VeztaVezta
Architecture

System Overview

Full system architecture diagram and component inventory

Vezta's backend orchestrates data ingestion from two prediction market exchanges plus crypto price feeds, runs multiple intelligence pipelines, and delivers data to the web frontend via REST and WebSocket APIs.

Data Flow

Backend Module Inventory

The backend contains 40+ NestJS modules organized by domain. Each module follows the standard pattern: module.ts, controller.ts, service.ts, dto/, and optionally processor.ts for BullMQ jobs.

Auth and Users

ModulePurpose
authWallet-based authentication (Solana + EVM), Google OAuth, JWT issuance, token refresh
waitlistEarly access waitlist with tweet verification and access-key generation
sub-walletPer-user EOA + Polygon Safe (CREATE2) management, encrypted key storage
userUser profile management
accountAccount settings, deposits, withdrawals (LI.FI for cross-chain)
kycIdentity verification including DFlow Proof flow

Core Trading

ModulePurpose
marketMarket CRUD, search, chart data (OHLC via date_bin), price snapshots
tradingOrder submission, SmartRouter, exchange adapters, OrderStateMachine, circuit breaker, idempotency
paper-tradingVirtual-balance trading mode for newcomers
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)
comboPolymarket CLOB combo / RFQ multi-leg orders (parlay-style baskets) — EIP-712 signing, RFQ gateway, settlement reconciliation
admin-walletAdmin operational wallets

Social and Engagement

ModulePurpose
leaderboardTop trader rankings synced from Polymarket (10 categories × 4 periods), enrichment pipeline
trackerWallet tracking and activity monitoring
wallet-list / wallet-profilePre-loaded wallet lists (whales, KOLs, insiders) and profile pages
activityActivity logs and trade feed
copy-tradeCopy trade subscriptions and automated execution
rewardsPoints ledger, missions, challenges, fee tiers
eventsEvents calendar and competitions
feedAggregated activity feed

Intelligence

ModulePurpose
ai-predictionsLLM-backed predictions via OpenRouter (heuristic fallback)
monitorNews signal detection and ingestion (~6 connectors)
monitor/ingestion/Sub-module: classifier, dedup, market linker, geo, broadcast
insider-signals11-layer bot filter + 10-metric scorer + tiered Telegram/push fanout
alertsPrice alerts with multi-channel delivery
analyticsPlatform-wide analytics and metrics

AI Agent and Research

ModulePurpose
agentIn-app conversational AI assistant. SSE token streaming (DeepSeek via an OpenAI-compatible API), an MCP-shaped tool layer + market_intel skill, prompt-injection / funds-leaving safety guards, web search, and rich result cards. Runs on the ai worker domain (agent-request / agent-resume / agent-summarize queues) when FF_AGENT_QUEUE_SPLIT=true, else in-process on the API container
researchLong-form structured market-research pipeline backing the agent (research-request queue, ai domain)

Sports

ModulePurpose
sports-statsESPN sports-stats ingestion — live scores, standings, win-probability, and fixture resolution for sports markets (sports worker domain)
sports-alertsPrematch reminders and sports-market alerting (prematch-reminder queue)

Platform

ModulePurpose
notificationIn-app and email notifications
push-notificationMobile push via Expo Notifications
telegram-botgrammY-based outbound (signal dispatch) and interactive (trading) Telegram bots
dflowDFlow proxy controller (/api/v1/dflow/*) for Solana-side Kalshi trading
searchFull-text market and event search
share-cardShareable PnL card generation (satori + resvg + sharp)
calendarMarket resolution date calendar
helpHelp and FAQ content
healthHealth check endpoint
adminAdmin management endpoints
app-versionMobile app version checking

Deployment Topology

EnvironmentFrontendBackend API
ProductionDocker (vezta-fe) → vezta.io / www.vezta.io (host 3005 → container 3000)backend.vezta.io (host 4001 → container 3001)
StagingDocker (vezta-fe-staging) → dev.vezta.io (host 3002 → container 3000)staging.vezta.io (host 4002 → container 3001)

Both environments deploy from ghcr.io/morcalabs/vezta-be-api and ghcr.io/morcalabs/vezta-fe via Docker Compose on self-hosted VMs. Backend production deploys use a promoted-image model — staging builds and tags sha-<sha>, production workflow_dispatch takes that image ref as input (no rebuild). Frontend follows the same pattern. Rollback by re-running the deploy workflow with an older image ref.

Container topology

Each backend VM runs 9 application containers (1 API + 8 specialized workers) sharing the same ghcr.io/<owner>/vezta-be-api image, plus supporting redis, loki, promtail, and grafana containers:

ContainerRoleMemory / CPULiveness
vezta-production-apiHTTP API + Socket.IO gateway1.5 GB / 1.5 CPUport 3001
vezta-production-worker-tradersOrder execution, confirmations, fee collection, copy-trade, sniper, counter-trade, insider-signals2.5 GB / 2.0 CPUport 3002
vezta-production-worker-marketmarket-sync, trade-sync, short-duration, catalog-sync, holders/orderbook sync, chart backfill2.0 GB / 1.5 CPUport 3003
vezta-production-worker-miscnotifications, rewards, share-card, leaderboard, alerts, calendar, spread-scanner2.0 GB / 1.0 CPUport 3004
vezta-production-worker-aiAgent chat + research (agent-request / agent-resume / agent-summarize / research-request)2.0 GB / 1.0 CPUport 3006
vezta-production-worker-websocketPolymarket CLOB WS, Kalshi WS, Sports WS, User WS1.0 GB / 1.5 CPUport 3005
vezta-production-worker-rtdsPolymarket RTDS (Chainlink crypto prices for BTC/ETH/SOL/XRP)384 MB / 0.25 CPUport 3007
vezta-production-worker-sportsESPN sports-stats (scores, standings, win-probability, prematch/resolve)384 MB / 0.25 CPUport 3008
vezta-production-worker-combosPolymarket CLOB combo / RFQ order catalog + settlement384 MB / 0.25 CPUport 3009

Domain ownership is enforced at the provider level: backgroundOnly([Processor, Scheduler], '<domain>') excludes providers from DI on sibling workers (so BullMQ never registers a competing consumer). WS connectors check shouldRunInDomain('<domain>') inside onModuleInit. Rollback by setting WORKER_DOMAIN=all on a single fallback worker.

Network and security

  • GCP VPC firewall: only ports 22 / 80 / 443 open to the internet.
  • Nginx reverse proxy with SSL via Certbot, rate limits (api_general 30r/s, api_auth 5r/s burst 10), CORS map (map $http_origin $cors_origin), 30 conn/IP, 10s body/header timeouts, 2MB body max.
  • Polymarket CLOB proxy — a dedicated vezta-proxy VM runs Tinyproxy (port 8888) to route CLOB API traffic past geo-restrictions. The proxy address is supplied to the backend via environment variable, never hardcoded.

The production VM has 15 GiB RAM; staging has 8 GiB. Memory-intensive operations like uncapped event fetching or running price-change queries every 60 seconds can exhaust available memory. Critical optimizations (delta-only writes, deferred price-change queries) are in place — do not remove them.

On this page