Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

249 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ TradeFlux

TradeFlux is a cloud-native distributed trading infrastructure platform built to simulate real-world stock trading workflows using microservices, event-driven architecture, observability, and container orchestration.

The project focuses on designing production-grade backend systems by combining synchronous and asynchronous communication patterns, service discovery, distributed tracing, monitoring, and Docker-based deployment.


🎯 Project Goals

TradeFlux was built to explore:

  • Distributed Systems Design
  • Event-Driven Architecture
  • Cloud-Native Development
  • Microservices Communication
  • Observability & Monitoring
  • Containerization & Orchestration
  • Production-Grade Backend Engineering

πŸ—οΈ System Architecture

                         +------------------+
                         |    API Gateway   |
                         +---------+--------+
                                   |
      ---------------------------------------------------------
      |                |                 |                    |
      β–Ό                β–Ό                 β–Ό                    β–Ό

+-------------+ +-------------+ +-------------+ +-------------+
| Auth Service| | User Service| |Order Service| |WalletService|
+-------------+ +-------------+ +------+------| +------+------+
                                      |               |
                                      |               |
                                      β–Ό               β–Ό

                               +-------------+  +-------------+
                               |    Kafka    |  | PostgreSQL  |
                               +------+------+  +------+------+
                                      |
                                      |
                                      β–Ό

                              +---------------+
                              |PortfolioService|
                              +---------------+


⚑ Core Business Workflow

Order Placement Flow

Client
   β”‚
   β–Ό

API Gateway
   β”‚
   β–Ό

Order Service
   β”‚
   β”œβ”€β”€ Reserve Funds (Wallet Service)
   β”‚
   └── Publish OrderPlacedEvent
            β”‚
            β–Ό
          Kafka

Order Execution Flow

Order Service
      β”‚
      β–Ό

OrderExecutedEvent
      β”‚
      β–Ό

Kafka
      β”‚
      β”œβ”€β”€ Wallet Service
      β”‚       └── Consume Funds
      β”‚
      └── Portfolio Service
              └── Update Holdings

🧩 Microservices

API Gateway

Responsibilities:

  • Single Entry Point
  • JWT Authentication
  • Request Routing
  • Route Protection

Auth Service

Responsibilities:

  • User Registration
  • User Authentication
  • JWT Generation
  • JWT Validation

User Service

Responsibilities:

  • User Profile Management
  • User Registration Event Handling

Wallet Service

Responsibilities:

  • Wallet Creation
  • Fund Management
  • Reserve Funds
  • Release Funds
  • Consume Funds

Order Service

Responsibilities:

  • Buy Order Placement
  • Order Lifecycle Management
  • Kafka Event Publishing
  • Wallet Integration

Portfolio Service

Responsibilities:

  • Portfolio Holdings
  • Position Tracking
  • Event-Based Updates

πŸ“‘ Communication Patterns

Synchronous Communication

OpenFeign

Used for:

Order Service β†’ Wallet Service

Asynchronous Communication

Apache Kafka

Events:

  • UserRegisteredEvent
  • OrderPlacedEvent
  • OrderCancelledEvent
  • OrderExecutedEvent

πŸ” Observability

Distributed Tracing

Implemented using:

  • Micrometer Tracing
  • Brave
  • Zipkin

Trace Flow:

Gateway
   ↓
Order Service
   ↓
Wallet Service
   ↓
Portfolio Service

Metrics

Implemented using:

  • Spring Boot Actuator
  • Micrometer
  • Prometheus

Available Metrics:

  • JVM Metrics
  • Memory Usage
  • CPU Usage
  • HTTP Requests
  • Response Time
  • Application Health

Monitoring Dashboard

Implemented using:

  • Grafana

Dashboards:

  • Service Health
  • Request Throughput
  • JVM Monitoring
  • Application Metrics

🐳 Containerization

All services are fully containerized using Docker.

Containerized Components:

  • API Gateway
  • Auth Service
  • User Service
  • Wallet Service
  • Portfolio Service
  • Order Service
  • Discovery Server
  • PostgreSQL
  • Kafka
  • Zipkin

πŸš€ Docker Compose Deployment

Start the complete platform:

docker compose up -d

Stop the platform:

docker compose down

Check running containers:

docker ps

πŸ› οΈ Technology Stack

Backend

  • Java 21
  • Spring Boot 3
  • Spring Cloud

Microservices

  • Eureka Discovery Server
  • Spring Cloud Gateway
  • OpenFeign

Messaging

  • Apache Kafka

Database

  • PostgreSQL

Observability

  • Prometheus
  • Grafana
  • Zipkin
  • Micrometer
  • Spring Actuator

Containerization

  • Docker
  • Docker Compose

πŸ“ˆ Current Features

  • JWT Authentication
  • Service Discovery
  • API Gateway Routing
  • Event-Driven Communication
  • Portfolio Management
  • Wallet Management
  • Order Lifecycle Management
  • Distributed Tracing
  • Metrics Collection
  • Dockerized Infrastructure
  • Docker Compose Deployment

πŸ”œ Next Roadmap

  • Kubernetes Deployment
  • ConfigMaps & Secrets
  • Ingress Controller
  • Horizontal Pod Autoscaler
  • Minikube Deployment
  • AWS EKS Deployment
  • CI/CD Pipeline
  • GitHub Actions
  • Centralized Logging

⭐ Key Learnings

  • Designing Event-Driven Systems
  • Distributed Transaction Handling
  • Service-to-Service Communication
  • Cloud-Native Architecture
  • Container Orchestration
  • Production Observability
  • Microservice Deployment Strategies

About

TradeFlux is a cloud-native distributed trading infrastructure simulation designed to explore low-latency systems, event-driven architecture, real-time market streaming, and production-grade backend engineering

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages