A full‑stack monorepo that streams live crypto price data, performs VMD‑based signal decomposition, and visualises the results with interactive Plotly charts, a 3‑D phase‑space attractor, a spectrogram, and a heat‑map calendar. It also includes alerting, export/share, historical playback, and AI‑generated daily narratives.
- Project Overview
- Prerequisites
- Backend – FastAPI
- Frontend – Next.js (React + TypeScript)
- Running the Whole Stack
- Environment Variables
- Data & Storage
- Testing & Linting
- Known Issues / Gotchas
- License
- Quick Start (one‑liner)
- Live crypto stream –
backend/crypto_stream.pyconnects to Binance WebSocket, buffers price ticks, and yields a NumPy array of the latest 500 samples. - Signal processing –
backend/vmd_nht_processor.pyruns Variational Mode Decomposition (VMD), extracting Intrinsic Mode Functions (IMFs), instantaneous frequency (IF), and amplitude (IA). - FastAPI server –
backend/main.pyexposes:/stream(SSE) – sends Plotly JSON (viz_json) plus LLM‑features./api/alerts/*– CRUD for user alerts (WebSocket push)./api/historical/*,/api/daily_volatility/*,/api/narrative– data & AI endpoints.
- Frontend –
intrinsic-volatility-dashboard/app(Next.js) renders:- Main Plotly chart (
PhaseSpace3D,VolatilityRadar). - Spectrogram (
SpectrogramCanvas). - Heat‑map calendar (
VolatilityCalendar). - Controls: asset selector, playback timeline, AI settings, export/share, alerts.
- Main Plotly chart (
| Tool | Minimum version |
|---|---|
| Python | 3.12+ (tested on 3.13) |
| Node.js | 20.x (LTS) |
| npm | 10.x |
| Git | any recent version |
| Virtual‑env | venv (built‑in) |
| OpenAI API key (optional, for AI narrative) | – |
| Binance public WebSocket – no auth needed | – |
-
Create a virtual environment (run from the repo root):
python -m venv .venv # PowerShell (Windows) .venv\Scripts\Activate.ps1 # Bash (macOS/Linux) source .venv/bin/activate
-
Install dependencies
pip install -r backend/requirements.txt
-
Run the server
uvicorn main:app --reload --port 8000
The server will start on
http://127.0.0.1:8000./streamis the SSE endpoint consumed by the frontend.- Swagger UI is available at
http://127.0.0.1:8000/docs.
-
Database
- SQLite file
vibe_finance.dbis created automatically on first run. - Tables:
market_snapshots,alert_rules,alert_history,daily_summaries.
- SQLite file
-
Install node modules
cd intrinsic-volatility-dashboard npm install -
Start the dev server
npm run dev
The app will be served at
http://localhost:3000. -
Important components
app/components/StreamingDashboard.tsx– core page, connects to/streamviaEventSource.PhaseSpace3D.tsx– Plotly 3‑D scatter (IMF 2/3/4).SpectrogramCanvas.tsx– Canvas‑based heat‑map built from IF/IA data.VolatilityCalendar.tsx– D3 heat‑map of 90‑day volatility.- Utilities:
AlertManager.tsx,ExportButton.tsx,LLMSettings.tsx.
-
Styling
- Tailwind CSS + Shadcn UI utilities are pre‑configured (
tailwind.config.js). - Global glass‑morphism styles live in
app/globals.css.
- Tailwind CSS + Shadcn UI utilities are pre‑configured (
# Terminal 1 – Backend
.venv\Scripts\Activate.ps1 # or source .venv/bin/activate
uvicorn main:app --reload --port 8000
# Terminal 2 – Frontend
cd intrinsic-volatility-dashboard
npm run devOpen http://localhost:3000 in a browser. The dashboard should automatically connect to the SSE stream, display the live price line, the IMF traces, the 3‑D phase‑space, and the spectrogram.
Create a .env file in the repo root (or set variables in your shell). Only the AI endpoint needs a key.
# OpenAI (optional – used by /api/narrative)
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
# FastAPI secret (optional, for future auth)
FASTAPI_SECRET=your-secret-hereThe backend reads these via os.getenv.
- Live price buffer – in‑memory, 500‑sample circular buffer.
- Snapshots – persisted to SQLite every
SNAPSHOT_INTERVALseconds (default 10 s). - Narratives – cached in
daily_summariestable; subsequent calls return the stored text.
The repo includes minimal test scaffolding. To run linting:
# Backend
pip install flake8
flake8 backend
# Frontend
npm run lint # uses eslint + prettier (already configured)Add unit tests under backend/tests/ and intrinsic-volatility-dashboard/__tests__/ as needed.
- Trend line (IMF 1) appearing flat – ensure the VMD processor is receiving enough samples (
len(signal) >= 100). The backend will skip processing until the buffer fills. - Spectrogram/Phase‑Space not rendering – the frontend expects
IFandIAtraces named"IF X"/"IA X"(X = 1‑N). Do not hide them withvisible='legendonly'. - CORS – backend allows
*origins for development; tighten in production. - WebSocket alerts – only work while the backend is running; reconnect logic is in
AlertManager.
This project is provided under the MIT License. See LICENSE for details.
# Backend
python -m venv .venv && .venv\Scripts\Activate.ps1 && pip install -r backend/requirements.txt && uvicorn main:app --reload &
# Frontend (new terminal)
cd intrinsic-volatility-dashboard && npm install && npm run devEnjoy the live intrinsic volatility dashboard!