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/PA100T0 Oct 31 '25
If you wanna go beyond Ruff and MyPy, I’d recommend Bandit, Radon/Xenon and Vulture.
Bandit will help you keep things safe and secure, scanning for vulnerabilities.
Radon and Xenon will help you keep up with code complexity, scalability and maintainability.
Vulture to make sure there’s no dead code - mostly on large codebase.
I use these (among other code quality tools) with pre-commit hooks on my GitHub Actions, to make sure everything’s nice and tidy.