AlphaMind is a full-stack quantitative trading platform: a FastAPI backend serving portfolio, strategy, risk, backtest, market-data, trading, research, and alternative-data APIs, a React web dashboard, and a React Native (Expo) mobile app that share one "Quant Terminal" design language. Alongside the application sits a research library of machine-learning and quantitative modules: forecasting transformers, reinforcement-learning agents, generative models, Bayesian risk, and execution analytics.
- Overview
- Architecture
- Project Structure
- Feature Status
- Technology Stack
- Installation and Setup
- Running the Stack
- API Surface
- Testing
- CI/CD Pipeline
- Documentation
- Contributing
- License
| Topic | Summary |
|---|---|
| Application tier | FastAPI backend plus a web and a mobile client. Fully wired and covered by tests. |
| Research tier | Library of ML and quant modules in code/ai_models and code/backend. Usable on their own, and drawn on by the backend for rl_agent and ml_alpha backtests. |
| Data | Deterministic seeded and synthetic data by default, so the platform runs with no external accounts. Yahoo Finance is used automatically when reachable. |
| Trading | Simulated in-process. There is no live broker connection. |
flowchart TD
web["web-frontend (React, TypeScript)"] -->|"HTTP/JSON"| api
mobile["mobile-frontend (React Native, Expo)"] -->|"HTTP/JSON"| api
api["FastAPI routers: /api/v1/* and /api/auth"] --> services["Services: portfolio, strategy, risk, market data, trading, backtest_runner"]
services --> db[("SQLAlchemy and Alembic: SQLite, MySQL, PostgreSQL")]
services --> feed["Market data: Yahoo Finance, Polygon, synthetic fallback"]
services -->|"rl_agent and ml_alpha backtests"| ai["ai_models: agents, environments, forecasting"]
AlphaMind is organized in tiers rather than a sprawl of microservices. The frontends own presentation and the backend owns the data contracts. A contract test suite pins every response field the clients read, so the tiers cannot drift apart silently. See docs/architecture.md for detail.
| Path | Purpose |
|---|---|
code/backend |
FastAPI service: routers and services, database layer, auth, market data, research modules, migrations, and tests |
code/ai_models |
Research ML library: agents, environments, forecasting, generative models, research studies, examples, and tests |
web-frontend |
React, TypeScript, and Vite dashboard |
mobile-frontend |
React Native (Expo) app |
infrastructure |
Docker, Kubernetes, Terraform, and Ansible configuration |
scripts |
Build, test, deploy, and development helper scripts |
docs |
Project documentation |
.github |
CI/CD workflow and its documentation |
| Component | Details |
|---|---|
| API | FastAPI endpoints under /api/v1 for portfolio, strategies, risk, backtest, market data, trading, research, and alternative data, plus authentication under /api/auth and health checks. |
| Auth | bcrypt password hashing and HS256 JSON Web Tokens with expiry. The signing key comes from SECRET_KEY, and in production or staging the app refuses to start if it is unset, the placeholder, or under 32 characters. |
| Market data | A live connector waterfall (Yahoo Finance, then an optional Polygon connector) backed by a deterministic synthetic fallback, so quotes and history are always available. |
| Data layer | SQLAlchemy over SQLite in development (alphamind.db), with async MySQL and PostgreSQL drivers for other environments and Alembic managing migrations. |
| Web dashboard | React app covering Home, Dashboard, Strategies, Portfolio, Backtest, Risk, Market Data, Trading, Research, Alternative Data, Documentation, About, Settings, and sign in and sign up screens. |
| Mobile app | React Native (Expo) app covering the same functional areas through bottom-tab and stacked navigation, Redux Toolkit state, and a light and dark theme. Alternative data appears inside the Research screen. |
| Graceful degradation | If the backend is unreachable, both clients fall back to a local demo session for account creation and sign in, and data screens show empty or placeholder states instead of failing. |
POST /api/v1/backtest/ trains and evaluates real models for rl_agent and ml_alpha strategies through code/backend/app/services/backtest_runner.py. See docs/BACKTEST_RESULTS.md. The other modules can be imported and run on their own.
| Component | Details | Live API |
|---|---|---|
| Forecasting | Transformer, attention, and multi-horizon model implementations (PyTorch and TensorFlow). | Wired: ml_alpha backtests |
| Reinforcement learning | DDPG and PPO agents with replay buffers, plus custom trading and portfolio Gym environments. | Wired: rl_agent backtests |
| Generative models | GAN components for synthetic series, and a regime model. | Library |
| Risk | Bayesian Value at Risk (PyMC), stress testing, counterparty, and aggregation modules. | Library |
| Execution | Liquidity forecasting, market impact, order management, and routing modules. | Library |
| Area | Technology |
|---|---|
| Backend API | Python 3.10+, FastAPI, Uvicorn, Pydantic v2 |
| Auth | bcrypt, PyJWT and python-jose, passlib |
| Data layer | SQLAlchemy 2, Alembic, SQLite (dev), MySQL and PostgreSQL (async drivers), Redis |
| ML and quant | PyTorch, TensorFlow, scikit-learn, Gymnasium, Stable-Baselines3, PyMC, QuantLib, NumPy, pandas, Dask |
| Market data | yfinance (Yahoo Finance), optional Polygon connector |
| Web frontend | React 19, TypeScript, Vite 7, Tailwind CSS, React Router, TanStack Query, axios, Recharts |
| Mobile frontend | React Native, Expo, React Navigation, Redux Toolkit, React Native Paper, axios |
| Infrastructure | Docker, Docker Compose, Kubernetes, Terraform, Ansible |
| CI/CD | GitHub Actions |
| Testing | pytest (backend and AI models), Vitest (web), Jest (mobile) |
Prerequisites: Python 3.10+ and Node.js 20+ (the web frontend uses Vite 7, which needs Node 20.19 or newer). Docker is optional.
git clone https://github.com/quantsingularity/AlphaMind.git
cd AlphaMind
# Backend
cd code/backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Web frontend
cd ../../web-frontend
npm install
# Mobile frontend
cd ../mobile-frontend
npm installThe backend requirements include PyTorch and TensorFlow, so the first install is large. Full, environment-specific instructions are in docs/INSTALLATION.md.
# 1) Backend (from code/backend, venv active)
python -m main # serves http://0.0.0.0:8000, docs at /docs
# 2) Web dashboard (from web-frontend)
npm run dev # http://localhost:3000, proxies /api to :8000
# 3) Mobile app (from mobile-frontend)
npm start # press w for web, a for Android, i for iOSThe web dashboard proxies API calls to port 8000. The mobile app resolves the API base URL automatically: on web it uses the host the app was opened from (so a LAN address reaches a backend on the same machine), on the Android emulator it uses 10.0.2.2:8000, and otherwise localhost:8000. Override it with EXPO_PUBLIC_API_BASE_URL.
For a fuller local environment, a Compose file in code/backend starts the API together with PostgreSQL, Redis, and Kafka:
cd code/backend
docker compose up --buildSee docs/USAGE.md and docs/CONFIGURATION.md.
Base URL http://localhost:8000. Interactive docs are at /docs (Swagger) and /redoc.
| Group | Prefix | Endpoints |
|---|---|---|
| Health | /health, / |
Liveness check |
| Auth | /api/auth |
register, login, logout, refresh, profile |
| Portfolio | /api/v1/portfolio |
Summary, holdings, performance, positions, positions/{id}, positions/{id}/close |
| Strategies | /api/v1/strategies |
List, create, detail, update, delete, {id}/activate, {id}/deactivate, backtest, backtests/{id}, {id}/backtests, {id}/performance, {id}/equity-curve |
| Risk | /api/v1/risk |
metrics, stress-scenarios, correlation-matrix, radar |
| Backtest | /api/v1/backtest |
Run a backtest (POST), list results for {strategy_id} |
| Market data | /api/v1/market-data |
quotes, batch-quotes, quote/{ticker}, history/{ticker}, historical/{ticker} |
| Trading | /api/v1/trading |
orders (GET, POST), orders/{id} (GET, DELETE) |
| Research | /api/v1/research |
papers, papers/{id} |
| Alternative data | /api/v1/alternative-data |
sources, sources/{id} |
Unversioned aliases such as /api/portfolio exist for every group except trading. Full request and response shapes are in docs/API.md.
| Suite | Directory | Run locally |
|---|---|---|
| Backend | code/backend |
pytest |
| AI models | code/ai_models |
PYTHONPATH=.. pytest tests/ |
| Web | web-frontend |
npm test -- --run |
| Mobile | mobile-frontend |
npm test |
Run each command from the directory shown. All four suites run in CI, and the backend job also re-runs the contract, security, and market-data tests as a separate step. Some tests are skipped when an optional library (TensorFlow or Stable-Baselines3) is not installed. See CI/CD Pipeline.
GitHub Actions (.github/workflows/cicd.yml) runs on pushes and pull requests to main and develop, and on manual dispatch. Every job after the first depends on Code Quality Checks, so the other seven run in parallel once formatting passes.
| # | Job | Depends on | What it does |
|---|---|---|---|
| 1 | Code Quality Checks | None | autoflake and black --check on Python, plus a repository-wide Prettier check (JS, TS, JSON, HTML, CSS, Markdown, Solidity, YAML) |
| 2 | Backend Test & Build | Code Quality Checks | Runs pytest with coverage, re-runs the frontend and backend contract tests, builds the backend Docker image, and uploads the image |
| 3 | AI Models Test & Validation | Code Quality Checks | Byte-compiles ai_models, verifies every sub-package imports, and runs the AI model tests (GPU and integration tests excluded) with coverage |
| 4 | Web-Frontend Test & Build | Code Quality Checks | npm ci, the Vitest suite, the production Vite build, and a bundle upload |
| 5 | Mobile-Frontend Test & Build | Code Quality Checks | npm ci, the Jest suite with coverage, the Expo web export, and a bundle upload |
| 6 | Docs Validation | Code Quality Checks | markdownlint, offline link and anchor checks, syntax checks for code samples, docs and scripts consistency checks, and an advisory external link check |
| 7 | Infrastructure Validation | Code Quality Checks | Terraform, Kubernetes (base and all overlays), and Ansible validation, plus yamllint, Docker Compose and Dockerfile checks, a frontend image build, and a secret scan |
| 8 | Scripts Validation | Code Quality Checks | ShellCheck, syntax, shebang, and executable-bit checks on every shell script, plus a --help smoke test for the CLI scripts |
Coverage reports are kept for 30 days and build artifacts for 7 days. The step-by-step breakdown of each job is in .github/readme/README.md.
| Document | Contents |
|---|---|
| docs/README.md | Documentation index |
| docs/architecture.md | System architecture |
| docs/API.md | REST API reference |
| docs/INSTALLATION.md | Setup for all components |
| docs/CONFIGURATION.md | Environment variables and config |
| docs/USAGE.md | Running and using the platform |
| docs/CLI.md | Helper scripts reference |
| docs/FEATURE_MATRIX.md | Feature status, implemented vs planned |
| docs/BACKTEST_RESULTS.md | How backtests work and how to read them |
| docs/troubleshooting.md | Common issues and fixes |
| docs/CONTRIBUTING.md | Contribution guide |
| docs/examples/api_usage.md | Example: calling the API from the shell and Python |
| docs/examples/ddpg_trading.md | Example: the DDPG agent and trading environment |
| docs/examples/sentiment_analysis.md | Example: the alternative-data surface |
See docs/CONTRIBUTING.md.
This project is licensed under the MIT License. See the LICENSE file for details.
