How baygeldiaza/layered-architecuture-social-media works
This is a FastAPI backend for user accounts, JWT authentication, posts, and votes. A client request enters the application, is dispatched to a feature router, and the handler validates request/response data and performs database operations; protected operations resolve the bearer token to a user first. Account creation hashes passwords, while login verifies them and issues a token. The source excerpts show the principal handlers and persistence setup; deployment documentation also identifies PostgreSQL, but migrations and deployment mechanics are omitted from this runtime view.
Main entry points: oauth2.py JWT Auth · db.py DB Sessions · auth.py Login Route · user.py User Routes
Components 13
API Routing
- FastAPI App
app/main.py - Request Schemas
app/schemas/schemas.py
Identity
- Login Route
app/routers/auth.py - JWT Auth
app/auth/oauth2.py - Password Hashing
app/utils/utils.py
Accounts And Content
- User Routes
app/routers/user.py - Post Routes
app/routers/post.py - Vote Routes
app/routers/vote.py
Persistence
- ORM Models
app/models/models.py - DB Sessions
app/database/db.py - Runtime Settings
app/core/config.py
Other components
- API Client
- PostgreSQL
Connections 30
- API Client → FastAPI App: sends requests
README.md - FastAPI App → Login Route: registers
app/main.py - FastAPI App → User Routes: registers
app/main.py - FastAPI App → Post Routes: registers
app/main.py - FastAPI App → Vote Routes: registers
app/main.py - Login Route → DB Sessions: queries users
app/routers/auth.py - Login Route → ORM Models: queries users
app/routers/auth.py - Login Route → Password Hashing: verifies password
app/routers/auth.py - Login Route → JWT Auth: creates token
app/routers/auth.py - Login Route → Request Schemas: returns token
app/routers/auth.py - User Routes → DB Sessions: queries and writes
app/routers/user.py - User Routes → ORM Models: uses models
app/routers/user.py - User Routes → Request Schemas: validates and shapes
app/routers/user.py - User Routes → Password Hashing: hashes passwords
app/routers/user.py - User Routes → JWT Auth: resolves current user
app/routers/user.py - Post Routes → DB Sessions: queries and writes
app/routers/post.py - Post Routes → ORM Models: uses models
app/routers/post.py - Post Routes → Request Schemas: validates and shapes
app/routers/post.py - Post Routes → JWT Auth: resolves current user
app/routers/post.py - Vote Routes → DB Sessions: queries and writes
app/routers/vote.py - Vote Routes → ORM Models: uses models
app/routers/vote.py - Vote Routes → Request Schemas: validates vote
app/routers/vote.py - Vote Routes → JWT Auth: resolves current user
app/routers/vote.py - JWT Auth → DB Sessions: loads user
app/auth/oauth2.py - JWT Auth → ORM Models: queries user
app/auth/oauth2.py - JWT Auth → Request Schemas: builds token data
app/auth/oauth2.py - JWT Auth → Runtime Settings: reads signing settings
app/auth/oauth2.py - DB Sessions → Runtime Settings: configures engine
app/database/db.py - ORM Models → DB Sessions: uses declarative base
app/models/models.py - DB Sessions → PostgreSQL: connects to
README.md