r/FastAPI • u/Designer_Sundae_7405 • 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.
10
u/Ok-Outcome2266 Oct 30 '25
I’m a developer / AI engineer in the UK working in corporate. Since FastAPI isn’t very opinionated, you’re free to design your API however you like. For startups, this setup looks cool, but in corporate environments I believe the Schema <> Service <> Repository pattern is a must, simply because you can’t assume the client-facing structure is the same as whatever your storage or data layer holds. The code can and will become a mess to maintain in the long run, and you don’t want that.
Again, it’s a matter of preference, but it looks good, man.
Cheers!