Architecture
System Overview Full system architecture diagram and component inventory
Vezta's backend orchestrates data ingestion from two prediction market exchanges, processes it through multiple pipelines, and delivers it to web and mobile clients via REST and WebSocket APIs.
┌─────────────────┐ ┌─────────────────┐
│ Polymarket API │ │ Kalshi API │
│ (CLOB + Gamma) │ │ (Trade API v2) │
└────────┬────────┘ └────────┬────────┘
│ │
└───────────┬───────────┘
▼
┌─────────────────────┐
│ BullMQ Ingester │
│ (market-sync) │
└──────────┬──────────┘
▼
┌─────────────────────┐
│ NormalizerService │
│ (unified schema) │
└──────────┬──────────┘
▼
┌─────────────────────┐
│ PostgreSQL 17 │◀── Prisma ORM (42+ models)
└──────────┬──────────┘
│
┌──────┴──────┐
▼ ▼
REST API (/api/v1) WebSocket (/ws)
│ │
┌──────┴──────┐ │
▼ ▼ ▼
vezta-fe vezta-mobile
(Next.js 16) (Expo SDK 55)
The backend contains 36+ NestJS modules organized by domain. Each module follows the standard pattern: module.ts, controller.ts, service.ts, dto/, and optionally a processor.ts for BullMQ jobs.
Module Purpose authWallet-based authentication (Solana + EVM), JWT issuance, token refresh waitlistEarly access waitlist with tweet verification and access key generation sub-walletExchange sub-wallet creation and encrypted key management userUser profile management accountAccount settings and preferences kycIdentity verification workflow
Module Purpose marketMarket CRUD, search, chart data, price snapshots tradingOrder submission, SmartRouter, exchange adapters, OrderStateMachine portfolioPosition tracking, PnL snapshots, portfolio analytics merge-splitPolymarket conditional token merge/split operations sniperPrice-triggered sniper orders with monitoring counter-tradeAutomated inverse trading against target wallets arbitrageCross-platform spread detection (Polymarket vs Kalshi)
Module Purpose leaderboardTop trader rankings synced from Polymarket, enrichment pipeline trackerWallet tracking and activity monitoring activityActivity logs and trade feed copy-tradeCopy trade subscriptions and automated execution rewardsPoints ledger, missions, challenges eventsEvents calendar and competitions
Module Purpose ai-predictionsML model predictions with confidence scoring monitorSignal detection, news ingestion pipeline (6 sources) alertsPrice alerts with multi-channel delivery analyticsPlatform-wide analytics and metrics
Module Purpose notificationIn-app and email notifications push-notificationMobile push via Expo Notifications searchFull-text market and event search share-cardShareable PnL card generation calendarMarket resolution date calendar feedAggregated activity feed helpHelp and FAQ content healthHealth check endpoint adminAdmin management endpoints app-versionMobile app version checking
Component Target Trigger Frontend Vercel (auto-deploy on push to main) Git push Backend Docker on Digital Ocean VM (8 GB RAM, 4 vCPU) GitHub Actions self-hosted runner Mobile EAS Build (iOS + Android) GitHub Actions Database PostgreSQL 17 container on backend VM Docker volume Redis Separate container on backend VM Docker network
The backend runs at https://backend.vezta.io behind an Nginx reverse proxy with SSL via Certbot. Host port 4001 maps to container port 3001.
The backend VM is a shared 8 GB machine. Memory-intensive operations like uncapped Kalshi event fetching or running price-change queries every 60 seconds can exhaust available memory. Critical optimizations are in place -- do not remove them.