Case Study
CEX Spot Trading & ICO Platform (Backend)
A centralized exchange backend focused on BEP20 spot trading, ICO lifecycle management, and operational tooling, built on a modular NestJS architecture.
Project Overview
This project delivers the backend for a centralized crypto exchange that supports secure spot trading for BEP20 tokens, ICO campaigns, and rich admin visibility. The system is implemented as a NestJS monolith with clear domain modules for trading, tokens, ICOs, users, wallets, security, and monitoring, backed by Redis for caching and WebSocket scalability and a relational database for strong consistency of orders, trades, and balances.
My Role
- Designed and implemented BEP20 spot trading flows.
- Worked on frontend integration for core trading UX (markets, order books, order placement).
- Integrated real-time updates via WebSockets for prices, orders, and balances.
- Built admin trading views and supervision tools.
- Extended the backend with a reusable ICO module.
- Ensured new features reused core wallet & trading services.
Tech Stack
- NestJS (Node.js), TypeScript
- PostgreSQL (relational database)
- Redis (caching & real-time)
- WebSockets for live markets & order updates
Core Problem Space
- Deliver familiar spot trading for BEP20 tokens with live prices, order books, and recent trades.
- Provide admin observability and control over trading activity for compliance, support, and incident response.
- Run ICO campaigns on top of the same wallet and ledger infrastructure to avoid fragmented balances and accounting mismatches.
- Maintain high security, auditability, and performance while continuously shipping new features.
Spot Trading (BEP20 Tokens)
The spot trading module is organized around symbols, orders, trades, and balances. BEP20 tokens are registered with metadata and exposed via a shared token service so the matching and trading logic can treat assets generically.
- Unified token representation: A single token service provides metadata, price data, and analytics for all BEP20 tokens.
- Market data pipeline: Dedicated services aggregate and cache prices, powering charts, market overviews, and volume metrics.
- Order lifecycle integration: Orders flow through a matching engine that creates trades and invokes wallet/balance services for settlements.
- Consistent balance accounting: All changes go through a single wallet/balance subsystem shared by deposits, withdrawals, trading, ICOs, and transfers.
Market Data Flow
The diagram below illustrates how market data is fetched and cached, with Redis serving as the primary cache layer and database fallback for historical data.

Spot Trading Order Flow
Sequence diagram showing the complete order lifecycle from user submission through authentication, fund reservation, matching, settlement, and audit logging.

Admin Trading Controls
Admin tooling focuses on deep visibility and safe interventions, without duplicating matching or wallet logic.
- Global order views with rich filtering across symbols, users, and statuses.
- Read-only-first design, with rare actions (like cancels) routed through core services.
- Role-based access control on all sensitive endpoints and data.
- Monitoring and logging hooks to trace how orders and balances evolved over time.
ICO Lifecycle on Shared Infrastructure
The ICO module reuses the same primitives as spot trading and wallets, so token sales feel native to the exchange instead of a separate system.
- Configurable campaigns (token, pricing, caps, schedules, rules) mapped to existing token records.
- Contributions recorded through the wallet subsystem, keeping ledgers consistent.
- Allocations and vesting flows that credit balances via the same balance engine as trading.
- Full admin visibility into participation, caps, and final distributions.
ICO Participation Flow
The sequence diagram below shows how users discover ICOs, check eligibility, contribute funds, and receive token allocations, all using the shared wallet and token infrastructure.

Results & Learnings
- A modular NestJS backend where trading, tokens, wallets, and ICOs share core abstractions but remain cleanly separated.
- Redis-backed caching and WebSockets deliver responsive market data and order updates.
- A single balance subsystem enforces consistency across deposits, withdrawals, trading, ICOs, and internal transfers.
- Powerful but safe admin tooling, all routed through well-tested services instead of ad-hoc database access.