How viktorsapozhok/fastapi-services-oauth2 works
This is a FastAPI/Postgres demo structured in API, service, and data-access tiers. The main workflows are bearer-token authentication and authenticated movie lookups; authentication also includes user creation through the auth service. Routers receive requests, obtain database sessions, and delegate to services. The README documents Postgres and OAuth2/JWT as core capabilities. Some modules, notably the movie service and CLI, were not excerpted, so uncertain internal links are omitted or marked unverified.
Main entry points: auth.py Auth Service · routers/movies.py Movie Endpoints · session.py Session Factory · services/movies.py Movie Service
Components 21
HTTP API
- FastAPI Application
app/main.py - Auth Endpoint
app/routers/auth.py - Movie Endpoints
app/routers/movies.py - CLI
app/cli.py
Authentication
- Auth Service
app/services/auth.py - Auth Data Manager
app/services/auth.py - Auth Schemas
app/schemas/auth.py - User Model
app/models/auth.py
Movie Service
- Movie Service
app/services/movies.py - Movie Schema
app/schemas/movies.py - Movie Model
app/models/movies.py
Data and Configuration
- Session Factory
app/backend/session.py - Data Access Base
app/services/base.py - SQL Model Base
app/models/base.py - Settings
app/backend/config.py - API Constants
app/const.py - API Errors
app/exc.py - Schema Base
app/schemas/base.py - Version Metadata
app/version.py
Other components
- API Client
- Postgres
Connections 26
- FastAPI Application → Auth Endpoint: registers
app/main.py - FastAPI Application → Movie Endpoints: registers
app/main.py - API Client → Auth Endpoint: requests token
app/routers/auth.py - API Client → Movie Endpoints: requests movies
app/routers/movies.py - Auth Endpoint → Auth Service: delegates authentication
app/routers/auth.py - Movie Endpoints → Movie Service: delegates queries
app/routers/movies.py - Auth Endpoint → Session Factory: depends on session
app/routers/auth.py - Movie Endpoints → Session Factory: depends on session
app/routers/movies.py - Movie Endpoints → Auth Service: validates bearer token
app/routers/movies.py - Auth Service → Auth Data Manager: reads and writes users
app/services/auth.py - Auth Data Manager → User Model: queries user model
app/services/auth.py - Auth Service → Auth Schemas: uses auth schemas
app/services/auth.py - Auth Service → Settings: reads token key
app/services/auth.py - Auth Service → API Errors: raises auth errors
app/services/auth.py - Auth Service → Data Access Base: inherits data access
app/services/auth.py - Auth Data Manager → Data Access Base: uses data operations
app/services/auth.py - Movie Service → Data Access Base: uses data operations
app/services/movies.py - Movie Service → Movie Model: queries movie model
app/services/movies.py - Movie Service → Movie Schema: returns movie schema
app/services/movies.py - Data Access Base → Session Factory: uses database session
app/services/base.py - Session Factory → Settings: configures connection
app/backend/session.py - Session Factory → Postgres: connects to
app/backend/session.py - SQL Model Base → User Model: bases model
app/models/auth.py - SQL Model Base → Movie Model: bases model
app/models/movies.py - Schema Base → Auth Schemas: bases schemas
app/schemas/auth.py - Schema Base → Movie Schema: bases schema
app/schemas/movies.py