How pcnerd9/fastapi_boilerplate works
This is a FastAPI authentication service offering email OTP registration/login, cookie-based refreshable sessions, and Google OAuth/OIDC account creation and linking. Users enter through the API routes, which delegate authentication to domain services; successful flows create sessions and return access tokens while setting refresh-token cookies. The services use repositories backed by PostgreSQL, Redis for supporting authentication state, and email providers for OTP delivery. Google OAuth exchanges authorization codes and validates identity tokens. The README is empty, so capability details come from route documentation and indexed source references; several internal links remain unshown.
Main entry points: google_auth.py Google auth · otp_auth.py OTP auth · dependencies.py Auth dependencies · main.py App startup
Components 22
HTTP API
- App startup
main.py - Auth routes
src/api/routes/auth.py - OAuth routes
src/api/routes/oauth.py - Auth dependencies
src/api/dependencies.py
Authentication
- OTP auth
src/service/auth/otp_auth.py - Google auth
src/service/auth/google_auth.py - Session limits
src/service/auth/session_service.py - Token utilities
src/core/security/token_manager.py - OIDC validation
src/core/security/oidc_validator.py - OAuth state
src/core/security/oauth_state.py
Persistence
- OTP repository
src/repository/otp_repository.py - User repository
src/repository/user_repository.py - Session repository
src/repository/refresh_token_repository.py - Provider repository
src/repository/oauth_provider_repository.py - User model
src/models/user.py
Runtime infrastructure
- PostgreSQL
src/infrastructure/database/postgres_db.py - Redis
src/infrastructure/database/redis.py - Email delivery
src/service/email_service.py - Email providers
src/infrastructure/email_provider - Settings
src/core/config.py
Other components
- Client
- Google OIDC
Connections 32
- Client → App startup: sends requests
main.py - App startup → Auth routes: registers routes
- App startup → OAuth routes: registers routes
- Auth routes → OTP auth: delegates OTP
src/api/routes/auth.py - OAuth routes → Google auth: delegates OAuth
src/api/routes/oauth.py - Auth routes → Auth dependencies: requires identity
src/api/routes/auth.py - OAuth routes → Auth dependencies: requires identity
src/api/routes/oauth.py - Auth dependencies → Token utilities: decodes tokens
src/api/dependencies.py - Auth dependencies → Redis: checks revocation
src/api/dependencies.py - Auth dependencies → User repository: loads user
src/api/dependencies.py - OTP auth → OTP repository: manages OTPs
src/service/auth/otp_auth.py - OTP auth → User repository: manages users
src/service/auth/otp_auth.py - OTP auth → Session repository: manages sessions
src/service/auth/otp_auth.py - OTP auth → Email delivery: sends OTP
src/service/auth/otp_auth.py - OTP auth → Session limits: enforces limits
src/service/auth/otp_auth.py - OTP auth → Token utilities: issues tokens
src/service/auth/otp_auth.py - Google auth → OAuth state: stores state
src/service/auth/google_auth.py - Google auth → Google OIDC: exchanges code
src/service/auth/google_auth.py - Google auth → OIDC validation: validates identity
src/service/auth/google_auth.py - Google auth → User repository: resolves account
src/service/auth/google_auth.py - Google auth → Provider repository: links provider
src/service/auth/google_auth.py - Google auth → Session repository: creates session
src/service/auth/google_auth.py - Google auth → Session limits: enforces limits
src/service/auth/google_auth.py - Session limits → Session repository: deletes old sessions
src/service/auth/session_service.py - Email delivery → Email providers: uses provider
src/service/email_service.py - User repository → User model: queries model
src/repository/user_repository.py - OTP repository → PostgreSQL: persists OTPs
- Session repository → PostgreSQL: persists sessions
src/repository/refresh_token_repository.py - Provider repository → PostgreSQL: persists links
- User model → PostgreSQL: maps tables
src/models/user.py - App startup → Settings: loads settings
main.py - Google auth → Redis: stores OAuth state