Stack
This project is built with a robust and modern technology stack:
- Runtime: Bun
- Backend: Hono v4
- Frontend: Next.js 16, React 19, Tailwind CSS v4
- Database: PostgreSQL 15 with PgBouncer
- ORM: Prisma v7
- Cache/Sessions: Redis v5
- Matching Engine: TypeScript (in-process) and Go 1.22
- Message Broker: Redpanda (Kafka-compatible)
- WebSockets: Bun native + Redis pub/sub
- Blockchain: Solana Web3.js, SPL Token
- Wallet Adapters: Phantom, Solflare
- Charts: lightweight-charts v5
- Monorepo: Turborepo
- Infrastructure: Docker Compose, Kubernetes, Nginx
- Monitoring: Prometheus, Grafana
Monorepo Structure
The project is organized as a monorepo with the following structure:
- apps/server: Hono API server with in-process TypeScript matching engine and a separate Go matching engine microservice.
- apps/client: Next.js frontend application.
- packages: Shared packages for database, configuration, types, pub/sub, and event brokering.
- nginx: Configuration for reverse proxy, rate limiting, and WebSocket upgrades.
- k8s: Kubernetes manifests for deployment.
- docker-compose.yml: Docker Compose configuration for local development and deployment.
Getting Started
Prerequisites: Bun, Docker, Docker Compose, and Go (for local Go engine development).
Installation: Run bun install.
Environment Setup: Copy and fill in the .env files for both server and client.
Running Locally: Use Docker Compose to start infrastructure services (Postgres, Redis, Redpanda). Run database migrations with Prisma, then start the server and client applications.
Architecture Overview
The system follows a client-server architecture with a robust backend designed for high performance and scalability:
- Requests flow from the Client through Nginx to the Server (Hono).
- The matching engine is available in two versions: an in-process TypeScript engine (v1) and a separate Go microservice (v2) that communicates via Kafka.
- Order settlement and WebSocket communication are handled via Kafka and Redis pub/sub.
Key Features
- Centralized Cryptocurrency Exchange (CEX): A full-stack CEX built as a monorepo.
- Dual Matching Engines: Offers both an in-process TypeScript engine for low latency and a Go microservice for high concurrency, with Kafka integration.
- Real-time Data: WebSocket channels provide live updates for order books, trades, and tickers.
- Solana Integration: Supports SOL and SPL token deposits and withdrawals with deterministic address generation.
- Scalable Infrastructure: Designed for deployment on Kubernetes with Docker Compose for local development.
- Comprehensive Monitoring: Integrated Prometheus and Grafana for system performance tracking.