Initial commit: backend API, data models, and test suite
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>
This commit is contained in:
commit
8f7d893a63
32 changed files with 6282 additions and 0 deletions
21
backend/db.py
Normal file
21
backend/db.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import os
|
||||
|
||||
from sqlmodel import Session, SQLModel, create_engine
|
||||
|
||||
DATABASE_URL = os.environ.get(
|
||||
"DATABASE_URL", "postgresql+psycopg://localhost/innercontext"
|
||||
)
|
||||
connect_args = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {}
|
||||
engine = create_engine(DATABASE_URL, pool_pre_ping=True, connect_args=connect_args)
|
||||
|
||||
|
||||
def get_session():
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
|
||||
def create_db_and_tables():
|
||||
# Import all models so SQLModel.metadata knows about them
|
||||
import innercontext.models # noqa: F401
|
||||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
Loading…
Add table
Add a link
Reference in a new issue