前端: 新增 RealTimeQuoteResponse 类型;新增 useRealtimeQuote Hook 并在报告页图表旁展示价格与时间戳(严格 TTL,无兜底)
FastAPI: 新增 GET /financials/{market}/{symbol}/realtime?max_age_seconds=.. 只读端点;通过 DataPersistenceClient 读取 Rust 缓存
Rust: 新增 realtime_quotes hypertable 迁移;新增 POST /api/v1/market-data/quotes 与 GET /api/v1/market-data/quotes/{symbol}?market=..;新增 DTO/Model/DB 函数;修正 #[api] 宏与路径参数;生成 SQLx 离线缓存 (.sqlx) 以支持离线构建
Python: DataPersistenceClient 新增 upsert/get 实时报价,并调整 GET 路径与参数
说明: TradingView 图表是第三方 websocket,不受我们缓存控制;页面数值展示走自有缓存通路,统一且可控。
110 lines
3.1 KiB
YAML
110 lines
3.1 KiB
YAML
version: "3.9"
|
||
|
||
services:
|
||
postgres-db:
|
||
image: timescale/timescaledb:2.15.2-pg16
|
||
container_name: fundamental-postgres
|
||
command: -c shared_preload_libraries=timescaledb
|
||
environment:
|
||
POSTGRES_USER: postgres
|
||
POSTGRES_PASSWORD: postgres
|
||
POSTGRES_DB: fundamental
|
||
volumes:
|
||
- pgdata:/var/lib/postgresql/data
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U postgres -d fundamental"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 10
|
||
ports:
|
||
- "15432:5432"
|
||
|
||
data-persistence-service:
|
||
build:
|
||
context: ./services/data-persistence-service
|
||
dockerfile: Dockerfile
|
||
container_name: data-persistence-service
|
||
environment:
|
||
HOST: 0.0.0.0
|
||
PORT: 3000
|
||
# Rust service connects to the internal DB service name
|
||
DATABASE_URL: postgresql://postgres:postgres@postgres-db:5432/fundamental
|
||
ports:
|
||
- "13000:3000"
|
||
depends_on:
|
||
postgres-db:
|
||
condition: service_healthy
|
||
# If you prefer live-reload or local code mount, consider switching to a dev Dockerfile.
|
||
# volumes:
|
||
# - ./:/workspace
|
||
|
||
backend:
|
||
build:
|
||
context: .
|
||
dockerfile: backend/Dockerfile
|
||
container_name: fundamental-backend
|
||
working_dir: /workspace/backend
|
||
command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
||
environment:
|
||
PYTHONDONTWRITEBYTECODE: "1"
|
||
PYTHONUNBUFFERED: "1"
|
||
# Config service base URL
|
||
CONFIG_SERVICE_BASE_URL: http://config-service:7000/api/v1
|
||
# Data persistence service base URL
|
||
DATA_PERSISTENCE_BASE_URL: http://data-persistence-service:3000/api/v1
|
||
volumes:
|
||
# 挂载整个项目,确保后端代码中对项目根目录的相对路径(如 config/)仍然有效
|
||
- ./:/workspace
|
||
ports:
|
||
- "18000:8000"
|
||
depends_on:
|
||
config-service:
|
||
condition: service_started
|
||
data-persistence-service:
|
||
condition: service_started
|
||
|
||
frontend:
|
||
build:
|
||
context: .
|
||
dockerfile: frontend/Dockerfile
|
||
container_name: fundamental-frontend
|
||
working_dir: /workspace/frontend
|
||
command: npm run dev
|
||
environment:
|
||
# 让 Next 的 API 路由代理到后端容器
|
||
NEXT_PUBLIC_BACKEND_URL: http://backend:8000/api
|
||
# Prisma 直连数据库(与后端共用同一库)
|
||
DATABASE_URL: postgresql://postgres:postgres@postgres-db:5432/fundamental?schema=public
|
||
NODE_ENV: development
|
||
NEXT_TELEMETRY_DISABLED: "1"
|
||
volumes:
|
||
- ./:/workspace
|
||
# 隔离 node_modules,避免与宿主机冲突
|
||
- frontend_node_modules:/workspace/frontend/node_modules
|
||
ports:
|
||
- "13001:3001"
|
||
depends_on:
|
||
- backend
|
||
- postgres-db
|
||
- config-service
|
||
|
||
config-service:
|
||
build:
|
||
context: .
|
||
dockerfile: services/config-service/Dockerfile
|
||
container_name: fundamental-config-service
|
||
working_dir: /workspace/services/config-service
|
||
command: uvicorn app.main:app --host 0.0.0.0 --port 7000
|
||
environment:
|
||
PROJECT_ROOT: /workspace
|
||
volumes:
|
||
- ./:/workspace
|
||
ports:
|
||
- "17000:7000"
|
||
|
||
volumes:
|
||
pgdata:
|
||
frontend_node_modules:
|
||
|
||
|