refactor: pre-M0 cleanup, core library hardening, and isolated dev/QA Docker stack

- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched)
- Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations()
- Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation
- Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims
- Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution
- Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs
This commit is contained in:
Boki 2026-11-27 00:11:50 -05:00
parent ce9e2df67c
commit 4cd6038063
432 changed files with 1247 additions and 44469 deletions

View file

@ -1,25 +1,22 @@
# QA Infrastructure Stack (existing live volumes: stock-bot_mongodb_data, stock-bot_postgres_data, etc.)
# WARNING: Do NOT run `docker compose down -v` against this file — mongodb_data holds the full ingested dataset.
# For isolated local development, use `docker-compose.dev.yml` (ports 5433, 27018, 6380, 9100).
services: # Dragonfly - Redis replacement for caching and events
# Host prerequisite for QuestDB 10.2.0: sysctl vm.max_map_count >= 1048576 (/etc/sysctl.d/99-stockbot.conf)
name: stock-bot
services:
# Dragonfly - Redis replacement for caching and BullMQ queues
dragonfly:
image: docker.dragonflydb.io/dragonflydb/dragonfly:latest
image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.30.3
container_name: trading-bot-dragonfly
mem_limit: 5g
ports:
- '127.0.0.1:6379:6379'
deploy:
resources:
limits:
cpus: '4.0' # Use up to 4 CPU cores
memory: 8G # Use up to 8GB RAM
reservations:
cpus: '2.0' # Reserve at least 2 CPU cores
memory: 4G # Reserve at least 4GB RAM
command:
- dragonfly
- --logtostderr
- --maxmemory=8gb
- --proactor_threads=8
- --maxmemory=4gb
- --proactor_threads=4
- --bind=0.0.0.0
- --admin_port=6380
- --cluster_mode=emulated
@ -39,15 +36,27 @@ services: # Dragonfly - Redis replacement for caching and events
networks:
- trading-bot-network
# PostgreSQL - Operational data (orders, positions, strategies)
# PostgreSQL 16.9 - Security master, trial_ledger, backtests, research & vault state
postgres:
image: postgres:16-alpine
image: postgres:16.9-alpine
container_name: trading-bot-postgres
mem_limit: 10g
shm_size: 2g
environment:
POSTGRES_DB: trading_bot
POSTGRES_USER: trading_user
POSTGRES_PASSWORD: trading_pass_dev
POSTGRES_INITDB_ARGS: '--encoding=UTF-8'
command:
- postgres
- -c
- shared_buffers=4GB
- -c
- effective_cache_size=16GB
- -c
- work_mem=64MB
- -c
- maintenance_work_mem=1GB
ports:
- '127.0.0.1:5432:5432'
volumes:
@ -62,33 +71,51 @@ services: # Dragonfly - Redis replacement for caching and events
networks:
- trading-bot-network
# QuestDB - Time-series data (OHLCV, indicators, performance)
# QuestDB 10.2.0 - Intraday 1m/5m/1h & hot streaming bars (PARTITION BY MONTH)
questdb:
image: questdb/questdb:latest
image: questdb/questdb:10.2.0
container_name: trading-bot-questdb
mem_limit: 28g
ulimits:
nofile:
soft: 1048576
hard: 1048576
ports:
- '127.0.0.1:9000:9000' # Web console
- '127.0.0.1:9000:9000' # Web console & REST
- '127.0.0.1:8812:8812' # PostgreSQL wire protocol
- '127.0.0.1:9009:9009' # InfluxDB line protocol
volumes:
- questdb_data:/var/lib/questdb
environment:
- QDB_TELEMETRY_ENABLED=false
- QDB_RAM_USAGE_LIMIT_BYTES=21474836480
- JAVA_OPTS=-Xms2g -Xmx4g
healthcheck:
test: ['CMD-SHELL', 'curl -fsS http://127.0.0.1:9003/status >/dev/null 2>&1 || exit 1']
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
restart: unless-stopped
networks:
- trading-bot-network
# MongoDB - Document storage (sentiment, raw docs, unstructured data)
# MongoDB 7.0.21 - Raw provider corpus (~638 GB; read-only to data-pipeline)
mongodb:
image: mongo:7-jammy
image: mongo:7.0.21-jammy
container_name: trading-bot-mongodb
mem_limit: 24g
ulimits:
nofile:
soft: 1048576
hard: 1048576
environment:
MONGO_INITDB_ROOT_USERNAME: trading_admin
MONGO_INITDB_ROOT_PASSWORD: trading_mongo_dev
MONGO_INITDB_DATABASE: stock
ports:
- '127.0.0.1:27017:27017'
command: --wiredTigerCacheSizeGB 20
command: --wiredTigerCacheSizeGB ${MONGODB_CACHE_GB:-16}
volumes:
- mongodb_data:/data/db
- ./database/mongodb/init:/docker-entrypoint-initdb.d
@ -99,10 +126,13 @@ services: # Dragonfly - Redis replacement for caching and events
timeout: 10s
retries: 3
networks:
- trading-bot-network # Redis Insight - GUI for Dragonfly debugging
- trading-bot-network
# Redis Insight - GUI for Dragonfly debugging
redis-insight:
image: redislabs/redisinsight:latest
image: redis/redisinsight:2.68
container_name: trading-bot-redis-insight
mem_limit: 512m
ports:
- '127.0.0.1:8001:5540'
depends_on:
@ -113,8 +143,9 @@ services: # Dragonfly - Redis replacement for caching and events
# PgAdmin - PostgreSQL GUI
pgadmin:
image: dpage/pgadmin4:latest
image: dpage/pgadmin4:9.4
container_name: trading-bot-pgadmin
mem_limit: 768m
environment:
PGADMIN_DEFAULT_EMAIL: admin@tradingbot.com
PGADMIN_DEFAULT_PASSWORD: admin123
@ -132,8 +163,9 @@ services: # Dragonfly - Redis replacement for caching and events
# Mongo Express - MongoDB GUI
mongo-express:
image: mongo-express:latest
image: mongo-express:1.0.2-20-alpine3.19
container_name: trading-bot-mongo-express
mem_limit: 512m
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: trading_admin
ME_CONFIG_MONGODB_ADMINPASSWORD: trading_mongo_dev
@ -151,8 +183,9 @@ services: # Dragonfly - Redis replacement for caching and events
# Prometheus - Metrics collection
prometheus:
image: prom/prometheus:latest
image: prom/prometheus:v3.4.0
container_name: trading-bot-prometheus
mem_limit: 1g
ports:
- '127.0.0.1:9090:9090'
volumes:
@ -161,6 +194,7 @@ services: # Dragonfly - Redis replacement for caching and events
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=15d'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
@ -172,6 +206,7 @@ services: # Dragonfly - Redis replacement for caching and events
loki:
image: grafana/loki:2.9.2
container_name: trading-bot-loki
mem_limit: 768m
ports:
- '127.0.0.1:3100:3100'
volumes:
@ -186,10 +221,12 @@ services: # Dragonfly - Redis replacement for caching and events
restart: unless-stopped
networks:
- trading-bot-network
# Grafana - Visualization for logs and metrics
grafana:
image: grafana/grafana:10.2.0
container_name: trading-bot-grafana
mem_limit: 512m
ports:
- '127.0.0.1:3000:3000'
environment:
@ -209,8 +246,9 @@ services: # Dragonfly - Redis replacement for caching and events
# Bull Board - Queue monitoring
bull-board:
image: venatum/bull-board:latest
image: venatum/bull-board:3.3.1
container_name: trading-bot-bull-board
mem_limit: 256m
ports:
- '127.0.0.1:3001:3000'
environment: