Skip to content

Kwasus33/Virtual-Currency-Exchange-Service

Repository files navigation

Virtual-Currency-Exchange-Service

Summary

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.

Architecture Overview

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.

Core Infrastructure

  • 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.

Technology Stack

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

Service Details

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 Available funds (liquid) and Frozen funds (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.

DevOps & CI/CD Pipelines

This project adheres to DevOps best practices to ensure reproducibility and stability.

  • Containerization: Each service contains a multi-stage Dockerfile to minimize image size.
  • Orchestration: docker-compose manages the entire stack, including network bridges and volume persistence.
  • Continuous Integration (Jenkins):
    1. Checkout: Pulls latest code from GitHub.
    2. Build: Maven/pip compile and package.
    3. Test: Runs Unit and Integration tests via a dedicated Test Runner container.
    4. Publish: Pushes verified artifacts to a private Nexus repository.

Installation & Execution

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

API Reference

  • Gateway URL: http://localhost:8082
  • Auth Header: Authorization: Bearer <token>

About

Virtual service for currency exchange

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors