Skip to content

feat(api): init FastAPI project with uv, SQLAlchemy async, Alembic, lib/ utilities#6

Merged
gracefullight merged 2 commits intomainfrom
symphony/FIR-6
Mar 21, 2026
Merged

feat(api): init FastAPI project with uv, SQLAlchemy async, Alembic, lib/ utilities#6
gracefullight merged 2 commits intomainfrom
symphony/FIR-6

Conversation

@gracefullight
Copy link
Member

@gracefullight gracefullight commented Mar 21, 2026

Summary

  • Initialize FastAPI backend project (api/) with uv package manager
  • Add core dependencies: FastAPI, SQLAlchemy[asyncio], asyncpg, Alembic, redis, miniopy-async, pyjwt
  • Implement shared lib utilities: database.py, redis.py, storage.py, exceptions.py, pagination.py, auth.py, config.py
  • Configure Alembic for async migrations with SQLAlchemy
  • Add api/AGENTS.md documenting Router→Service→Repository pattern
  • Response envelope: { data, meta, errors } for success, { error: { code, message, details } } for errors
  • Health endpoint at GET /health
  • Fix mypy errors: proper generics in response models, Annotated dependency pattern, miniopy_async type stub

Test plan

  • uv run pytest — health endpoint test passes
  • uv run mypy src/ — no type errors
  • uv run ruff check src/ tests/ — no lint errors
  • ./scripts/harness/validate.sh — all architecture checks pass

🤖 Generated with Claude Code

gracefullight and others added 2 commits March 21, 2026 18:16
…ib/ utilities

Initialize the api/ subdirectory with:
- pyproject.toml with FastAPI, SQLAlchemy[asyncio], asyncpg, alembic, redis,
  miniopy-async, pyjwt, pydantic-settings
- src/main.py with FastAPI app, CORS, lifespan, /health endpoint
- src/lib/config.py — pydantic-settings based configuration
- src/lib/database.py — async SQLAlchemy engine + session factory
- src/lib/redis.py — async Redis client
- src/lib/storage.py — MinIO async client
- src/lib/exceptions.py — AppError hierarchy + exception handlers
- src/lib/pagination.py — response envelope models (PaginatedResponse, SuccessResponse)
- src/lib/auth.py — JWT encode/decode + get_current_user dependency
- Alembic configured for async migrations
- AGENTS.md documenting Router→Service→Repository pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add type: ignore for miniopy_async missing stubs in storage.py
- Use generic T in PaginatedResponse/SuccessResponse data fields
- Use Annotated[..., Depends()] pattern for CurrentUser dependency

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gracefullight gracefullight merged commit ace29a6 into main Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant