Skip to content

Architecture Overview

TradeX is built as a microservices architecture, with each service handling a specific domain.

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Frontend │────▶│ Backend │────▶│ Services │
│ (Next.js) │ │ (Hono) │ │ (Microsvcs) │
└─────────────┘ └─────────────┘ └─────────────┘
┌─────────────┐
│ Database │
│ (MongoDB) │
└─────────────┘
  • Next.js Application: User interface and client console
  • WebSocket Client: Real-time data streaming
  • Market Data Service: Market data ingestion and distribution
  • Order Service: Order management and execution
  • Auth Service: Authentication and authorization
  • User Service: User profile management
  • Wallet Service: Wallet operations and balance tracking
  • Metadata Service: Trading symbols and configuration
  • MongoDB: Primary database
  • PostgreSQL: Relational data storage
  • Redis: Caching and session management
  • Kafka: Event streaming and messaging
  • gRPC: Inter-service communication
  1. Market Data: External exchanges → Market Data Service → WebSocket/Kafka → Clients
  2. Orders: Client → Order Service → Matching Engine → Execution
  3. Authentication: Client → Auth Service → JWT Token → Service Access

For detailed data flows, see the Data Flow documentation.

Services communicate via:

  • REST APIs: External client access
  • gRPC: Internal service-to-service communication
  • Kafka: Event-driven messaging
  • WebSocket: Real-time client updates

For detailed communication patterns, see the Communication Patterns documentation.

Real-time market data ingestion, processing, and distribution via WebSocket and REST APIs.

Order management, validation, and lifecycle handling with integration to matching engine.

High-performance order matching and trade execution engine built in Rust.

Canonical reference data store for instruments, configuration, and trading rules.

User authentication, JWT token management, and API key management.

User profile management, preferences, and KYC workflows.

Balance management, deposits, withdrawals, and transaction history.

Position tracking, risk calculations, and position limit enforcement.

API aggregation layer providing unified access to multiple services.

  • MongoDB: Document storage for user data and preferences
  • PostgreSQL: Relational data for transactions and configuration
  • TimescaleDB: Time-series data for market data
  • ClickHouse: Analytics and historical data storage
  • Redis: In-memory caching and session management
  • Kafka: Event streaming and asynchronous messaging
  • Schema Registry: Avro schema management for Kafka events
  • Prometheus: Metrics collection
  • Grafana: Metrics visualization
  • OpenTelemetry: Distributed tracing