Production-grade mini exchange monorepo. NestJS API, Typescript matching engine, NATS JetStream, PostgreSQL, Prisma.
- Node.js 20+
- pnpm 8+
- Docker (for Postgres + NATS)
-
Copy environment:
cp .env.example .env cp .env.example apps/api/.env
-
Start infrastructure (Postgres, NATS):
make up
-
Create NATS JetStream streams (orders.commands., orders.events., trades.events.*):
make nats-setup
-
Install dependencies and run migrations:
pnpm install make migrate
-
Run services locally:
make api # NestJS API on http://localhost:3000 make engine # Go matching engine
helix-exchange/
├── apps/
│ ├── api/ # NestJS REST API
│ └── engine/ # Go matching engine
├── packages/
│ └── contracts/ # Shared event types (TypeScript)
└── infra/
└── docker-compose.yml
| Variable | Description | Default |
|---|---|---|
| PORT | API server port | 3000 |
| DATABASE_URL | PostgreSQL connection | postgresql://... |
| NATS_URL | NATS server URL | nats://localhost:4222 |
| NATS_MAX_RECONNECT | NATS reconnect attempts | 10 |
- API:
make apiorpnpm --filter api dev - Database migrations:
make migrate - Docker logs:
make logs
| Command | Description |
|---|---|
make up |
Start Postgres, NATS, API, Engine |
make down |
Stop all containers |
make logs |
Tail container logs |
| Service | Port |
|---|---|
| API | 3000 |
| Postgres | 5432 |
| NATS | 4222 |
- API:
GET http://localhost:3000 - Health:
GET http://localhost:3000/health