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.
39
Upvotes
View all comments
Show parent comment
2
u/Designer_Sundae_7405 Oct 30 '25
Thanks and yes, there’s definitely a lot of ways to go about this.
For mapping between client facing and data models, you would not just use alias in Pydantic models? And would you say specifically the repository layer on top of ORM models is essential if you have schemas, services and ORM?