FastAPI backend for personal health and skincare data with MCP export. Includes SQLModel models for products, inventory, medications, lab results, routines, and skin condition snapshots. Pytest suite with 111 tests running on SQLite in-memory (no PostgreSQL required). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
965 B
Python
34 lines
965 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from db import create_db_and_tables
|
|
from innercontext.api import health, inventory, products, routines, skincare
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
create_db_and_tables()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="innercontext API", lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(products.router, prefix="/products", tags=["products"])
|
|
app.include_router(inventory.router, prefix="/inventory", tags=["inventory"])
|
|
app.include_router(health.router, prefix="/health", tags=["health"])
|
|
app.include_router(routines.router, prefix="/routines", tags=["routines"])
|
|
app.include_router(skincare.router, prefix="/skin-snapshots", tags=["skincare"])
|
|
|
|
|
|
@app.get("/health-check")
|
|
def health_check():
|
|
return {"status": "ok"}
|