A distributed, microservices-based trading platform designed for high-availability currency exchange. This system implements a classic API Gateway + Service Registry pattern to ensure scalability and dynamic service discovery.
The system operates on a containerized infrastructure managed by Docker Compose. It separates concerns into distinct business domains (Trading, Wallets, User Mgmt, Market Data), all orchestrated via a central Gateway.
- API Gateway (Spring Cloud Gateway): Single entry point. Handles reverse proxying and request routing.
- Service Registry (Netflix Eureka): Maintains a live registry of active service instances for client-side load balancing and dynamic routing.
- CI/CD: Automated pipelines via Jenkins triggered on GitHub commits. Artifacts managed in Nexus.
| Component | Technology | Responsibility |
|---|---|---|
| Api Gateway | Java 21, Spring Boot | Routing, Rate Limiting, Access Control |
| Service Registry | Java 21, Spring Cloud Eureka | Service Discovery & Health Monitoring |
| User Service | Java 21, Spring Boot, JWT | Identity Management (Authentication/Authorization) |
| Trading Service | Java 21, Spring Boot | Order Matching Engine, Order Book Management |
| Wallet Service | Java 21, Spring Boot | Ledger Management (Available vs. Frozen Funds) |
| Market Data | Python, FastAPI | Near Real-time external price ingestion (NBP API) |
| Frontend | TypeScript, React | User Interface |
| Infrastructure | Docker, Jenkins, Nexus | Containerization, CI/CD, Artifact Storage |
1. User Service (Identity Provider) Handles the full lifecycle of user identity.
- Public Endpoints:
/register,/authenticate,/verify-code - Security: Implements JWT (JSON Web Token) issuance.
- Flow: Upon successful authentication, a Bearer token is generated, which is required for all subsequent requests to protected services.
2. Trading Service (Order Matching Engine) The core business logic unit.
- Maintains the Central Order Book.
- Executes trade matching algorithms.
- Logs all transaction history for auditability.
- Controls order lifecycle (Place, Cancel, Fill).
3. Wallet Service (Ledger) Manages user balances with strict transactional integrity.
- State Management: Distinguishes between
Availablefunds (liquid) andFrozenfunds (locked in active orders). - Prevents double-spending via pessimistic locking during trade execution.
4. Market Data Service (Ingestion) Lightweight Python service optimized for I/O operations.
- Source: Scrapes official exchange rates from NBP (Narodowy Bank Polski).
- Feeds near real-time pricing data into the Trading Service.
This project adheres to DevOps best practices to ensure reproducibility and stability.
- Containerization: Each service contains a multi-stage
Dockerfileto minimize image size. - Orchestration:
docker-composemanages the entire stack, including network bridges and volume persistence. - Continuous Integration (Jenkins):
- Checkout: Pulls latest code from GitHub.
- Build: Maven/pip compile and package.
- Test: Runs Unit and Integration tests via a dedicated Test Runner container.
- Publish: Pushes verified artifacts to a private Nexus repository.
Prerequisites: Docker Engine, Docker Compose.
Quick Start (Local) To spin up the entire infrastructure including the Eureka Server and all microservices:
git clone https://github.com/Kwasus33/Virtual-Currency-Exchange-Service.git
cd Virtual-Currency-Exchange-Service
docker-compose up -d --build
open http://localhost:8761 # Verify System Health
open http://localhost:3000 # Frontend- Gateway URL:
http://localhost:8082 - Auth Header:
Authorization: Bearer <token>