Automated Action b51b13eb3e Create backend scaffold for freelancer invoicing API
- Set up FastAPI application with CORS support
- Configure SQLite database connection
- Create database models for users, clients, invoices, and line items
- Set up Alembic for database migrations
- Implement JWT-based authentication system
- Create basic CRUD endpoints for users, clients, and invoices
- Add PDF generation functionality
- Implement activity logging
- Update README with project information
2025-05-26 18:21:20 +00:00

27 lines
633 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Create storage directory if it doesn't exist
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
"""
Dependency function that yields db sessions.
"""
db = SessionLocal()
try:
yield db
finally:
db.close()