Initial project scaffold: FastAPI backend + Svelte 5 frontend

Backend (uv): FastAPI app with routers (foods, log, targets, OFF proxy),
SQLAlchemy models, Pydantic schemas, migration runner + 0001 initial schema,
example pytest suite (7 tests).
Frontend (npm): Vite 7 + Svelte 5 runes, lib/ (api, stores, scanner, format)
per spec §7, placeholder components, example vitest suite (4 tests).
SPEC.md §1: registered uvicorn and Vitest (rule §8.3.3).
This commit is contained in:
Craig
2026-07-26 10:25:59 +01:00
commit e047d884b6
47 changed files with 3994 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
"""CalCount FastAPI app entry point."""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from database import run_migrations
from routers import foods, log, off, targets
@asynccontextmanager
async def lifespan(app: FastAPI):
# Migrations from day one, applied at startup (spec §8.1 rule 9)
run_migrations()
yield
app = FastAPI(title="CalCount", lifespan=lifespan)
# Vite dev server origin; tighten for production deployment
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"],
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(foods.router)
app.include_router(log.router)
app.include_router(targets.router)
app.include_router(off.router)
@app.get("/api/health")
def health():
return {"status": "ok"}