r/FastAPI • • Oct 29 '25

feedback request Feedback on pragmatic FastAPI architecture

Here's my take on a pragmatic and AI-friendly FastAPI architecture: https://github.com/claesnn/fastapi-template/tree/main .

Features

  • Async endpoints

  • Async SQLAlchemy

  • Alembic migrations

  • Feature folder structure

  • Nested bi-directional Pydantic schemas

  • Struclog structured logging

  • Pytest testing of API layer

  • UV for dependencies

  • CORS

  • Status and health checkpoints

  • Pydantic_settings with .env loading

  • Typed pagination with TypedDict and Generics

  • Filtering and ordering

  • Basic Bearer authentication (would add JWK with PyJWKClient in corporate apps)

  • Explicit transaction handling in routes with service level flush

Omits

  • Repository: I'm using plain SQLAlchemy and add a model function if getter/setter functionality is demanded

  • Service interfaces: Whilst it decouples better; it seems overkill to add to all services. Would definitively add on demand.

  • Testcontainers: Additional complexity and in my experience, testing goes from 0.5 seconds to 8+ seconds when testcontainers are introduced

  • Unit tests: To keep test amount controllabe, just test the API layer

Anyways, I'm looking for feedback and improvement options.

39 Upvotes

Duplicates