How swathigithubrit/fastapi-authentication-system works
This is a compact FastAPI authentication backend. A client registers with credentials, logs in to receive a bearer JWT, then supplies that token to access the profile endpoint. The route layer owns registration and login actions; authentication helpers handle password hashing and token operations, while dependencies validate tokens and load the current user. Database startup and PostgreSQL persistence are shown as separate runtime responsibilities. Edges reflect the supplied source excerpts or README; database table registration details are documented but not fully visible in the excerpts.
Main entry points: user_routes.py User endpoints · dependencies.py Session and user dependencies · database.py Database session provider · main.py FastAPI application
Components 9
API workflow
- FastAPI application
app/main.py - User endpoints
app/routes/user_routes.py - Request and token schemas
app/schemas/user_schemas.py
Authentication
- Password and JWT helpers
app/auth.py - Session and user dependencies
app/dependencies.py
Persistence
- Database session provider
app/database.py - User model
app/models/user_model.py
Other components
- API client
- PostgreSQL database
Connections 11
- API client → User endpoints: registers, logs in, requests profile
README.md - FastAPI application → Database session provider: creates tables at startup
app/main.py - FastAPI application → User endpoints: includes router
app/main.py - User endpoints → Request and token schemas: uses request and token schemas
app/routes/user_routes.py - User endpoints → Session and user dependencies: injects session and current user
app/routes/user_routes.py - User endpoints → User model: queries and creates users
app/routes/user_routes.py - User endpoints → Password and JWT helpers: hashes, verifies, and issues tokens
app/routes/user_routes.py - Session and user dependencies → Database session provider: gets database session
app/dependencies.py - Session and user dependencies → Password and JWT helpers: validates JWT
app/dependencies.py - Session and user dependencies → User model: loads user by email
app/dependencies.py - Database session provider → PostgreSQL database: connects and creates tables
README.md