How ahmetfbalci/fastapi-jwt-auth works
This repository is a FastAPI authentication service. Clients register or log in with username/password, then receive JWT access and refresh tokens; refresh-token state supports renewal and logout revocation. A separate Google OAuth flow either signs in an existing linked account or issues a short-lived pending token so a new user can choose a username. The graph also includes the shared security, session, schema, and persistence layers. Connections reflect the sampled source and README; migrations and unsampled internals are not mapped.
Main entry points: google_auth.py Google auth · auth.py Password auth · database.py Database session · main.py FastAPI app
Components 13
API flows
- FastAPI app
app/main.py - Password auth
app/routers/auth.py - Google auth
app/routers/google_auth.py
Identity security
- Token and password security
app/core/security.py
Persistence
- Database session
app/database.py - User records
app/models/user.py - Provider accounts
app/models/AuthAccount.py - Refresh-token records
app/models/refresh_token.py
API contracts
- User schemas
app/schemas/user.py - Token schema
app/schemas/token.py
Other components
- API client
- Google OAuth
- PostgreSQL
Connections 23
- API client → FastAPI app: sends requests
README.md - FastAPI app → Password auth: mounts router
app/main.py - FastAPI app → Google auth: mounts router
app/main.py - FastAPI app → Database session: creates tables
app/main.py - Password auth → User schemas: validates users
app/routers/auth.py - Password auth → Token schema: returns tokens
app/routers/auth.py - Google auth → Token schema: returns tokens
app/routers/google_auth.py - Password auth → Token and password security: uses security
app/routers/auth.py - Google auth → Token and password security: uses token functions
app/routers/google_auth.py - Token and password security → Database session: gets session
app/core/security.py - Token and password security → User records: loads current user
app/core/security.py - Password auth → Database session: gets session
app/routers/auth.py - Password auth → User records: queries and writes
app/routers/auth.py - Password auth → Refresh-token records: stores and revokes
app/routers/auth.py - Google auth → Database session: gets session
app/routers/google_auth.py - Google auth → User records: queries and creates
app/routers/google_auth.py - Google auth → Provider accounts: looks up and links
app/routers/google_auth.py - Google auth → Refresh-token records: stores refresh tokens
app/routers/google_auth.py - Google OAuth → Google auth: authorizes callback
app/routers/google_auth.py - Database session → PostgreSQL: connects to
app/database.py - User records → Database session: uses declarative base
app/models/user.py - Provider accounts → Database session: uses declarative base
app/models/AuthAccount.py - Refresh-token records → Database session: uses declarative base
app/models/refresh_token.py