Trinity Beast – System Architecture Guide

Technical overview of architecture, components, data flows, and AWS infrastructure

📍 Region: us-east-2 (Ohio) 🏗️ Version: Production 📅 Updated: April 2026

1. Overview

Trinity Beast is a high-performance cryptocurrency price API infrastructure built on AWS, delivering real-time prices with sub-10ms cached responses and 10,000+ QPS capacity — all for approximately $215/month.

Max QPS
10,000+
Cached Response
<10ms
Uncached Response
30–50ms
Cache Hit Rate
85–95%
Monthly Cost
~$215
Availability
Multi-AZ

2. System Architecture

The system consists of three independently deployed services behind an Application Load Balancer, backed by Aurora Serverless v2 and MemoryDB (Redis-compatible).

High-Level Architecture AWS us-east-2
Internet
    │
    ▼
Application Load Balancer (ALB)
    │
    ├──▶ LPO Server (ECS Fargate) ──▶ MemoryDB (Redis) ──▶ Coinbase/Kraken/Gemini
    │
    ├──▶ LRS Server (ECS Fargate) ──▶ MemoryDB (Redis)
    │
    └──▶ Sync Job (ECS Fargate)   ──▶ Aurora PostgreSQL ──▶ MemoryDB (Redis)
                                                │
                                         Aurora Serverless v2

3. Components

3.1 LPO Server (Listener Price Oracle)

trinity-beast-lpo-server Go / ECS Fargate

The LPO is the primary price-serving component. It checks MemoryDB first (cache hit = <10ms), then falls back to live exchange APIs.

Key Features

  • Multi-source failover: Coinbase → Kraken → Gemini
  • Response-first architecture: logs and metrics written in background goroutines
  • Go runtime tuned: GOMAXPROCS(NumCPU()), GCPercent(200)
  • HTTP client reuse with connection pooling
CPU
2 vCPU
Memory
4 GB
Port
8080

3.2 LRS Server (Listener Report Service)

trinity-beast-lrs-server Go / ECS Fargate

The LRS reads usage logs from MemoryDB and generates reports. Supports filtering, pagination, and multiple output formats.

Output Formats

  • json — Default, structured API response
  • csv — Comma-separated, Excel/Sheets compatible
  • tsv — Tab-delimited, database/ETL friendly
  • text — Human-readable plain text
CPU
4 vCPU
Memory
8 GB
Port
9090

3.3 Sync Job

trinity-beast-sync-job Go / ECS Fargate

Periodically flushes usage logs from MemoryDB to Aurora PostgreSQL for long-term storage and reporting. Also handles cache prewarming.

  • Batch writes to Aurora (configurable batch size and interval)
  • Tier-based cache prewarming: top assets every 5 min, mid-tier every 15 min
  • Staggered across services to prevent thundering herd

4. Data Flows

Price Request Flow (LPO)

1
Client sends GET /price?asset=BTC with Bearer token to ALB
2
ALB routes to LPO Fargate task
3
LPO checks MemoryDB for cached price (price:BTC)
4a
Cache hit: Returns price immediately (<10ms). Logs usage in background goroutine.
4b
Cache miss: Fetches from Coinbase → Kraken → Gemini (30–50ms). Writes to MemoryDB. Returns price.

Report Request Flow (LRS)

1
Client sends GET /reports/usage?format=csv with Bearer token
2
LRS queries MemoryDB sorted sets by time range and filters
3
Fetches full log hashes from MemoryDB
4
Formats and streams response in requested format (JSON/CSV/TSV/text)

5. AWS Infrastructure

Amazon MemoryDB (Valkey 7.3)

MemoryDB Clusterr7g.large
Node Type
db.r7g.large
Memory
13 GB
Throughput
100K+ ops/sec
Monthly Cost
~$50

Amazon Aurora Serverless v2

Aurora PostgreSQLServerless v2
ACU Range
1–16 ACU
IOPS
Unlimited
Mode
Optimized I/O
Cost Savings
40% vs standard

Amazon ECS on AWS Fargate

ServiceCPUMemoryTasksMonthly Cost
LPO Server2 vCPU4 GB1~$60
LRS Server4 vCPU8 GB1~$95
Sync Job0.5 vCPU1 GB1~$10

6. Deployment Strategies

Strategy 1: Separate Services (Production)

Each component runs as an independent ECS service. Allows independent scaling and zero-downtime deployments.

✅ Recommended for production. Currently deployed configuration.

Strategy 2: Combined Service (Development)

LPO and LRS run in a single container using APP_REPORT_SERVER mode. Reduces cost for dev/staging environments.

Strategy 3: Hybrid (Flexible Scaling)

LPO scales horizontally (multiple tasks) while LRS remains single-task. Use when LPO traffic increases but reporting load stays low.

Traffic LevelLPO TasksLRS TasksMonthly Cost
Current (Low)11~$215
Medium (5K QPS)21~$335
High (10K QPS)32~$485

7. Mission

100% of revenue funds freedom from brick kiln debt bondage in Pakistan through Cross Power Ministries of Pakistan.

The Trinity Beast Infrastructure is named in honor of the Father, Son, and Holy Spirit — built to serve both developers and the least of these.