How goutampatel18/fastapi-social-media works
This is a FastAPI social-media REST API. Clients register or look up users, log in for a bearer token, then use protected post and voting endpoints; post responses include vote counts. The routers own request handling, while shared auth, password, schema, and database layers support them. PostgreSQL stores users, posts, and votes. The README documents interactive API docs and migrations; migrations are operational tooling rather than a runtime product component. Relationships are limited to those visible in excerpts or explicitly documented.
Main entry points: database.py SQLAlchemy sessions · main.py FastAPI application · models.py User, post, vote models · auth.py Login endpoint
Components 15
API surface
- FastAPI application
app/main.py - Interactive API docs
app/main.py
Identity
- User endpoints
app/routers/user.py - Login endpoint
app/routers/auth.py - JWT authentication
app/oauth2.py - Password hashing
app/utils.py
Posts and votes
- Post endpoints
app/routers/post.py - Voting endpoint
app/routers/vote.py
Shared runtime
- Request and response schemas
app/schemas.py - User, post, vote models
app/models.py - SQLAlchemy sessions
app/database.py - Runtime settings
app/config.py
Other components
- API client
- PostgreSQL
- Environment variables
Connections 32
- API client → FastAPI application: sends requests
README.md - FastAPI application → User endpoints: registers router
app/main.py - FastAPI application → Post endpoints: registers router
app/main.py - FastAPI application → Login endpoint: registers router
app/main.py - FastAPI application → Voting endpoint: registers router
app/main.py - FastAPI application → User, post, vote models: creates tables
app/main.py - FastAPI application → SQLAlchemy sessions: binds engine
app/main.py - API client → Interactive API docs: explores API
README.md - User endpoints → Password hashing: hashes passwords
app/routers/user.py - Login endpoint → Password hashing: verifies passwords
app/routers/auth.py - Login endpoint → JWT authentication: creates token
app/routers/auth.py - Post endpoints → JWT authentication: checks identity
app/routers/post.py - Voting endpoint → JWT authentication: checks identity
app/routers/vote.py - JWT authentication → SQLAlchemy sessions: gets session
app/oauth2.py - JWT authentication → User, post, vote models: loads user
app/oauth2.py - JWT authentication → Runtime settings: reads JWT settings
app/oauth2.py - User endpoints → SQLAlchemy sessions: gets session
app/routers/user.py - User endpoints → User, post, vote models: queries users
app/routers/user.py - Post endpoints → SQLAlchemy sessions: gets session
app/routers/post.py - Post endpoints → User, post, vote models: queries posts and votes
app/routers/post.py - Voting endpoint → SQLAlchemy sessions: gets session
app/routers/vote.py - Voting endpoint → User, post, vote models: queries vote records
app/routers/vote.py - Login endpoint → SQLAlchemy sessions: gets session
app/routers/auth.py - Login endpoint → User, post, vote models: queries user
app/routers/auth.py - User endpoints → Request and response schemas: validates and formats
app/routers/user.py - Login endpoint → Request and response schemas: formats token response
app/routers/auth.py - Post endpoints → Request and response schemas: validates and formats
app/routers/post.py - Voting endpoint → Request and response schemas: validates vote input
app/routers/vote.py - User, post, vote models → SQLAlchemy sessions: uses declarative base
app/models.py - SQLAlchemy sessions → Runtime settings: reads connection settings
app/database.py - SQLAlchemy sessions → PostgreSQL: connects to
app/database.py - Environment variables → Runtime settings: supplies values
app/config.py