feat: T03 backend core – FastAPI + DB models + Equipment API + Redis cache + health + tests

- FastAPI app with CORS, lifespan handlers
- Pydantic Settings config (DB, Redis, CORS, SMTP, JWT, Rentman)
- SQLAlchemy async engine + session (DeclarativeBase)
- 6 DB models: EquipmentCache, RentalRequest, RentalRequestItem, Contact, AdminUser, SyncLog
- Pydantic schemas: EquipmentItem, EquipmentDetail, PaginatedEquipment, ContactCreate, ContactResponse
- Redis cache helper: set/get/delete_pattern, rate limiting, equipment key builders
- Equipment router: list (search/category/sort/pagination), detail, categories – all cached
- Contact router: POST with Pydantic validation + rate limiting (5/min)
- Health router: GET /api/health with DB + Redis status
- 28 pytest tests (all pass, 90% coverage)
- Dockerfile, requirements.txt, pytest.ini, test_report.md
This commit is contained in:
A0 Implementation Engineer
2026-07-09 01:26:45 +02:00
parent 3bfa54b4b3
commit e62ece1c06
29 changed files with 1251 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
"""Application configuration via Pydantic Settings."""
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Settings loaded from environment variables."""
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
# Database
DATABASE_URL: str = "postgresql+asyncpg://hms:hms@localhost:5432/hms"
# Redis
REDIS_URL: str = "redis://localhost:6379/0"
# CORS
CORS_ORIGINS: str = "https://hms.media-on.de,http://localhost:3000"
# Rentman
RENTMAN_API_TOKEN: str = ""
# Auth
JWT_SECRET: str = "dev-secret-change-me"
# SMTP
SMTP_HOST: str = ""
SMTP_PORT: int = 587
SMTP_USER: str = ""
SMTP_PASSWORD: str = ""
SMTP_FROM: str = "info@hms-licht-ton.de"
# Admin
ADMIN_USERNAME: str = "admin"
ADMIN_PASSWORD: str = "change_me"
@property
def cors_origins_list(self) -> list[str]:
"""Parse CORS_ORIGINS into a list."""
return [origin.strip() for origin in self.CORS_ORIGINS.split(",") if origin.strip()]
settings = Settings()