first commit
This commit is contained in:
0
backend/app/core/__init__.py
Normal file
0
backend/app/core/__init__.py
Normal file
34
backend/app/core/config.py
Normal file
34
backend/app/core/config.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from pathlib import Path
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
DATABASE_URL: str = "postgresql+asyncpg://fundtracer:fundtracer_dev@localhost:5432/fundtracer"
|
||||
DATABASE_URL_SYNC: str = "postgresql://fundtracer:fundtracer_dev@localhost:5432/fundtracer"
|
||||
REDIS_URL: str = "redis://localhost:6379/0"
|
||||
|
||||
UPLOAD_DIR: str = "./uploads"
|
||||
|
||||
OCR_API_KEY: str = ""
|
||||
OCR_API_URL: str = ""
|
||||
LLM_API_KEY: str = ""
|
||||
LLM_API_URL: str = ""
|
||||
LLM_MODEL: str = ""
|
||||
|
||||
SECRET_KEY: str = "change-me-in-production"
|
||||
DEBUG: bool = True
|
||||
|
||||
@property
|
||||
def upload_path(self) -> Path:
|
||||
p = Path(self.UPLOAD_DIR)
|
||||
p.mkdir(parents=True, exist_ok=True)
|
||||
return p
|
||||
|
||||
|
||||
settings = Settings()
|
||||
23
backend/app/core/database.py
Normal file
23
backend/app/core/database.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
engine = create_async_engine(settings.DATABASE_URL, echo=settings.DEBUG, future=True)
|
||||
async_session_factory = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
async with async_session_factory() as session:
|
||||
try:
|
||||
yield session
|
||||
await session.commit()
|
||||
except Exception:
|
||||
await session.rollback()
|
||||
raise
|
||||
9
backend/app/core/security.py
Normal file
9
backend/app/core/security.py
Normal file
@@ -0,0 +1,9 @@
|
||||
"""Placeholder for authentication & authorization.
|
||||
|
||||
In the competition demo we skip real auth. This module reserves the
|
||||
extension point so RBAC / JWT can be plugged in later.
|
||||
"""
|
||||
|
||||
|
||||
async def get_current_user() -> str:
|
||||
return "demo_user"
|
||||
Reference in New Issue
Block a user