How buguno/fastapi-template works
This is a reusable FastAPI template with a working async user-management and JWT-authentication slice. The main workflow is HTTP request → router → service → user persistence, with schemas shaping inputs and outputs; authentication adds password hashing, token creation, and current-user resolution. The excerpts show the core calls and dependencies. PostgreSQL is documented as the database target, but the runtime database interaction is through SQLAlchemy sessions. Other unsampled capabilities are not inferred beyond the README and file tree.
Main entry points: users.py User Routes · security.py Password And JWT · main.py FastAPI Application · user.py User Service
Components 17
HTTP API
- FastAPI Application
app/main.py - User Routes
app/routers/users.py - Auth Routes
app/routers/auth.py
Domain Services
- User Service
app/services/user.py - Auth Service
app/services/auth.py - Domain Exceptions
app/exceptions.py
Identity And Persistence
- User Entity
app/models/user.py - Model Registry
app/models/base.py - Async Database Session
app/database.py - Password And JWT
app/security.py
Contracts And Configuration
- User Schemas
app/schemas/user.py - Token Schema
app/schemas/token.py - Pagination Filter
app/schemas/filters.py - Message Schema
app/schemas/message.py - Application Settings
app/settings.py
Other components
- API Client
- PostgreSQL
Connections 30
- API Client → FastAPI Application: sends requests
README.md - FastAPI Application → User Routes: mounts routes
app/main.py - FastAPI Application → Auth Routes: mounts routes
app/main.py - FastAPI Application → Domain Exceptions: translates errors
app/main.py - FastAPI Application → Message Schema: uses response
app/main.py - FastAPI Application → Application Settings: configures docs
app/main.py - User Routes → User Service: calls
app/routers/users.py - Auth Routes → Auth Service: calls
app/routers/auth.py - User Routes → Async Database Session: injects session
app/routers/users.py - Auth Routes → Async Database Session: injects session
app/routers/auth.py - User Routes → Password And JWT: resolves current user
app/routers/users.py - Auth Routes → Password And JWT: resolves current user
app/routers/auth.py - User Routes → User Schemas: accepts and returns
app/routers/users.py - User Routes → Pagination Filter: accepts filters
app/routers/users.py - User Routes → Message Schema: returns message
app/routers/users.py - Auth Routes → Token Schema: returns token
app/routers/auth.py - User Service → User Entity: queries and updates
app/services/user.py - User Service → Password And JWT: hashes passwords
app/services/user.py - User Service → Domain Exceptions: raises domain errors
app/services/user.py - User Service → User Schemas: uses input schema
app/services/user.py - User Service → Pagination Filter: uses filters
app/services/user.py - Auth Service → User Entity: queries user
app/services/auth.py - Auth Service → Password And JWT: verifies and issues tokens
app/services/auth.py - Auth Service → Domain Exceptions: raises credential error
app/services/auth.py - Password And JWT → Async Database Session: injects session
app/security.py - Password And JWT → User Entity: loads current user
app/security.py - Password And JWT → Application Settings: uses token settings
app/security.py - Async Database Session → Application Settings: reads database URL
app/database.py - Model Registry → User Entity: registers mapping
app/models/__init__.py - Async Database Session → PostgreSQL: connects asynchronously