Prerequisites
Before you begin, ensure you have the following installed:- Rust (1.87 or later) - Install Rust
- Docker and Docker Compose - Install Docker
- PostgreSQL (via Docker)
- Redis (via Docker)
- Git - Install Git
Quick start
Configure environment variables
Copy the example environment file and configure your local database credentials:Edit the
.env file with your local configuration. For local development, you can use:Start infrastructure services
Start PostgreSQL and Redis using Docker Compose:This will start:
- PostgreSQL on port
5000(mapped from container port5432) - Redis on port
6380(mapped from container port6379)
The database will persist data in
./docker/postgres-data and Redis in ./docker/redis-data.Build the project
Return to the project root and build all services:This will compile all workspace members including:
router- REST API serverengine- Order matching enginews-stream- WebSocket streaming servicedb-processor- Database operations processor
Service ports
When running locally, the services use the following ports:| Service | Port | Description |
|---|---|---|
| Router | 8080 | REST API endpoints |
| Engine | 8081 | Order matching engine |
| WebSocket | 4000 | Real-time market data streams |
| DB Processor | 8083 | Database operations |
| PostgreSQL | 5000 | Database (mapped from 5432) |
| Redis | 6380 | Pub/sub and caching (mapped from 6379) |
Development workflow
Running tests
Code formatting
The project usesrustfmt for code formatting:
Linting
Run Clippy for linting:Database migrations
The project uses SQLx for database migrations. Migrations are located in:SQLx requires
DATABASE_URL to be set in your environment or .env file.Troubleshooting
Port already in use
If you see errors about ports being in use, check what’s running:Database connection errors
If you can’t connect to PostgreSQL:-
Verify Docker containers are running:
-
Check container logs:
-
Ensure your
.envfile has correct credentials matching the Docker setup.
Redis connection errors
If Redis connection fails:-
Check Redis is running:
-
Test Redis connection:
SQLX offline mode
If you encounter SQLx compile-time verification errors:Clean rebuild
If you encounter build issues, try a clean rebuild:Hot reload
For faster development iterations, you can usecargo-watch:
Next steps
- Learn about Docker deployment for containerized development
- Explore the API documentation
- Read about production deployment