kiwi/app/db/session.py
pyr0ball 8cbde774e5 chore: initial commit — kiwi Phase 2 complete
Pantry tracker app with:
- FastAPI backend + Vue 3 SPA frontend
- SQLite via circuitforge-core (migrations 001-005)
- Inventory CRUD, barcode scan, receipt OCR pipeline
- Expiry prediction (deterministic + LLM fallback)
- CF-core tier system integration
- Cloud session support (menagerie)
2026-03-30 22:20:48 -07:00

23 lines
654 B
Python

"""
FastAPI dependency that provides a Store instance per request.
Local mode: opens a Store at settings.DB_PATH.
Cloud mode: opens a Store at the per-user DB path from the CloudUser session.
"""
from __future__ import annotations
from typing import Generator
from fastapi import Depends
from app.cloud_session import CloudUser, get_session
from app.db.store import Store
def get_store(session: CloudUser = Depends(get_session)) -> Generator[Store, None, None]:
"""FastAPI dependency — yields a Store for the current user, closes on completion."""
store = Store(session.db)
try:
yield store
finally:
store.close()