01. Overview/System Topology

Engine Architecture & Data Flow

Every request GN-Apex receives is sorted before it's processed. Transactional work runs through a control plane built for correctness; telemetry runs through a sentry built for volume. Here's how the two stay out of each other's way.

Ingest latency
2–5ms
Node throughput
25K/s
Breaker trip
5 fails
Storage tiers
4
THROUGHPUT CAPACITY
25,000+
Events / Sec per Node Cluster

Actix-web zero-cost abstractions combined with Redis stream buffers ensure constant single-digit ingestion latency.

Compiled Rust Core · Non-Blocking Async Pipeline

Topological Overview

The platform routes traffic based on workload characteristics: heavy transactional workloads (Auth, Schemas, Billing, CRM) are handled by the NestJS Control Plane, while telemetry and RUM packets are directed to the Rust Analytics Sentry. Neither engine blocks on the other — a spike in one never degrades the other's latency.

Clientbrowser · mobile · IoTNESTJS · :3001Control PlaneAuth · Billing · CRMRUST · :3002Analytics SentryIngest · Score · Fan-outPostgreSQLPrisma · Orgs · CRMRedis ClusterStreams · BullMQMongoDBBSON · SessionsTLS 1.3 · EDGE ROUTED · REGIONAL FAILOVER ACTIVE

The Dual-Engine Model

ENGINE 1 / CONTROL PLANE

NestJS Core (Port 3001)

Governs business logic: RBAC authorization, custom schemas, billing transactions, WebPush notifications, and communication dispatchers.

ENGINE 2 / SENTINEL

Rust Sentry (Port 3002)

Built for massive throughput: validates tokens, checks rate limits, enriches GeoIP/ASN, and writes to Redis Streams in < 3ms.

STORAGE / RELATIONAL

PostgreSQL Truth Layer

ACID-compliant storage for users, organizations, custom domain certificates, invoices, and CRM address books.

STORAGE / TELEMETRY

MongoDB Event Vault

High-density BSON storage: holds billions of interaction events with N → 1 session aggregation to avoid lock contention.

Data Storage Tiers

Storage is strictly partitioned to guarantee high durability, sub-second query performance, and cost efficiency:

ParameterTypeRequirementDescription
PostgreSQL (Prisma)Relational ACIDRequiredHolds transactional records: Users, Project permissions, Invoices, Wallets, CRM contacts, and Domains.
MongoDB (BSON)Document StoreRequiredWritten exclusively by Rust: raw events, session documents, identities, and daily project summaries.
Redis StreamsIn-Memory FIFORequiredHigh-speed ingestion buffer (`MAXLEN ~1M`), BullMQ job queues, live active user counters, and cached queries.
Cloudflare R2 / S3Blob Object StoreRequiredStores optimized WebP/AVIF media, H.264 video streams, encrypted KYC documents, and compiled Next.js ISR bundles.

The High-Speed Write Path

When an analytics packet hits POST /api/collect, the Rust engine moves it through four phases — each one handing off to the next without waiting for it to finish:

01

Token & Rate Limiting

Ingests the API key and evaluates client IP limits against an in-memory token bucket (L1) and Redis distributed limiters (L2).

02

Stream Buffering

Directly appends the packet into Redis Stream (events_stream) and returns HTTP 202 Accepted within 2–5ms.

03

Async Enrichment Workers

Background worker threads consume the stream, resolve GeoIP2/ASN metadata, parse User-Agent headers, run ML outlier scoring, and batch-write to MongoDB.

04

Real-time WS Fan-Out

Publishes the event to Redis Pub/Sub channels (live_events:*) to update live dashboard clients over WebSockets.

Circuit Breakers & Fault Tolerance

Cascading Failure Isolation
The Client SDK and Backend engines implement three-state Circuit Breakers (CLOSED, OPEN, HALF_OPEN). If network calls fail 5 times consecutively, traffic is temporarily halted for 30 seconds, and local cached data is served seamlessly to prevent cascading server crashes.