AI-powered global trading & research platform โ real-time markets, copilot intelligence, SEC filings RAG, backtesting, and geopolitical risk monitoring.
Live: https://quanttrade.us
QuantTrade AI is a full-stack financial intelligence platform that combines real-time market data from 12 global exchanges with AI-driven research tools. Think Bloomberg terminal meets AI copilot โ built for traders, analysts, and researchers who want institutional-grade insight without institutional cost.
- Global Markets Dashboard โ Real-time indices, sector heatmaps, and movers across NYSE, NASDAQ, NSE, LSE, TSE, HKEX, SSE, KSC, ASX, SAO, and more
- Ranked Stock Universe โ 800+ curated stocks across 12 exchanges (US: 300 ยท India: 100 ยท UK: 75 ยท Canada: 50 ยท Germany: 50 ยท France: 40 ยท Japan: 50 ยท HK: 40 ยท China: 40 ยท Korea: 20 ยท Australia: 20 ยท Brazil: 15), ranked by market cap + dollar volume + index membership
- Continent Tabs โ Americas / Europe / Asia / Oceania / Africa view with per-exchange breakdown
- Stock Snapshot Modal โ Live price, sparkline chart (Yahoo Finance), 52W high/low, P/E, market cap, avg volume (Finnhub basic-financials)
- Real-time Indices โ World exchange indices with 60s auto-refresh and session % change
- Gainers & Losers โ Live movers from actual quote cache, no fake data
- AI Chat โ Claude/OpenAI-powered assistant with tool calling: live quotes, news, indicators, SEC filings, watchlist
- Symbol Deep Dive โ TradingView-style chart, technical indicators, fundamental panel, news feed
- SEC Filings RAG โ Retrieval-augmented analysis of 10-K, 10-Q, 8-K filings via LangChain + vector store
- Finnhub Panels โ Insider transactions, analyst recommendations, IPO calendar, company news, basic financials
- Ideas Lab โ AI-generated trade ideas with catalyst, risk/reward, entry/exit levels
- Backtesting Engine โ Rule-based strategy simulation with equity curve, drawdown, Sharpe ratio
- Risk Analysis โ VaR, beta, correlation heatmap, portfolio risk scoring
- Watchlist โ Portfolio-aware AI insights, alert conditions, price monitoring
- 12-Layer Intelligence โ Geopolitical events, instability scoring, anomaly detection, geographic clusters, ticker impact correlation
- 3D Globe Visualization โ Interactive Three.js globe with real-time event markers
- AI Threat Classification โ Severity scoring and market impact prediction
- Continent News Feed Grid โ Real-time news by region with sentiment
- 8 Communities โ Wall Street Bets, Stocks, Investing, Options, Crypto, Stock Market, Theta Gang, Value Investing
- Posts โ Text, news, market updates with ticker detection ($AAPL), sentiment badges, image upload, pin/lock
- Comments โ Threaded replies with Wilson score sorting (Best/Top/New/Controversial), @mentions
- Feed Algorithms โ Hot, New, Top (with time windows), Rising (velocity-based)
- AI Moderation โ 3-stage pipeline: AutoMod rules โ Claude analysis โ decision engine (auto-approve/review/remove)
- Sentiment Analysis โ FinBERT scoring on every post, Market Mood aggregate widget
- Full-Text Search โ Posts, comments, communities, users with tabbed results
- Real-Time โ WebSocket notifications, live trending tickers, notification bell
- Moderation Dashboard โ AutoMod rules editor, ban management (temp/permanent), audit log
- Content Ingestion โ NewsAPI + Finnhub + yfinance auto-posting via Celery (every 4 hours)
- Trust Layer โ Financial disclaimers, reputation badges, user verification tiers
- Nightly Training Pipeline โ 804 stocks, 3 horizons (1/7/30 day), manifest-driven sharding, parallel shard execution
- Shard Planner โ Weighted bin-packing: balances shards by estimated runtime, supports dry-run inspection
- AWS Batch Orchestration โ Step Functions state machine, EventBridge scheduler, Spot EC2 (c5.xlarge), per-shard retry
- S3 Artifact Store โ Deterministic paths for checkpoints, metrics, manifests, feature cache, reports
- Neon Metadata Layer โ training_runs, training_shards, training_artifacts, model_versions tables
- Internal Operator API โ 14 endpoints: trigger runs, retry shards, inspect artifacts, shard planning, health checks
- Feature Store โ Offline batch compute + online serving, 20 engineered features, parquet storage, schema versioning
- Experiment Tracking โ Run lifecycle, metric logging, artifact registration, run comparison
- Model Registry โ Version management, stagingโproductionโarchived, rollback, model cards
- Drift Detection โ PSI + KS tests against baseline, per-feature analysis, retrain triggers
- Performance Monitor โ Rolling window evaluation, directional accuracy, confidence calibration, automated alerts
- Prediction Logger โ Every prediction logged with outcomes for production monitoring
- Structured Logging โ JSON logs with run_id, shard_id, symbol, horizon, phase, duration for CloudWatch
- ML Container โ Dedicated training Dockerfile with batch entrypoint, deterministic I/O contract
- MLOps Dashboard โ Production models, experiments, feature store, pipeline control (/mlops)
- WebAuthn/Passkey โ Biometric authentication (Face ID / Touch ID / hardware keys) via
webauthn(PyPI) - JWT Sessions โ RS256 tokens, refresh rotation, secure httpOnly cookie option
- Email OTP + Google OAuth โ Multi-method auth flow
- Subscription Billing โ Stripe integration with plan gating
Complete system design with 8 diagrams: HLD (systems blueprint), LLD (service architecture), ER (database relationships), UML sequences (copilot, ideas lab, auth flows), component diagram (frontend), deployment architecture (AWS + Cloudflare), and background jobs.
flowchart TD
User["End User (Mobile๐ฑ / Desktop๐ป)"]
subgraph ReverseProxy ["Edge & Load Balancing"]
Nginx["Nginx Reverse Proxy\n(SSL, WebAuthn Route, Load Balancing)"]
end
subgraph Frontend ["Frontend Ecosystem (React/Next.js & Godot)"]
UI["Core UI & Animations\n(React, Framer Motion, GSAP)"]
Godot["Godot Engine\n(godot_ashmarket 3D Export)"]
Vis["Financial & 3D Visuals\n(Three.js, globe.gl, lightweight-charts, Remotion)"]
LocalCache["State & Caching\n(TanStack Query, Zustand, LocalStorage)"]
PlatformAPIs["Hardware APIs\n(WebAuthn Passkeys, Web Audio API)"]
NextServer["Server Layer\n(App Router, SSR Data Fetching, BFF)"]
end
subgraph Backend ["Backend Core (FastAPI)"]
API["API Gateway\n(Auth, Game, Billing, Chat)"]
Services["Domain Services\n(WebAuthn, Billing, Storage, OTP)"]
RT["Real-time Broadcaster\n(WebSocket Manager / SSE)"]
Jobs["Task Schedulers\n(APScheduler & Celery Pipelines)"]
end
subgraph ML ["Machine Learning & AI Engine"]
LangChain["LangChain Orchestrator\n(RAG Pipes, Memory)"]
MLModels["Predictive Models\n(XGBoost, LightGBM, scikitlearn, shap)"]
TA["Feature Engineering\n(ta Technical Analysis, Pandas)"]
end
subgraph Storage ["Persistent Storage"]
DB[("Primary DB (Neon PostgreSQL)\nUsers, Passkeys, Game State\npgvector (Embeddings Index)")]
end
subgraph CacheLayer ["Caching & Queue"]
Cache[("Redis / Upstash\nOTP TTL, Rate Limits, Quote Snapshots, Task Queue")]
end
subgraph External ["Cloud & AI External Services"]
S3["AWS S3 / MinIO (Object Storage)"]
LLMs["LLM Providers (OpenAI, Anthropic Claude)"]
MediaAI["Media AI APIs (Fal.ai, ElevenLabs TTS)"]
MarketData["Market Data & Scrapers (Finviz lxml, Finnhub, FMP)"]
AuthBilling["Identity & Payments (Stripe Webhooks, Google OAuth)"]
end
%% Interactions
User <-->|biometrics & audio| PlatformAPIs
PlatformAPIs <-->|inject state| UI
LocalCache <-->|cache sync| UI
Godot -->|export models/textures| Vis
UI <-->|render canvas| Vis
UI -->|navigation / SSR| NextServer
NextServer -->|REST request| Nginx
UI <-->|REST + JWT| Nginx
UI <-->|Live WebSockets| Nginx
Nginx <-->|Forward Traffic| API
Nginx <-->|Forward WSS| RT
API -->|business logic| Services
API -->|push stream| RT
Services <-->|ACID read/write| DB
Services <-->|Rate limit / throttle| Cache
Services <-->|AI context| LangChain
LangChain <-->|semantic search| DB
LangChain -->|inference| LLMs
Services -->|scoring| MLModels
MLModels <-->|compute features| TA
Services <-->|Upload/Download| S3
Services -->|GenAI Assets| MediaAI
Services <-->|Verify Hooks & OAuth| AuthBilling
Services -->|Enqueue async| Jobs
Jobs <-->|Batch writes| DB
Jobs -->|Web parsing / polling| MarketData
classDef frontend fill:#1e40af,stroke:#60a5fa,color:#fff
classDef backend fill:#065f46,stroke:#34d399,color:#fff
classDef storage fill:#854d0e,stroke:#facc15,color:#fff
classDef cache fill:#5b21b6,stroke:#a78bfa,color:#fff
classDef external fill:#374151,stroke:#9ca3af,color:#fff
classDef proxy fill:#0f766e,stroke:#5eead4,color:#fff
classDef ml fill:#86198f,stroke:#f0abfc,color:#fff
class UI,Vis,LocalCache,PlatformAPIs,NextServer,Godot frontend
class API,Services,RT,Jobs backend
class DB storage
class Cache cache
class S3,LLMs,MediaAI,MarketData,AuthBilling external
class Nginx proxy
class LangChain,MLModels,TA ml
flowchart LR
subgraph API ["API Layer (FastAPI Routers)"]
direction TB
AuthAPI["auth.py"]
CopilotAPI["copilot_stream.py"]
IdeasAPI["ideas.py"]
MarketAPI["market.py"]
MonitorAPI["global_monitor.py"]
GameAPI["game.py"]
BillingAPI["billing.py"]
WSAPI["ws.py"]
BacktestAPI["backtest.py"]
ModelIndexAPI["model_index.py"]
end
subgraph Services ["Service Layer"]
direction TB
subgraph DataFetch ["Data Fetchers"]
FMP["fmp_client"]
Finnhub["finnhub_fetcher"]
Finviz["finviz_fetcher"]
YF["yfinance"]
SEC["filings_fetcher"]
GDELTf["global_monitor_fetchers"]
end
subgraph AI ["AI / ML Services"]
LSTM["lstm_prediction_service"]
RAG["rag_service"]
Embed["embedding_service"]
LLM["llm_router"]
TA["technical_analysis_service"]
Conf["confidence_engine"]
CompA["comprehensive_analysis"]
end
subgraph Infra ["Infrastructure"]
Redis["redis_cache_service"]
WS["ws_manager"]
Sched["idea_scheduler"]
Ingest["data_ingestion_service"]
Email["email_service"]
Rate["rate_limiter"]
end
subgraph Business ["Business Logic"]
Bill["billing_service"]
GameSvc["game_service"]
BT["backtest_engine"]
MI["model_index/orchestrator"]
WLAlert["watchlist_alert_service"]
end
end
CopilotAPI --> RAG & LSTM & CompA & LLM & Conf
IdeasAPI --> TA & FMP & Finnhub & YF
MarketAPI --> FMP & Finnhub & YF
MonitorAPI --> GDELTf
GameAPI --> GameSvc
BillingAPI --> Bill
BacktestAPI --> BT
ModelIndexAPI --> MI
WSAPI --> WS
RAG --> Embed
LSTM --> YF
CompA --> FMP & TA & LSTM
Sched --> TA & Ingest & WS
MI --> FMP & TA
classDef api fill:#1e40af,stroke:#60a5fa,color:#fff
classDef svc fill:#065f46,stroke:#34d399,color:#fff
classDef ai fill:#86198f,stroke:#f0abfc,color:#fff
classDef infra fill:#5b21b6,stroke:#a78bfa,color:#fff
classDef biz fill:#854d0e,stroke:#facc15,color:#fff
class AuthAPI,CopilotAPI,IdeasAPI,MarketAPI,MonitorAPI,GameAPI,BillingAPI,WSAPI,BacktestAPI,ModelIndexAPI api
class FMP,Finnhub,Finviz,YF,SEC,GDELTf svc
class LSTM,RAG,Embed,LLM,TA,Conf,CompA ai
class Redis,WS,Sched,Ingest,Email,Rate infra
class Bill,GameSvc,BT,MI,WLAlert biz
erDiagram
users ||--o{ watchlists : has
users ||--o{ portfolios : owns
users ||--o{ conversations : creates
users ||--o| billing_customers : "1:1"
users ||--o| subscriptions : "1:1"
users ||--o| connected_accounts : "1:1"
users ||--o| game_characters : "1:1"
users ||--o{ chat_history : sends
users ||--o| passkey_credentials : registers
symbols ||--o{ price_bars : has
symbols ||--o{ news_articles : about
symbols ||--o{ filings : filed_by
symbols ||--o{ watchlists : tracked_in
portfolios ||--o{ positions : contains
portfolios ||--o{ transactions : records
portfolios ||--o{ portfolio_snapshots : snapshots
positions }o--|| symbols : references
filings ||--o{ filing_chunks : chunked_into
conversations ||--o{ chat_history : contains
game_characters ||--o| game_wallets : "1:1"
game_characters ||--o{ game_missions : assigned
game_characters ||--o{ game_portfolio_holdings : holds
game_characters ||--o{ game_event_logs : logs
game_characters }o--o{ game_community_groups : "joins via game_character_communities"
model_index_snapshots ||--o{ basket_holdings : contains
users {
int id PK
string email UK
string username
string hashed_password
string google_id
bool is_active
datetime created_at
}
symbols {
int id PK
string symbol UK
string name
string exchange
string sector
string industry
float market_cap
}
watchlists {
int id PK
int user_id FK
int symbol_id FK
string source
}
portfolios {
int id PK
int user_id FK
string name
float cash_balance
bool is_paper_trading
}
positions {
int id PK
int portfolio_id FK
int symbol_id FK
float quantity
float avg_cost_basis
float unrealized_pnl
}
transactions {
int id PK
int portfolio_id FK
int symbol_id FK
string transaction_type
float quantity
float price
float realized_pnl
}
conversations {
uuid id PK
int user_id FK
string title
datetime updated_at
}
chat_history {
int id PK
int user_id FK
uuid conversation_id FK
string role
text content
string intent_type
json payload_json
}
filings {
int id PK
int symbol_id FK
string filing_type
string form_type
datetime filing_date
}
filing_chunks {
int id PK
int filing_id FK
int chunk_index
text content
string section
json embedding
}
news_articles {
int id PK
int symbol_id FK
string title
string source
string url
float sentiment
}
game_characters {
int id PK
int user_id FK
string name
string life_stage
int level
int xp
json behavioral_profile
}
game_wallets {
int id PK
int character_id FK
float cash_balance
float net_worth
float total_invested
}
game_missions {
int id PK
int character_id FK
string title
string status
int xp_reward
int gold_reward
}
model_index_snapshots {
int id PK
string index_id
string strategy_type
string regime
json snapshot_data
}
basket_holdings {
int id PK
int snapshot_id FK
string ticker
float weight
float composite_score
json factor_scores
}
global_events {
int id PK
string event_id UK
string source
string category
string threat_level
float latitude
float longitude
float market_impact_score
}
billing_customers {
int user_id PK
string stripe_customer_id
}
subscriptions {
int user_id PK
string stripe_subscription_id
string status
}
sequenceDiagram
actor User
participant FE as Frontend (Next.js)
participant BE as copilot_stream.py
participant SYM as Symbol Resolver
participant CA as comprehensive_analysis
participant LSTM as lstm_prediction_service
participant RAG as rag_service
participant CE as confidence_engine
participant LLM as llm_router (GROQ/OpenRouter)
User->>FE: Type stock question
FE->>BE: POST /api/v1/copilot/stream (SSE)
BE->>SYM: Resolve symbol from query
SYM-->>BE: symbol = "AAPL"
par Parallel data assembly
BE->>CA: build_comprehensive_analysis("AAPL")
CA->>LSTM: predict("AAPL", [1,7,30])
LSTM-->>CA: predictions + confidence
CA-->>BE: structured_data (quote, indicators, regime, risk, prediction)
BE->>RAG: query(message, symbol, top_k=10)
RAG-->>BE: filing_chunks + news context
end
BE->>CE: compute_confidence(structured_data)
CE-->>BE: {overall: 78, grade: "B", components: {...}}
BE-->>FE: SSE event: "intent" (symbol, type)
BE-->>FE: SSE event: "structured_data" (full analysis JSON)
BE->>LLM: stream(system_prompt + context + user_query)
loop Token streaming
LLM-->>BE: token chunk
BE-->>FE: SSE event: "token" (chunk)
end
BE-->>FE: SSE event: "meta" (model, sources, request_id)
BE-->>FE: SSE event: "done"
FE->>User: Rendered analysis + chat response
sequenceDiagram
participant Sched as APScheduler (every 5m)
participant MDS as market_data_service
participant TAS as technical_analysis_service
participant Cache as Redis Cache
participant WS as WebSocket Manager
participant FE as Frontend
Sched->>MDS: get_quotes_batch(64 symbols)
MDS-->>Sched: {AAPL: Quote, MSFT: Quote, ...}
loop For each symbol
Sched->>TAS: compute_signals(symbol)
TAS-->>Sched: RSI, MACD, BB, trend, confidence
end
Sched->>Sched: Score & rank ideas (confidence 0-100)
Sched->>Cache: SET qt:ideas:trending (TTL 300s)
Sched->>Cache: PUBLISH qt:ws:ideas
Cache-->>WS: pub/sub message
WS-->>FE: WebSocket broadcast (ideas_update)
FE->>FE: Re-render Ideas Lab grid
sequenceDiagram
actor User
participant FE as Frontend
participant BE as auth.py
participant DB as Neon PostgreSQL
participant Email as Brevo/Resend
participant Google as Google OAuth
alt Email + Password
User->>FE: Enter email + password
FE->>BE: POST /auth/login
BE->>DB: Verify credentials (bcrypt)
DB-->>BE: User record
BE-->>FE: JWT (7-day, HS256)
else Google OAuth
User->>FE: Click "Sign in with Google"
FE->>Google: OAuth redirect
Google-->>FE: id_token
FE->>BE: POST /auth/google
BE->>DB: Find/create user by google_id
BE-->>FE: JWT
else WebAuthn Passkey
User->>FE: Click "Sign in with Passkey"
FE->>BE: GET /auth/passkey/auth/challenge
BE-->>FE: challenge + allowCredentials
FE->>User: Biometric prompt (Face ID / Touch ID)
User-->>FE: Signed assertion
FE->>BE: POST /auth/passkey/auth/verify
BE->>DB: Verify credential signature
BE-->>FE: JWT
else Email OTP
User->>FE: Request OTP
FE->>BE: POST /auth/otp/send
BE->>Email: Send 6-digit OTP
Email-->>User: OTP email
User->>FE: Enter OTP
FE->>BE: POST /auth/otp/verify
BE-->>FE: JWT
end
flowchart TB
subgraph Public ["Public Pages"]
Home["/"]
About["/about"]
Pricing["/pricing"]
Legal["/legal"]
end
subgraph Auth ["Auth"]
Login["/auth"]
ForgotPW["/auth/forgot-password"]
end
subgraph Core ["Core Trading (Auth Required)"]
Markets["/markets"]
Watchlist["/watchlist"]
Research["/research"]
Copilot["/copilot"]
IdeasLab["/ideas-lab"]
Backtest["/backtest"]
Monitor["/monitor"]
end
subgraph Game ["Game Module"]
GameHub["/game"]
Dashboard["/game/dashboard"]
Character["/game/character"]
Student["/game/student"]
World["/game/world"]
Community["/game/community"]
end
subgraph Settings ["User Settings"]
Profile["/settings/profile"]
Notifications["/settings/notifications"]
BillSuccess["/billing/success"]
end
subgraph APIRoutes ["Next.js API Routes (BFF)"]
QuoteAPI["/api/quotes/*"]
ExchangeAPI["/api/exchange/*"]
AIAnalysis["/api/ai-analysis"]
CopilotProxy["/api/copilot/stream"]
FinnhubProxy["/api/finnhub"]
end
Home --> Login
Login --> Markets
Markets --> Research
Research --> Copilot
Copilot -.->|SSE stream| CopilotProxy
Markets -.->|data| QuoteAPI & ExchangeAPI
IdeasLab -.->|WebSocket| WSAPI["Backend /ws/ideas"]
classDef pub fill:#374151,stroke:#9ca3af,color:#fff
classDef auth fill:#7c2d12,stroke:#fb923c,color:#fff
classDef core fill:#1e40af,stroke:#60a5fa,color:#fff
classDef game fill:#86198f,stroke:#f0abfc,color:#fff
classDef set fill:#065f46,stroke:#34d399,color:#fff
classDef api fill:#854d0e,stroke:#facc15,color:#fff
class Home,About,Pricing,Legal pub
class Login,ForgotPW auth
class Markets,Watchlist,Research,Copilot,IdeasLab,Backtest,Monitor core
class GameHub,Dashboard,Character,Student,World,Community game
class Profile,Notifications,BillSuccess set
class QuoteAPI,ExchangeAPI,AIAnalysis,CopilotProxy,FinnhubProxy api
flowchart TB
User["End User"] --> CF["Cloudflare\n(DNS, CDN, DDoS, Turnstile)"]
CF --> EC2["AWS EC2 Instance"]
subgraph EC2 ["EC2 (us-east-2)"]
Nginx["Nginx\n(SSL, HSTS, microcache)"]
Nginx --> FE["Frontend Container\n(Next.js :3000)"]
Nginx --> BE["Backend Container\n(FastAPI :8000)"]
end
BE --> Neon["Neon PostgreSQL\n(pgvector, serverless)"]
BE --> ElastiCache["AWS ElastiCache\n(Redis 7)"]
BE --> SecretsManager["AWS Secrets Manager"]
BE --> GHCR["GitHub Container Registry\n(Docker images)"]
subgraph CICD ["GitHub Actions CI/CD"]
Push["Push to main"] --> Build["Build Docker images"]
Build --> GHCR
Build --> Deploy["SSH deploy to EC2"]
end
subgraph ExternalAPIs ["External APIs"]
FMPx["FMP"]
Finnhubx["Finnhub"]
YFx["Yahoo Finance"]
Stripex["Stripe"]
Brevox["Brevo"]
GROQx["GROQ"]
OpenRouterx["OpenRouter"]
ElevenLabsx["ElevenLabs"]
end
BE --> ExternalAPIs
classDef cloud fill:#1e40af,stroke:#60a5fa,color:#fff
classDef aws fill:#854d0e,stroke:#facc15,color:#fff
classDef ext fill:#374151,stroke:#9ca3af,color:#fff
class CF,GHCR cloud
class EC2,Neon,ElastiCache,SecretsManager aws
class FMPx,Finnhubx,YFx,Stripex,Brevox,GROQx,OpenRouterx,ElevenLabsx ext
flowchart LR
subgraph APScheduler ["APScheduler (BackgroundScheduler)"]
J1["rescore_ideas\n(every 5m)"]
J2["update_market_pulse\n(every 2m)"]
J3["news_sentiment_check\n(every 10m)"]
J4["market_open_scan\n(9:30 AM ET)"]
J5["ingest_rag_data\n(every 6h)"]
J6["nightly_sync\n(00:30 UTC)"]
J7["weekly_cleanup\n(Sun 03:00)"]
J8["pro_watchlist_alerts\n(every 20m)"]
end
J1 --> MDS["market_data_service"] & TAS["technical_analysis"] & Redis["Redis Cache"] & WSM["WebSocket"]
J2 --> MDS & Redis & WSM
J3 --> Finn["finnhub_fetcher"] & Redis
J4 --> MDS & TAS & Redis
J5 --> Ingest["data_ingestion_service"] & Embed["embedding_service"] & VS["vector_store"]
J6 --> ExchSvc["exchange_universe_service"] & DB["Neon DB"]
J7 --> DB
J8 --> Email["email_service"]
classDef job fill:#86198f,stroke:#f0abfc,color:#fff
classDef svc fill:#065f46,stroke:#34d399,color:#fff
class J1,J2,J3,J4,J5,J6,J7,J8 job
class MDS,TAS,Redis,WSM,Finn,Ingest,Embed,VS,ExchSvc,DB,Email svc
flowchart LR
subgraph Sources ["Data Sources"]
NewsAPI["NewsAPI"]
Finnhub["Finnhub News"]
YF["yfinance"]
Users["User Posts"]
end
subgraph Pipeline ["Processing Pipeline"]
AutoMod["AutoMod Rules\n(Stage 0)"]
AIMod["Claude AI Moderation\n(Stage 1)"]
Sentiment["FinBERT Sentiment\n(Stage 2)"]
HotScore["Hot Score Calculator"]
end
subgraph Storage ["Storage"]
PG["PostgreSQL\n(Posts, Comments, Votes)"]
Redis["Redis Cache\n(Feeds, Trending)"]
end
subgraph Serving ["Serving"]
API["FastAPI REST"]
WS["WebSocket"]
Celery["Celery Workers"]
end
subgraph Frontend ["Frontend"]
Feed["Community Feed"]
PostDetail["Post Detail"]
Trending["Trending Sidebar"]
Mood["Market Mood"]
ModDash["Moderation Dashboard"]
end
Sources --> AutoMod --> AIMod --> Sentiment --> HotScore
HotScore --> PG & Redis
PG --> API --> Frontend
Redis --> API
WS --> Feed & PostDetail
Celery --> Sources
classDef src fill:#1e40af,stroke:#60a5fa,color:#fff
classDef pipe fill:#854d0e,stroke:#facc15,color:#fff
classDef store fill:#065f46,stroke:#34d399,color:#fff
classDef serve fill:#5b21b6,stroke:#a78bfa,color:#fff
classDef fe fill:#0f766e,stroke:#5eead4,color:#fff
class NewsAPI,Finnhub,YF,Users src
class AutoMod,AIMod,Sentiment,HotScore pipe
class PG,Redis store
class API,WS,Celery serve
class Feed,PostDetail,Trending,Mood,ModDash fe
flowchart TD
subgraph Triggers ["Triggers"]
EB["EventBridge\nScheduler\n(03:00 UTC)"]
API["Internal API\n(/internal/ml/*)"]
GHA["GitHub Actions\n(bridge/fallback)"]
end
subgraph Orchestration ["AWS Step Functions"]
Init["Initialize Run\n(Neon: training_runs)"]
Plan["Plan Shards\n(shard_planner.py)"]
Submit["Submit Batch Jobs\n(Map state, parallel)"]
Wait["Wait + Poll"]
Retry["Retry Failed\n(max 2, exit code routing)"]
Agg["Aggregate Results"]
Final["Finalize Run"]
end
subgraph Compute ["AWS Batch (Spot EC2)"]
S1["Shard 1\n(~160 symbols)"]
S2["Shard 2\n(~160 symbols)"]
S3["Shard 3\n(~160 symbols)"]
S4["Shard 4\n(~160 symbols)"]
S5["Shard 5\n(~160 symbols)"]
end
subgraph Container ["ML Training Container"]
Entry["entrypoint.py"]
Feat["precompute_features()\n(20 features, once)"]
Train["train per horizon\n(h=1, h=7, h=30)"]
Ckpt["checkpoint + metrics"]
end
subgraph Storage ["Data Plane"]
S3B[("S3\nquanttrade-ml-artifacts\ncheckpoints / metrics /\nmanifests / feature-cache")]
Neon[("Neon PostgreSQL\ntraining_runs\ntraining_shards\ntraining_artifacts\nmodel_versions")]
CW["CloudWatch\nStructured Logs\nMetrics + Alarms"]
end
subgraph Serving ["Inference"]
FAPI["FastAPI\n(31 MLOps + ML endpoints)"]
Pred["LSTM Prediction\n(3 horizons)"]
Cache["Redis Cache\n(5min TTL)"]
end
EB --> Init
API --> Init
GHA -.->|bridge| Init
Init --> Plan --> Submit
Submit --> S1 & S2 & S3 & S4 & S5
S1 & S2 & S3 & S4 & S5 --> Wait
Wait --> Retry --> Wait
Wait --> Agg --> Final
S1 --> Entry --> Feat --> Train --> Ckpt
Ckpt --> S3B
Ckpt --> Neon
Entry --> CW
S3B --> Pred
Neon --> FAPI
Pred --> Cache --> FAPI
classDef trigger fill:#1e3a5f,stroke:#60a5fa,color:#fff
classDef orch fill:#374151,stroke:#9ca3af,color:#fff
classDef compute fill:#065f46,stroke:#34d399,color:#fff
classDef container fill:#0f766e,stroke:#5eead4,color:#fff
classDef storage fill:#5b21b6,stroke:#a78bfa,color:#fff
classDef serve fill:#991b1b,stroke:#fca5a5,color:#fff
class EB,API,GHA trigger
class Init,Plan,Submit,Wait,Retry,Agg,Final orch
class S1,S2,S3,S4,S5 compute
class Entry,Feat,Train,Ckpt container
class S3B,Neon,CW storage
class FAPI,Pred,Cache serve
flowchart TD
S1["1. Data Fetch\n(yfinance, FMP, Finnhub)"]
S2["2. Feature Computation\n(20 features โ parquet)"]
S3["3. Data Validation\n(OHLCV + feature quality)"]
S4{"4. Drift Detection\n(PSI, KS vs baseline)"}
S5["5. Model Training\n(LSTM per horizon)"]
S6["6. Evaluation\n(DA, IC, Sharpe, RMSE)"]
S7["7. Model Registration\n(version + metadata)"]
S8{"8. Auto-Promote?\n(beats production?)"}
S9["9. Serving\n(FastAPI + Redis cache)"]
S10["10. Monitoring\n(predictions + outcomes)"]
S1 --> S2 --> S3 --> S4
S4 -->|No drift| SKIP["Skip Training\n(model is current)"]
S4 -->|Drift detected| S5
S5 --> S6 --> S7 --> S8
S8 -->|Yes| S9
S8 -->|No| KEEP["Keep Current\n(new model โ staging)"]
S9 --> S10
S10 -.->|"Drift check (6h)"| S4
S10 -.->|"Perf degraded"| S5
classDef step fill:#065f46,stroke:#34d399,color:#fff
classDef decision fill:#854d0e,stroke:#facc15,color:#fff
classDef skip fill:#374151,stroke:#9ca3af,color:#fff
classDef monitor fill:#991b1b,stroke:#fca5a5,color:#fff
class S1,S2,S3,S5,S6,S7,S9 step
class S4,S8 decision
class SKIP,KEEP skip
class S10 monitor
We supply the source code for producing ultra-high fidelity network mapping in doc/system_design.puml and doc/system_design.md.
- To render PlantUML locally: Requires Graphviz to be installed on your target machine. Open
.pumlin any compatible IDE or use the CLI:java -jar plantuml.jar doc/system_design.puml. - To map perfectly in Excalidraw: Open Excalidraw, click the "Insert" toolbar dropdown -> "Mermaid to Excalidraw". Copy and paste the Mermaid block above to generate a 100% mathematically aligned, beautiful, and directly editable DAG node layout.
Key design principles:
- No fake data โ every number comes from a live API or cached DB row
- Aggressive layered caching: in-memory (TTL) โ DB snapshot โ live API fallback
- APScheduler nightly jobs: exchange universe sync (00:30 UTC), weekly cleanup (Sun 03:00 UTC)
- All market data paths have graceful degradation; API failures return structured empty states
| Layer | Technology |
|---|---|
| Frontend | Next.js 16 (App Router), React 18, TypeScript, Tailwind CSS, Framer Motion |
| Charts | TradingView Lightweight Charts, custom Canvas sparklines |
| State | TanStack Query v5, Zustand, WebSocket hooks |
| Backend | Python 3.14, FastAPI, SQLAlchemy 2.0, Pydantic v2 |
| Database | PostgreSQL (Neon serverless), pgvector |
| Cache | Redis (ElastiCache) with in-memory fallback |
| Auth | httpOnly cookies, WebAuthn/FIDO2 passkeys, Google OAuth, JWT |
| AI/LLM | Anthropic Claude, OpenAI, FinBERT (sentiment), LangChain |
| ML/MLOps | PyTorch LSTM, Feature Store, Experiment Tracker, Model Registry, Drift Detection |
| Community | AI moderation (Claude), AutoMod rules, reputation system, WebSocket real-time |
| Market Data | Finnhub, FMP, Yahoo Finance, NewsAPI, SEC EDGAR |
| Billing | Stripe (subscriptions, webhooks) |
| DevOps | Docker, Nginx, EC2, Cloudflare (CDN/WAF), GitHub Actions CI/CD |
| Background | Celery + Redis (Beat scheduler), APScheduler |
QuantTrade-AI/
โโโ backend/
โ โโโ app/
โ โ โโโ api/ # FastAPI routers (60+ endpoints)
โ โ โ โโโ auth.py # JWT + WebAuthn + Google OAuth
โ โ โ โโโ market.py # Indices, movers, sectors
โ โ โ โโโ posts.py # Posts, feeds, voting, trending
โ โ โ โโโ comments.py # Threaded comments, Wilson score
โ โ โ โโโ community.py # Community CRUD, rules, automod
โ โ โ โโโ bookmarks.py # Saved posts
โ โ โ โโโ bans.py # Community ban management
โ โ โ โโโ search.py # Full-text search
โ โ โ โโโ moderation.py # AI moderation queue
โ โ โ โโโ notifications.py # Notifications + preferences
โ โ โ โโโ users.py # Profiles, follow, badges
โ โ โ โโโ uploads.py # Image upload (S3/local)
โ โ โ โโโ mlops.py # MLOps API (17 endpoints)
โ โ โ โโโ ws.py # WebSocket channels
โ โ โ โโโ ...
โ โ โโโ models/
โ โ โ โโโ community.py # 14 community tables
โ โ โ โโโ ml_model.py # ML model registry
โ โ โ โโโ ml_monitoring.py # Feature + prediction stats
โ โ โ โโโ ...
โ โ โโโ services/
โ โ โ โโโ reddit_ingestion_service.py # Reddit content ingestion
โ โ โ โโโ sentiment_service.py # FinBERT financial sentiment
โ โ โ โโโ moderation_service.py # AI content moderation
โ โ โ โโโ automod_service.py # AutoMod rules engine
โ โ โ โโโ reputation_service.py # User reputation scoring
โ โ โ โโโ ...
โ โ โโโ tasks/
โ โ โโโ celery_app.py # Beat schedule (Reddit, news, drift, perf)
โ โ โโโ community_sync.py # Reddit sync + news auto-posting
โ โ โโโ ml_tasks.py # Drift check, perf check, pipeline
โ โโโ ml/ # ML/MLOps core
โ โ โโโ model.py # LSTM with attention (3-layer)
โ โ โโโ dataset.py # 20 features, data pipeline
โ โ โโโ train.py # Training loop, early stopping
โ โ โโโ feature_store.py # Offline/online feature store
โ โ โโโ experiment_tracker.py # Experiment tracking
โ โ โโโ model_registry.py # Model versioning + promotion
โ โ โโโ drift_detector.py # PSI + KS drift detection
โ โ โโโ prediction_logger.py # Production prediction logging
โ โ โโโ performance_monitor.py # Performance alerts
โ โ โโโ pipeline.py # 5-stage ML pipeline orchestrator
โ โ โโโ data_quality.py # Production data validation
โ โ โโโ reproducibility.py # Seed control
โ โโโ scripts/
โ โ โโโ seed_content.py # Seed communities + real news/market data
โ โ โโโ seed_communities.py # Create 8 default communities
โ โโโ requirements.txt
โโโ frontend/
โ โโโ src/
โ โโโ app/
โ โ โโโ community/ # Community platform
โ โ โ โโโ page.tsx # Feed (hot/new/top/rising)
โ โ โ โโโ [slug]/page.tsx # Community detail
โ โ โ โโโ [slug]/settings/page.tsx # Community settings
โ โ โ โโโ post/[id]/page.tsx # Post detail + comments
โ โ โ โโโ discover/page.tsx # Community discovery
โ โ โ โโโ bookmarks/page.tsx # Saved posts
โ โ โ โโโ search/page.tsx # Full-text search
โ โ โ โโโ create/page.tsx # Create community
โ โ โ โโโ moderation/page.tsx # Mod dashboard
โ โ โโโ mlops/page.tsx # MLOps dashboard
โ โ โโโ notifications/page.tsx
โ โ โโโ ...
โ โโโ components/community/ # Community UI components
โ โ โโโ PostCard.tsx # Post with sentiment/pin/lock/bookmark
โ โ โโโ CommentTree.tsx # Threaded comments
โ โ โโโ TrendingSidebar.tsx # Live trending + market mood
โ โ โโโ NotificationBell.tsx # WebSocket real-time bell
โ โ โโโ ...
โ โโโ hooks/
โ โโโ useCommunityWS.ts # WebSocket hook
โโโ docs/
โโโ COMMUNITY_EXECUTION_PLAN.md
โโโ community-data-flow.drawio
โโโ community-database-schema.drawio
โโโ mlops-system-architecture.drawio
โโโ mlops-pipeline-flow.drawio
โโโ ARCHITECTURE_V2.md
- Python 3.11+ (3.14 works locally; use 3.11 for Docker/EC2)
- Node.js 18+
- PostgreSQL (or Neon free tier)
git clone https://github.com/yourusername/QuantTrade-AI.git
cd QuantTrade-AI/backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtcp .env.example .envEdit backend/.env:
# Database
DATABASE_URL=postgresql://user:password@host/dbname
# AI
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
# Market Data
FINNHUB_API_KEY=... # finnhub.io โ free tier (60 calls/min)
FMP_API_KEY=... # financialmodelingprep.com
FINVIZ_API_KEY=... # optional
# Auth
SECRET_KEY=your-secret-key-min-32-chars
WEBAUTHN_RP_ID=localhost # production: quanttrade.us
WEBAUTHN_ORIGIN=http://localhost:3000 # production: https://quanttrade.us
# Billing (optional)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...Edit frontend/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000
FINNHUB_API_KEY=...
FMP_API_KEY=...
NEXT_PUBLIC_FINNHUB_KEY=...cd backend
# Create all tables
python scripts/init_database.py
# Seed 800+ global stocks (US 300 ยท India 100 ยท UK 75 ยท etc.)
python scripts/seed_global_universe.py
# Optional: additional US symbol search index
python scripts/seed_symbols_master.pyuvicorn app.main:app --reload --port 8000cd frontend
npm install
npm run devThe platform maintains a ranked universe of stocks across 12 global exchanges, populated by seed_global_universe.py and refreshed nightly by APScheduler:
| Exchange | Count | Key Index |
|---|---|---|
| ๐บ๐ธ United States | 300 | S&P 500 + NASDAQ 100 |
| ๐ฎ๐ณ India | 100 | NIFTY 50 + NIFTY NEXT 50 |
| ๐ฌ๐ง United Kingdom | 75 | FTSE 100 |
| ๐จ๐ฆ Canada | 50 | TSX 60 |
| ๐ฉ๐ช Germany | 50 | DAX 40 + MDAX |
| ๐ซ๐ท France | 40 | CAC 40 |
| ๐ฏ๐ต Japan | 50 | Nikkei 225 top |
| ๐ญ๐ฐ Hong Kong | 40 | Hang Seng |
| ๐จ๐ณ China | 40 | CSI 300 top |
| ๐ฐ๐ท South Korea | 20 | KOSPI top |
| ๐ฆ๐บ Australia | 20 | ASX 20 |
| ๐ง๐ท Brazil | 15 | IBOVESPA top |
Priority score formula (used for ranking when FMP screener data is available):
score = 0.35 ร norm_market_cap
+ 0.35 ร norm_dollar_volume
+ 0.15 ร index_membership_weight
+ 0.10 ร analyst_coverage
+ 0.05 ร user_interest
| Endpoint | Description |
|---|---|
GET /api/v1/market/universe |
Ranked stock universe by exchange |
GET /api/v1/market/movers |
Real-time gainers + losers |
GET /api/v1/enhanced/quote/{symbol}/finnhub |
Live Finnhub quote |
GET /api/v1/global-monitor/events |
Geopolitical events feed |
| Endpoint | Description |
|---|---|
GET /api/v1/feed |
Personalized feed (hot/new/top/rising) |
GET /api/v1/feed/trending-tickers |
Live trending tickers by mention count |
GET /api/v1/feed/market-mood |
Aggregate sentiment (bullish/bearish/neutral) |
POST /api/v1/posts |
Create post (with AI moderation + sentiment) |
GET /api/v1/posts/{id}/comments?sort=best |
Comments with Wilson score sorting |
POST /api/v1/posts/{id}/vote |
Upvote/downvote |
POST /api/v1/posts/{id}/bookmark |
Save/bookmark post |
GET /api/v1/communities |
List communities |
GET /api/v1/search?q=...&type=posts |
Full-text search |
GET /api/v1/notifications |
User notifications |
| Endpoint | Description |
|---|---|
GET /api/v1/mlops/overview |
Dashboard summary (models, experiments, alerts) |
GET /api/v1/mlops/models |
List registered models |
GET /api/v1/mlops/models/{name}/card |
Model card documentation |
POST /api/v1/mlops/models/{name}/promote |
Promote model to production |
POST /api/v1/mlops/models/{name}/rollback |
Rollback to previous version |
GET /api/v1/mlops/experiments |
List experiment runs |
GET /api/v1/mlops/monitoring/drift/{symbol} |
Drift report for a symbol |
GET /api/v1/mlops/monitoring/performance |
Model performance snapshot |
POST /api/v1/mlops/pipeline/run |
Trigger ML training pipeline |
POST /api/v1/mlops/features/refresh |
Refresh feature store |
Full interactive docs: http://localhost:8000/docs
# Build and start all services
docker-compose up -d
# After first deploy, seed the database
docker-compose exec backend python scripts/seed_global_universe.pyRequired production env vars:
WEBAUTHN_RP_ID=quanttrade.us
WEBAUTHN_ORIGIN=https://quanttrade.us
ALLOWED_ORIGINS=https://quanttrade.us,https://www.quanttrade.us
DATABASE_URL=postgresql://...Home โ Market Intelligence Dashboard

Research โ Deep Dive with Finnhub Panels

Global Markets โ Continent Tabs + Heatmaps

- Architecture v2 โ Community platform architecture (microservices, 3-stage startup plan)
- Architecture v1 โ Original system design deep dive
- System Design & Diagrams โ Complete system design document
- Community Execution Plan โ 6-week build plan with feature breakdown
- Community Data Flow โ Architecture diagram (Reddit ingestion โ AI moderation โ Sentiment โ Feed)
- Community Database Schema โ ER diagram of 14 community tables
- Community Platform Infra โ AWS infrastructure diagram
- MLOps System Architecture โ Full ML lifecycle diagram (HLD)
- MLOps Pipeline Flow โ 10-stage pipeline flow diagram
- Quick Start โ Fast setup and key endpoints
- Global Monitor โ Geopolitical intelligence layer
- Neon Setup โ Serverless PostgreSQL configuration
- Installation Guide โ Full environment setup
MIT โ see LICENSE


