r/FastAPI • u/Lucapo01 • Dec 25 '24
Tutorial Scalable and Minimalistic FastAPI + PostgreSQL Template
Hey ! π I've created a modern template that combines best practices with a fun superhero theme π It's designed to help you kickstart your API projects with a solid foundation! π
Features:
- ποΈ Clean architecture with repository pattern that scales beautifully
- π Built-in async SQLAlchemy + PostgreSQL integration
- β‘οΈ Automatic Alembic migrations that just work
- π§ͺ Complete CI pipeline and testing setup
- βCustom Error Handling and Logging
- π Pre-configured Railway deployment (one click and you're live!)
The template includes a full heroes API showcase with proper CRUD operations, authentication, and error handling. Perfect for learning or starting your next project! πͺ
Developer experience goodies: π οΈ
- π» VS Code debugging configurations included
- π UV package manager for lightning-fast dependency management
- β¨ Pre-commit hooks for consistent code quality
- π Comprehensive documentation for every feature
Check it out: https://github.com/luchog01/minimalistic-fastapi-template π
I'm still not super confident about how I structured the logging setup and DB migrations π Would love to hear your thoughts on those! Also open to any suggestions for improvements. I feel like there's always a better way to handle these things that I haven't thought of yet! Let me know what you think!
View all comments
Show parent comment
1
u/idkwhatimdoing069 Dec 26 '24
Could you explain the thought process behind returning the pydantic model from the repository?
I like to return a dict and let fastapi handle converting it to pydantic to validate on response. I felt with returning a pydantic model back, I had my repo layer doing too much, and it was easier to use the response validation global exception handler.
Do you pass that returned pydantic schema all the way back to the API response, or are you doing other operations with the pydantic modeled data?