- docker-compose.yml: timescaledb-ha (timescaledb 2.27 + vectorscale + pgvector + pgai) + backend (FastAPI, CUDA 12.1) + web (Next.js 14) - docker-compose.gpu.yml: GPU profile overlay for RTX 3070 Ti - build.bat: Windows bootstrap, auto-detects nvidia-smi and selects GPU/CPU compose - backend: Dockerfile, pyproject.toml, FastAPI skeleton with /health and /health/db - DB migration 001_init.sql: symbols (with trigram search), ohlcv_daily/1m (hypertables), macro_daily, trading_value_daily, news (vector embedding), predictions (with user_triggered flag for on-demand UX), prediction_outcomes, model_performance - web: Next.js 14 + Tailwind + lightweight-charts placeholder - README: KIS/DART/HuggingFace token issuance guides + 10 seed tickers + run instructions
47 lines
1010 B
Python
47 lines
1010 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.config import settings
|
|
from app.db.connection import ping as db_ping
|
|
|
|
logging.basicConfig(level=settings.log_level)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
app = FastAPI(title="stock_chart_site", version="0.0.1")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
|
|
def _resolved_device() -> str:
|
|
if settings.model_device != "auto":
|
|
return settings.model_device
|
|
try:
|
|
import torch # noqa: WPS433
|
|
return "cuda" if torch.cuda.is_available() else "cpu"
|
|
except Exception: # noqa: BLE001
|
|
return "cpu"
|
|
|
|
|
|
@app.get("/health")
|
|
def health() -> dict[str, object]:
|
|
return {
|
|
"ok": True,
|
|
"device": _resolved_device(),
|
|
"version": "0.0.1",
|
|
}
|
|
|
|
|
|
@app.get("/health/db")
|
|
def health_db() -> dict[str, object]:
|
|
return {"ok": True, **db_ping()}
|