feat: Modern styling, draw.io integration, and C4 architecture docs
Build and Deploy Documentation / build (push) Failing after 8s

Styling:
- Dark-first design (Vercel/Linear inspired) with Geist font
- Custom CSS with full --ifm- token overrides
- Glassmorphic navbar, refined sidebar, modern tables
- Gradient hero with animated glow, app cards, C4 section
- Custom badge, tag, and callout components
- Announcement bar, TOC config, dark scrollbar

draw.io:
- Added docusaurus-plugin-drawio + raw-loader
- SMP full pipeline diagram (smp-pipeline.drawio)
- Embedded in architecture overview

Mermaid:
- Added @docusaurus/theme-mermaid
- C4Context, C4Container, C4Component diagrams
- Sequence and graph diagrams in architecture

C4 Architecture (Stock Market Professional):
- L1 Context: system in the world, actors, external systems
- L2 Containers: Data Ingestor, Analysis Engine, Signal Generator, TimescaleDB, Notifier
- L3 Components: deep component breakdown with mermaid C4Component diagrams

Other:
- Sidebar restructured with C4 section and Modules section
- Homepage rebuilt as modern dark landing page
This commit is contained in:
2026-07-16 20:25:09 +00:00
parent f39c2a1e5f
commit 674ec348ce
14 changed files with 2164 additions and 144 deletions
@@ -0,0 +1,112 @@
---
sidebar_position: 3
---
# L3 — Components
> **C4 Level 3**: Zooms into the key containers and shows their internal modules, classes, and responsibilities.
:::info C4 Model — Level 3
The Component diagram answers: *What are the major structural elements inside each container?*
:::
## Analysis Engine — Component Diagram
```mermaid
C4Component
title Components — Analysis Engine
Container_Ext(tsdb, "Market Data Store", "SQLite / TimescaleDB", "OHLCV candles")
Container_Ext(signalGen, "Signal Generator", "Python", "Consumes indicator snapshots")
Container_Boundary(analyser, "Analysis Engine") {
Component(candleLoader, "Candle Loader", "pandas", "Loads recent OHLCV windows from DB for each symbol and timeframe.")
Component(trendEngine, "Trend Engine", "pandas-ta", "Computes EMA, MACD, ADX, Parabolic SAR.")
Component(momentumEngine, "Momentum Engine", "pandas-ta", "Computes RSI, Stochastic, CCI, Williams %R.")
Component(volatilityEngine, "Volatility Engine", "pandas-ta", "Computes Bollinger Bands, ATR, Keltner Channels.")
Component(volumeEngine, "Volume Engine", "pandas-ta", "Computes VWAP, OBV, Volume Profile.")
Component(patternRecog, "Pattern Recogniser", "ta-lib / custom", "Detects candlestick and chart patterns.")
Component(confluenceScorer, "Confluence Scorer", "Python", "Weights and combines indicator signals into a 0–1 confluence score.")
Component(snapshotWriter, "Snapshot Writer", "pandas / SQLAlchemy", "Persists indicator snapshots to DB for the signal generator.")
}
Rel(candleLoader, tsdb, "Reads OHLCV", "SQL")
Rel(trendEngine, candleLoader, "Reads candle frame")
Rel(momentumEngine, candleLoader, "Reads candle frame")
Rel(volatilityEngine, candleLoader, "Reads candle frame")
Rel(volumeEngine, candleLoader, "Reads candle frame")
Rel(patternRecog, candleLoader, "Reads candle frame")
Rel(confluenceScorer, trendEngine, "Reads signals")
Rel(confluenceScorer, momentumEngine, "Reads signals")
Rel(confluenceScorer, volatilityEngine, "Reads signals")
Rel(confluenceScorer, volumeEngine, "Reads signals")
Rel(confluenceScorer, patternRecog, "Reads patterns")
Rel(snapshotWriter, confluenceScorer, "Reads scored snapshot")
Rel(snapshotWriter, tsdb, "Writes snapshots", "SQL")
Rel(signalGen, snapshotWriter, "Reads snapshots", "SQL")
```
## Signal Generator — Component Diagram
```mermaid
C4Component
title Components — Signal Generator
Container_Ext(tsdb, "Market Data Store", "TimescaleDB", "Indicator snapshots")
Container_Ext(newsApi, "Economic Calendar API", "REST", "High-impact events")
Container_Ext(notifier, "Notifier", "Python", "Receives final signals")
Container_Boundary(signalGen, "Signal Generator") {
Component(snapshotReader, "Snapshot Reader", "SQLAlchemy", "Loads latest indicator snapshots per symbol.")
Component(biasFilter, "Bias Filter", "Python", "Determines directional bias (bullish/bearish/neutral) per pair from higher-TF trend.")
Component(setupScanner, "Setup Scanner", "Python", "Identifies candidate setups where confluence score ≥ 0.65.")
Component(riskCalc, "Risk Calculator", "Python", "Calculates entry, stop-loss, take-profit; validates R:R ≥ 1.5.")
Component(newsFilter, "News Filter", "Python / requests", "Rejects signals within 30 min of high-impact economic events.")
Component(correlFilter, "Correlation Filter", "Python", "Prevents conflicting signals on correlated pairs (e.g. EUR/USD + GBP/USD both long).")
Component(dailyLimitGuard, "Daily Limit Guard", "Python", "Enforces max 3 signals per day hard cap.")
Component(signalAssembler, "Signal Assembler", "Python", "Packages final signals with metadata, reasoning, and time window.")
}
Rel(snapshotReader, tsdb, "Reads snapshots", "SQL")
Rel(biasFilter, snapshotReader, "Reads higher-TF data")
Rel(setupScanner, snapshotReader, "Reads scored snapshots")
Rel(setupScanner, biasFilter, "Applies directional filter")
Rel(riskCalc, setupScanner, "Calculates levels per setup")
Rel(newsFilter, newsApi, "Fetches upcoming events", "REST")
Rel(newsFilter, riskCalc, "Filters out news-window setups")
Rel(correlFilter, newsFilter, "Deduplicates correlated setups")
Rel(dailyLimitGuard, correlFilter, "Enforces ≤3 cap")
Rel(signalAssembler, dailyLimitGuard, "Assembles final signals")
Rel(notifier, signalAssembler, "Receives signals for delivery")
```
## Data Ingestor — Component Breakdown
| Component | Responsibility |
|---|---|
| **Source Router** | Selects primary/fallback data source per symbol |
| **REST Poller** | Fetches 1m candles from REST API on schedule |
| **WS Stream Client** | Maintains WebSocket connection for real-time tick data |
| **Normaliser** | Maps source-specific field names → unified OHLCV schema |
| **Gap Detector** | Identifies missing candles, triggers backfill |
| **Backfiller** | Fetches historical data to fill detected gaps |
| **Rate Limiter** | Tracks and respects per-API-key rate limits |
| **Health Reporter** | Emits data freshness metrics; alerts on stale data |
## Confluence Scoring — Detail
```python
# Scoring weights (sum = 1.0)
WEIGHTS = {
'trend_alignment': 0.30, # EMA cross, MACD, ADX
'momentum': 0.25, # RSI, Stochastic, CCI
'volume': 0.20, # VWAP, OBV
'pattern': 0.15, # Candlestick / chart patterns
'key_level': 0.10, # Support/resistance proximity
}
MINIMUM_CONFLUENCE = 0.65 # Hard threshold
MINIMUM_RR_RATIO = 1.5 # Risk/reward hard floor
MAX_DAILY_SIGNALS = 3 # Hard daily cap
MAX_HOLD_MINUTES = 30 # Hard position time limit
```
@@ -0,0 +1,71 @@
---
sidebar_position: 2
---
# L2 — Containers
> **C4 Level 2**: Zooms into Stock Market Professional and shows its deployable units — services, databases, and schedulers.
:::info C4 Model — Level 2
The Container diagram answers: *What are the high-level technical building blocks, and how do they talk to each other?*
:::
## Container Diagram
```mermaid
C4Container
title Container Diagram — Stock Market Professional
Person(trader, "Trader", "Reviews signals, executes manually")
System_Boundary(smp, "Stock Market Professional") {
Container(ingestor, "Data Ingestor", "Python / APScheduler", "Polls market data APIs on schedule, normalises OHLCV candles, detects gaps.")
Container(analyser, "Analysis Engine", "Python / pandas-ta", "Applies technical indicators and pattern recognition on latest candle data.")
Container(signalGen, "Signal Generator", "Python", "Scores setups by confluence, filters by risk rules, produces ≤3 daily signals.")
Container(scheduler, "Job Scheduler", "APScheduler / cron", "Orchestrates pipeline runs: ingest every minute, analyse every 5 min, generate plan pre-market.")
ContainerDb(tsdb, "Market Data Store", "SQLite / TimescaleDB", "Stores normalised OHLCV candles, indicator snapshots, and signal history.")
Container(notifier, "Notifier", "Python / Discord Webhook", "Formats and delivers the daily trading plan and intraday alerts.")
}
System_Ext(marketData, "Market Data APIs", "Yahoo Finance, Alpha Vantage, Polygon")
System_Ext(discord, "Discord", "Signal delivery")
System_Ext(newsApi, "Economic Calendar API", "Forex Factory, Investing.com")
Rel(scheduler, ingestor, "Triggers", "Internal call")
Rel(scheduler, analyser, "Triggers", "Internal call")
Rel(scheduler, signalGen, "Triggers", "Internal call")
Rel(ingestor, marketData, "Fetches OHLCV", "REST / WS")
Rel(ingestor, tsdb, "Writes candles", "SQL")
Rel(analyser, tsdb, "Reads candles", "SQL")
Rel(analyser, tsdb, "Writes indicator snapshots", "SQL")
Rel(signalGen, tsdb, "Reads snapshots", "SQL")
Rel(signalGen, newsApi, "Checks economic calendar", "REST")
Rel(signalGen, notifier, "Passes signals", "In-process")
Rel(notifier, discord, "Posts daily plan", "Webhook")
Rel(trader, discord, "Reads signals", "Discord UI")
```
## Containers Inventory
| Container | Technology | Responsibility |
|---|---|---|
| **Data Ingestor** | Python, requests, websockets | Poll & normalise market data |
| **Analysis Engine** | Python, pandas, pandas-ta, ta-lib | Technical indicators + pattern recognition |
| **Signal Generator** | Python | Confluence scoring, risk rules, signal assembly |
| **Job Scheduler** | APScheduler | Pipeline orchestration & timing |
| **Market Data Store** | SQLite (dev) / TimescaleDB (prod) | Persist OHLCV, indicators, signals |
| **Notifier** | Python, Discord Webhook | Format and deliver signals |
## Deployment
All containers run as a single **Python process** in development (scheduler + all modules), and can be split into separate Docker containers in production:
```
docker/
├── ingestor/ # Data poller container
├── analyser/ # Analysis worker container
├── signal-gen/ # Signal generation + notifier
└── timescaledb/ # Database container
```
The CI pipeline (Gitea Actions) builds images and pushes to the Zot container registry at `lego-cloud.eu:30264`.
@@ -0,0 +1,50 @@
---
sidebar_position: 1
---
# L1 — System Context
> **C4 Level 1**: Shows how Stock Market Professional fits into the world — who uses it, and what external systems it depends on.
:::info C4 Model — Level 1
The Context diagram answers: *What does this system do, and who / what interacts with it?*
:::
## Context Diagram
```mermaid
C4Context
title System Context — Stock Market Professional
Person(trader, "Trader (Lego)", "Human operator who reviews signals and executes trades manually.")
System(smp, "Stock Market Professional", "Monitors markets, runs technical analysis, and emits daily trading signals.")
System_Ext(marketData, "Market Data Provider", "Real-time & historical price feeds (Yahoo Finance, Alpha Vantage, Polygon.io)")
System_Ext(discord, "Discord", "Signal delivery channel — daily trading plans posted to a server.")
System_Ext(broker, "Broker / Trading Platform", "Where the trader manually executes trades (e.g. Interactive Brokers, MetaTrader).")
System_Ext(newsApi, "Economic Calendar / News API", "High-impact event feed used to filter signals around news releases.")
Rel(trader, smp, "Reviews signals and trading plan")
Rel(smp, marketData, "Fetches OHLCV data", "REST / WebSocket")
Rel(smp, discord, "Posts daily plan & alerts", "Webhook / Bot API")
Rel(smp, newsApi, "Queries upcoming events", "REST API")
Rel(trader, broker, "Executes trades manually", "Web UI / API")
```
## Actors & Systems
| Entity | Type | Role |
|---|---|---|
| Trader (Lego) | Person | Reviews daily signal plan, executes trades manually |
| Market Data Provider | External System | Source of truth for price data |
| Discord | External System | Primary delivery channel for signals |
| Broker / Trading Platform | External System | Where actual trades happen (out of scope) |
| Economic Calendar API | External System | News filter to avoid high-impact event windows |
## Key Constraints
- **No auto-trading** — all order execution is manual
- **Signal limit** — max **3 signals per day** to enforce quality
- **Hold time** — max **30 minutes** per position (scalping / intraday)
- **Manual review** — trader has final say on all entries