
- Set up FastAPI project structure - Configure SQLite database with SQLAlchemy - Create Item model and schemas - Implement CRUD endpoints for inventory items - Set up Alembic for database migrations - Add comprehensive documentation
24 lines
630 B
Python
24 lines
630 B
Python
from pathlib import Path
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
# Project settings
|
|
PROJECT_NAME: str = "Simple Inventory App"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
# CORS settings
|
|
BACKEND_CORS_ORIGINS: list[str] = ["*"]
|
|
|
|
# Database settings
|
|
DB_DIR = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
# Create the DB directory if it doesn't exist
|
|
Settings().DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
# Initialize settings
|
|
settings = Settings() |