← Back to Index
Architecture · ops.tradeit.gg
Backend Services Deep Dive
Deep dive into each core backend service — purpose, major components, connections, and key details.
Last updated: 2026-05-09
tradeit-backend
The heart of the platform. Handles all user-facing API endpoints, trade lifecycle, inventory queries, pricing reads, and bot coordination.
Major Components
- Routes: Express route files organized by domain (trades, inventory, users, deposits, withdrawals)
- OpenSearch integration:
openSearchService.js — inventory search with reserved item exclusion (genMustNot, mustNotGroup patterns)
- Bull queues: Async job processing for trades, notifications
- Transaction context:
express-http-context for request-scoped state
- MySQL pools: 40 connections, named placeholders, BigNumber as strings
- dd-trace: Datadog APM (must be imported first — before all other modules)
Connections
graph LR
BE[tradeit-backend] --> MySQL[(MySQL Aurora)]
BE --> Redis[(Redis)]
BE --> OS[(OpenSearch)]
BE --> TBS[tradeit-tradebot-server]
BE --> SS[tradeit-socket-server]
BE --> LS[tradeit-login-server]
NT[new-tradeit] --> BE
ADM[tradeit-admin-backend] --> BE
Key Details
- Port: 3000
- PM2 cluster mode inside Docker (--read-only, no curl)
- Webpack bundled for production
- Site disable toggle via config
- 429 rate limit interceptor
tradeit-tradebot-server
📖 Full deep dive: tradeit-tradebot-server — Redis/Bull contract surface, trade lifecycle sequences, MySQL surface, auto-QA contract.
Manages the entire fleet of ~400 Steam trade bots. Executes trades, monitors bot health, handles Steam API interactions.
Major Components
- Bot process: Single large file per bot instance — handles trade offers, inventory, health
- Redis pub/sub: Communicates with tradeit-backend for trade coordination
- Bull queues: Trade execution pipeline
- Steam SDK stack:
steam-user, steam-tradeoffer-manager, steam-community
- Casket system: Manages storage containers for bot items
- Login rate limiter: Prevents Steam API bans
Connections
graph LR
BE[tradeit-backend] --> TBS[tradeit-tradebot-server]
TBS --> Steam[Steam API]
TBS --> Redis[(Redis)]
TBS --> MySQL[(MySQL)]
IS[tradeit-inventory-server] --> TBS
Key Details
- Bot tiers:
veryGoodBots > goodBots > badBots (withdrawal routing priority)
- allowedPartnerIds: Whitelist for trusted trade partners
- Trade types: deposit, withdrawal, player-to-player
- Bots spread across multiple EC2 instances
- Restart via SSH scripts to EC2
tradeit-inventory-server
Fetches and aggregates bot inventories from Steam. Two sub-services: sinvbot (site inventory) and cinvbot (user/container inventory).
Major Components
- sinvbot (port 3000): Aggregates all bot inventories into site-wide view, fork mode
- cinvbot (port 3001): Fetches individual user/bot inventories, 4x cluster mode
- Bull queues: IP rotation, coordinated bot inventory fetching
- Redis as data bus: Compressed single-letter property names for payload efficiency
- PM2 instance 0: Special behavior — runs as queue processor
Connections
graph LR
IS[tradeit-inventory-server] --> Steam[Steam API]
IS --> Redis[(Redis)]
IS --> MySQL[(MySQL)]
IS --> ScraperAPI["ScraperAPI
fallback"]
BE[tradeit-backend] --> IS
IP[tradeit-inventory-parser] --> IS
Key Details
- Flat file structure (no
src/): sinvbot.ts, cinvbot.ts, util.ts
- Compressed property names (e.g., single-letter keys) for Redis payload size
- Express 5, legacy
mysql driver (not mysql2)
- Deploy via Makefile +
deploy.sh to EC2
tradeit-socket-server
Real-time WebSocket server. Pushes live updates to the frontend for inventory changes, trade status, and leaderboard.
Major Components
- Socket.IO 4: Main WebSocket engine with Redis adapter
- Redis pub/sub: Receives events from tradeit-backend
- MySQL polling: Falls back to polling for data that lacks pub/sub events (500ms interval)
- Throttled events: Reserve/unreserve events throttled to prevent client overload
Connections
graph LR
SS[tradeit-socket-server] --> Redis[(Redis)]
SS --> MySQL[(MySQL)]
BE[tradeit-backend] -->|pub/sub| SS
SS -->|WebSocket| NT[new-tradeit]
Key Details
- Port: 3000
- No PM2 in production (single process)
- 3-file
src/ layout
- Legacy
mysql driver
tradeit-service
Secondary API service. Handles SIH (Steam Inventory Helper) exports, product feed generation, and scheduled data processing jobs.
Major Components
- API endpoints: SIH feed, product feed exports, item data endpoints
- Scheduled jobs: Cron-based data aggregation and file generation
- OpenSearch: Scroll pagination for large dataset exports
- File-based data exchange: Generates files consumed by other services
Connections
graph LR
SVC[tradeit-service] --> MySQL[(MySQL)]
SVC --> OS[(OpenSearch)]
SVC --> Redis[(Redis)]
BE[tradeit-backend] --> SVC
Key Details
- Port: 3001
- No
src/ directory — files at root
- Singleton pattern for service instances
- Ramda utility usage
- Staging index suffix for env separation
tradeit-login-server
Steam authentication service. Handles Steam OpenID login flow, session creation, and domain validation.
Major Components
- Steam OpenID: Passport.js with forked
passport-openid strategy
- Domain whitelist: Validates redirect URLs against allowed domains
- Redis sessions: Session store with configurable TTL
Connections
graph LR
LS[tradeit-login-server] --> Steam[Steam OpenID]
LS --> Redis[(Redis)]
NT[new-tradeit] --> LS
LS --> BE[tradeit-backend]
Key Details
- Port: 3000
- Single-file architecture (
login.ts)
- Express 5 with forked passport library (compiled JS checked into repo)
- Domain whitelist for redirect validation
tradeit-oauth2-server
OAuth2/OIDC authentication server. Supports Steam, FACEIT, and GitHub login strategies with Swagger API documentation.
Major Components
- Passport strategies: Steam, FACEIT, GitHub
- Swagger: Auto-generated API documentation
- TypeORM: User and client management
- JWT: Token-based authentication
Connections
graph LR
OA[tradeit-oauth2-server] --> MySQL[(MySQL)]
OA --> Steam[Steam API]
OA --> FACEIT[FACEIT API]
OA --> GitHub[GitHub API]
BE[tradeit-backend] --> OA
Key Details
- Port: 3000
- Docker image name mismatch: Makefile uses
tradeit-oauth-server vs deploy.sh uses tradeit-oauth2-server
- NestJS with TypeORM
tradeit-admin-backend
Admin panel API. Powers the internal admin dashboard for managing items, users, bots, and pricing overrides.
Major Components
- Dual Prisma schemas: Main DB + Pricing DB
- JWT auth: Role-based access (admin hierarchy)
- Express routes: CRUD for all admin operations
- BigInt serialization: Custom JSON serializer for MySQL BigInt columns
Connections
graph LR
AB[tradeit-admin-backend] --> MySQL[(MySQL)]
ADM[tradeit-admin] --> AB
AB --> BE[tradeit-backend]
Key Details
- Port: 3000
- Express (not NestJS), Prisma (not TypeORM)
- PM2 cluster mode
- Conditional JSON parsing middleware
- dotenv import ordering matters
Related Pages
ops.tradeit.gg — Internal Engineering Docs