Skip to main content

MyTradeX System Architecture Overview

Executive Summary

MyTradeX is an enterprise-grade IDX (Indonesia Stock Exchange) trading platform built with a modern microservices architecture. The system provides comprehensive trading capabilities including real-time market data, order management, portfolio tracking, and administrative functions across multiple platforms (web, mobile, desktop).

Architecture Philosophy

Core Principles

  • Microservices Architecture: Modular, independently deployable services
  • Event-Driven Architecture: Real-time communication via WebSocket
  • Multi-Platform Support: Shared business logic across platforms
  • Security-First Design: Comprehensive authentication and authorization
  • Scalability: Horizontal scaling capabilities for high-volume trading
  • Compliance: Built-in audit trails and regulatory compliance

Technology Stack Summary

LayerTechnologyPurpose
FrontendNext.js 14, React Native, TypeScriptMulti-platform UI
BackendJava Spring Boot (Microservices)Business logic & API
DatabasePostgreSQLPrimary data storage
Real-timeWebSocket, Socket.IOLive market data & updates
SecuritySpring Security, JWTAuthentication & authorization
ProtocolsFIX, ITCH, OUCHExchange connectivity

System Architecture

High-Level Architecture

The MyTradeX platform follows a layered architecture pattern:

  1. Presentation Layer: Multi-platform clients (Web, Mobile, Desktop, Admin)
  2. API Gateway Layer: RESTful APIs and WebSocket endpoints
  3. Service Layer: Business logic microservices
  4. Data Layer: Persistent storage and caching
  5. Infrastructure Layer: Message brokers, monitoring, deployment

Microservices Architecture

The backend is composed of the following microservices:

Core Services

  • User Service: Authentication, authorization, user management
  • Order Service: Order lifecycle management
  • Trade Service: Trade execution and history
  • Position Service: Portfolio and position management
  • Market Data Service: Real-time market data processing

Protocol Services

  • FIX Handler: Financial Information eXchange protocol
  • ITCH Handler: Individual Trading and Clearing for Harmonized protocols
  • OUCH Handler: OUCH protocol for order entry

Infrastructure Services

  • Security Service: JWT management, role-based access control
  • Repository Service: Data access abstraction
  • Audit Service: System activity logging

Platform Architecture

Frontend Platforms

  1. Customer Web App (mytradex-monorepo/apps/customer-web)

    • Next.js 14 with App Router
    • TypeScript for type safety
    • Tailwind CSS for styling
    • Real-time updates via WebSocket
  2. Customer Mobile App (mytradex-monorepo/apps/customer-mobile)

    • React Native for cross-platform mobile
    • TypeScript for type safety
    • React Navigation for routing
    • Theme context for dark/light mode
  3. Customer Desktop App (mytradex-monorepo/apps/customer-desktop)

    • Vite + React application
    • Electron-ready architecture
    • TypeScript for development
  4. Admin Portal (mytradex-monorepo/apps/admin-portal)

    • Next.js pages router
    • Role-based access control
    • Comprehensive admin tools

Backend Services

  1. Security Module (mytradex-backend/security)

    • JWT authentication
    • Spring Security configuration
    • Role-based authorization
  2. Core Module (mytradex-backend/core)

    • Entity definitions
    • DTOs and mappers
    • Business exceptions
  3. Service Layer (mytradex-backend/service)

    • Business logic implementation
    • Transaction management
    • External integrations
  4. Repository Layer (mytradex-backend/repository)

    • Data access patterns
    • Database operations
    • Query optimization
  5. Protocol Layer (mytradex-backend/protocol)

    • Exchange protocol implementations
    • Message parsing and handling
    • Order routing

Data Flow Architecture

Order Flow

  1. Order Entry: Client → Order Service → Protocol Handler
  2. Order Validation: Service Layer validation and business rules
  3. Order Routing: Protocol-specific routing to exchanges
  4. Order Status Updates: Real-time updates via WebSocket
  5. Trade Execution: Trade Service processes execution reports
  6. Position Updates: Position Service updates user portfolios

Market Data Flow

  1. Data Ingestion: Market Data Service receives market feeds
  2. Data Processing: Real-time processing and enrichment
  3. Data Broadcasting: WebSocket broadcasts to subscribed clients
  4. Data Persistence: Historical data storage in database

Authentication Flow

  1. Login: Client → Security Service → JWT Token
  2. Authorization: Token-based request validation
  3. Session Management: Stateless session with token refresh
  4. Role-based Access: Role hierarchy enforcement

Communication Patterns

RESTful APIs

  • Standard HTTP/HTTPS communication
  • JSON request/response format
  • OpenAPI/Swagger documentation
  • Request/response validation

WebSocket Communication

  • Real-time bidirectional communication
  • Event-driven message handling
  • Subscription-based data delivery
  • Automatic reconnection handling

Inter-Service Communication

  • Spring's @Async for asynchronous processing
  • Message brokers for event-driven communication
  • Service discovery for dynamic routing

Deployment Architecture

Containerization

  • Docker containers for all services
  • Kubernetes orchestration (production)
  • Container registry for image management

Infrastructure

  • Load balancing for high availability
  • CDN for static content delivery
  • Database clustering for data persistence
  • Monitoring and logging infrastructure

Next: Detailed Component Documentation

Continue to the following documentation sections:

  1. Frontend Architecture
  2. Backend Architecture
  3. Database Schema
  4. Real-time Communication
  5. Security Architecture
  6. API Documentation
  7. Deployment Guide