A production-quality order execution platform built with Java Spring Boot, demonstrating real-world trading system architecture with comprehensive risk management, transaction handling, and audit trails.
This system simulates a stock trading platform's order execution engine, handling order creation, validation, execution, and comprehensive audit logging. Built with enterprise-grade architecture and best practices, it showcases modern Java backend development skills.
- π Real-time Order Execution - Market and limit orders with instant processing
- π° Account Management - Multi-account support with balance tracking and validation
- π‘οΈ Risk Management - Pre-trade validation, balance checks, and account status verification
- π Audit Trail - Complete execution history with detailed logging
- π Web Dashboard - Modern UI for order management and monitoring
- π RESTful API - Clean REST endpoints with proper HTTP semantics
- π§ͺ Comprehensive Testing - Unit and integration tests with 70%+ coverage
- π³ Docker Ready - Containerized deployment with Docker Compose
| Layer | Technology |
|---|---|
| Backend | Java 17, Spring Boot 3.2 |
| Data Access | Spring Data JPA, Hibernate |
| Database | H2 (dev), PostgreSQL (prod) |
| Frontend | HTML5, CSS3, Vanilla JavaScript |
| Testing | JUnit 5, Mockito, Spring Boot Test |
| Build | Maven |
| Containerization | Docker, Docker Compose |
βββββββββββββββββββββββββββββββββββββββ
β Controllers (REST API Layer) β β HTTP Endpoints
βββββββββββββββββββββββββββββββββββββββ€
β Services (Business Logic) β β Order Execution, Validation
βββββββββββββββββββββββββββββββββββββββ€
β Repositories (Data Access) β β JPA/Hibernate
βββββββββββββββββββββββββββββββββββββββ€
β Entities (Domain Model) β β User, Account, Order, Log
βββββββββββββββββββββββββββββββββββββββ
User (1) βββ (N) Account (1) βββ (N) Order (1) βββ (N) ExecutionLog
- Java 17 or higher
- Maven 3.6+
- Docker (optional)
git clone https://github.com/yourusername/order-execution-system.git
cd order-execution-system
# Build the project
mvn clean install
# Run the application
mvn spring-boot:runThe application will start on http://localhost:8080
| Service | URL | Description |
|---|---|---|
| Web UI | http://localhost:8080 | Interactive dashboard |
| REST API | http://localhost:8080/api | API endpoints |
| H2 Console | http://localhost:8080/h2-console | Database viewer |
| Health Check | http://localhost:8080/actuator/health | Application status |
H2 Console Credentials:
- JDBC URL:
jdbc:h2:mem:orderdb - Username:
sa - Password: (leave empty)
POST /api/orders
Content-Type: application/json
{
"accountId": 1,
"symbol": "AAPL",
"type": "MARKET",
"side": "BUY",
"quantity": 100
}GET /api/ordersGET /api/orders/{id}PUT /api/orders/{id}/cancelGET /api/accountsGET /api/accounts/{id}GET /api/execution-logsGET /api/execution-logs/order/{orderId}mvn test- Unit Tests: Service layer business logic
- Integration Tests: Repository queries and controller endpoints
- Coverage: 70%+ across all layers
- β Order creation with valid account
- β Order rejection with insufficient balance
- β Account status validation
- β Transaction rollback on failure
- β Execution log creation
# Run with H2 (Development)
docker-compose up app-dev
# Run with PostgreSQL (Production)
docker-compose up postgres app-proddocker build -t order-execution-system:latest .users
- Stores user information and status
- Indexes: email, status
accounts
- Trading accounts with balance tracking
- Indexes: user_id, account_number, status
orders
- Order details and execution status
- Indexes: account_id, symbol, status, created_at
execution_logs
- Audit trail of all executions
- Indexes: order_id, executed_at
The included web UI provides:
- π Real-time Dashboard - View accounts, orders, and execution logs
- π Order Creation - Interactive form for placing orders
- π Auto-refresh - Updates every 10 seconds
- π¨ Responsive Design - Works on desktop and mobile
- β Status Indicators - Color-coded order and account statuses
Development (default)
spring.profiles.active=dev
# Uses H2 in-memory database
# Auto-creates schema
# Initializes test dataProduction
spring.profiles.active=prod
# Uses PostgreSQL
# Requires database setup
# No test data initialization| Variable | Description | Default |
|---|---|---|
DB_USERNAME |
Database username | postgres |
DB_PASSWORD |
Database password | postgres |
SPRING_PROFILES_ACTIVE |
Active profile | dev |
order-execution-system/
βββ src/
β βββ main/
β β βββ java/com/portfolio/orderexecution/
β β β βββ config/ # Configuration classes
β β β βββ controller/ # REST controllers
β β β βββ dto/ # Data Transfer Objects
β β β βββ entity/ # JPA entities
β β β βββ exception/ # Exception handling
β β β βββ mapper/ # Entity-DTO mappers
β β β βββ repository/ # Data access layer
β β β βββ service/ # Business logic
β β βββ resources/
β β βββ static/ # Web UI files
β β βββ application.yml # Configuration
β βββ test/ # Test classes
βββ docker-compose.yml # Docker setup
βββ Dockerfile # Container image
βββ pom.xml # Maven dependencies
βββ README.md # This file
Clean separation of concerns with distinct layers for presentation, business logic, and data access.
Separate API contracts from domain models for flexibility and security.
ACID compliance for financial operations using Spring's @Transactional.
Global exception handler providing consistent error responses.
Strategic indexes on frequently queried columns for optimal performance.
Orders execute synchronously for simplicity (can be extended to async).
- Spring Security with JWT authentication
- WebSocket for real-time order updates
- Advanced order matching engine
- Position tracking and portfolio management
- Market data integration
- Performance metrics and monitoring
- Database migration with Flyway/Liquibase
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Fizzexual
- GitHub: @fizzexual
- LinkedIn: Your Profile
- Portfolio: fizzexual.github.io
- Built with Spring Boot
- Inspired by real-world trading systems
- Created as a portfolio demonstration project
β Star this repository if you find it helpful!
This is a demonstration project showcasing backend development skills. It is not intended for production trading.