fractafrag/services/api/app/config.py
John Lightner 05d39fdda8 M0: Foundation scaffold — Docker Compose, DB schema, FastAPI app, all service stubs
Track A (Infrastructure & Data Layer):
- docker-compose.yml with all 7 services (nginx, frontend, api, mcp, renderer, worker, postgres, redis)
- docker-compose.override.yml for local dev (hot reload, port exposure)
- PostgreSQL init.sql with full schema (15 tables, pgvector indexes, creator economy stubs)
- .env.example with all required environment variables

Track A+B (API Layer):
- FastAPI app with 10 routers (auth, shaders, feed, votes, generate, desires, users, payments, mcp_keys, health)
- SQLAlchemy ORM models for all 15 tables
- Pydantic schemas for all request/response types
- JWT auth middleware (access + refresh tokens, Redis blocklist)
- Redis rate limiting middleware
- Celery worker config with job stubs (render, embed, generate, feed cache, expire bounties)
- Alembic migration framework

Service stubs:
- MCP server (health endpoint, 501 for all tools)
- Renderer service (Express + Puppeteer scaffold, 501 for /render)
- Frontend (package.json with React/Vite/Three.js/TanStack/Tailwind deps)
- Nginx reverse proxy config (/, /api, /mcp, /renders)

Project:
- DECISIONS.md with 11 recorded architectural decisions
- README.md with architecture overview
- Sample shader seed data (plasma, fractal noise, raymarched sphere)
2026-03-24 20:45:08 -05:00

47 lines
2.2 KiB
Python

"""Fractafrag API — Application configuration."""
from pydantic_settings import BaseSettings
from functools import lru_cache
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# ── Database ──────────────────────────────────────────────
database_url: str = "postgresql+asyncpg://fracta:changeme@postgres:5432/fractafrag"
database_url_sync: str = "postgresql://fracta:changeme@postgres:5432/fractafrag"
# ── Redis ─────────────────────────────────────────────────
redis_url: str = "redis://redis:6379/0"
# ── JWT ───────────────────────────────────────────────────
jwt_secret: str = "changeme"
jwt_algorithm: str = "HS256"
jwt_access_token_expire_minutes: int = 15
jwt_refresh_token_expire_days: int = 30
# ── Cloudflare Turnstile ──────────────────────────────────
turnstile_secret: str = ""
# ── Stripe ────────────────────────────────────────────────
stripe_secret_key: str = ""
stripe_webhook_secret: str = ""
# ── Renderer ──────────────────────────────────────────────
renderer_url: str = "http://renderer:3100"
# ── BYOK Encryption ──────────────────────────────────────
byok_master_key: str = "changeme"
# ── AI Providers ──────────────────────────────────────────
anthropic_api_key: str = ""
openai_api_key: str = ""
class Config:
env_file = ".env"
case_sensitive = False
@lru_cache
def get_settings() -> Settings:
return Settings()