TradeForge Backend is a microservice-style Node.js backend for a crypto trading platform. It currently covers user creation, wallet management, and order lifecycle basics, with PostgreSQL and Prisma as the persistence layer.
The architecture is being built in stages: the current services already expose useful APIs and include wallet locking logic for order placement, while the matching engine, websocket distribution, and Redis-based real-time infrastructure are planned next.
user-servicecan create users, delete users, and change passwords.wallet-servicecan create wallets and manage balances.order-servicecan create buy and sell orders and cancel open orders.- PostgreSQL is available through Docker Compose.
- Prisma schema, migrations, and ERD generation are already present.
- Matching and trade execution are not implemented yet.
The backend is currently split into three services:
user-serviceon port30001order-serviceon port30002wallet-serviceon port30003
Each service follows a layered structure:
- route
- controller
- service
- repository
- Prisma persistence
The services communicate over HTTP where needed. For example:
- user creation triggers wallet creation in the wallet service
- order creation queries wallet ownership and locks balances before opening orders
- Node.js
- TypeScript
- Express 5
- Prisma ORM
- PostgreSQL
- Zod
- bcryptjs
- Docker Compose
The Prisma schema already models the main trading entities:
UserWalletWalletBalanceOrderTrade
Enums are already defined for:
- currencies
- supported pairs
- order side
- order status
At the moment, the schema is ahead of the execution engine: Trade and advanced order states exist in the model, but the matching flow that produces them is still in progress.
Base route: /user
Implemented endpoints:
POST /user/new-userDELETE /user/:idPOST /user/:id/passwordGET /healthz
Current responsibilities:
- validate user input with Zod
- hash passwords with bcrypt
- enforce uniqueness for email, username, and ID number
- trigger wallet creation after successful user creation
Base route: /wallet
Implemented endpoints:
POST /wallet/:userId/createWalletGET /wallet/:userId/balancesPOST /wallet/:userId/creditPOST /wallet/:userId/debitGET /wallet/:userId/getWalletGET /healthz
Current responsibilities:
- create a wallet for a user
- store balances per currency
- credit available funds
- debit available funds with transaction safety
- return wallet balances for upstream services
Base route: /order
Implemented endpoints:
POST /order/:userId/ordersPOST /order/:userId/orders/:id/cancelGET /healthz
Current responsibilities:
- validate new order requests
- create buy and sell orders
- lock quote/base assets depending on order side
- cancel open orders
- unlock remaining funds when orders are cancelled
- Node.js 20+
- npm
- Docker Desktop or a local Docker engine
From the backend directory:
docker compose up -dThis starts PostgreSQL on port 5433.
Install dependencies inside each service directory:
cd services/user-service
npm install
cd ../wallet-service
npm install
cd ../order-service
npm installEach service expects at least:
PORT=30001
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/trading?schema=public
JWT_SECRET=change-meAdjust PORT per service:
- user-service:
30001 - order-service:
30002 - wallet-service:
30003
You can start services manually:
npm run devOr use the helper script from the backend root:
.\start-dev.ps1backend/
docker-compose.yml
start-dev.ps1
services/
user-service/
wallet-service/
order-service/
shared/
Each service contains:
src/
app.ts
server.ts
config/
common/
modules/
<domain>/
prisma/
schema.prisma
migrations/
- modular service boundaries
- input validation with Zod
- password hashing
- wallet auto-creation on signup
- wallet credit and debit operations
- order creation with funds locking
- order cancellation with funds unlock
- shared trading schema across services
- no API gateway is wired and documented yet
- no authentication tokens or session flow yet
- no matching engine
- no trade settlement execution
- no websocket broadcasting
- no Redis integration yet
- no automated test suite yet
- build the matching engine
- introduce Redis for pub/sub, queueing, and market event fan-out
- add websocket infrastructure for live order book and market trades
- settle matched trades and update balances automatically
- expose market depth and recent trades endpoints
- add authentication and authorization flow
- add an API gateway for routing and consolidation
- add integration tests for service-to-service behavior
This backend is designed as a serious learning and portfolio project focused on real trading-system concepts:
- service boundaries
- balance locking and unlock flows
- transactional correctness around orders
- database modeling for trading entities
- readiness for real-time exchange infrastructure