How saranshkala/blog-api works
This is a FastAPI blog API. Clients register or log in, receive a JWT, then use user, post, and comment endpoints; protected operations resolve the caller and enforce ownership before returning validated responses or changing relational state. Route handlers contain the database logic directly. The graph reflects the sampled handlers and documented API surface; the README documents interactive Swagger UI and startup table creation, but migration tooling is absent.
Main entry points: main.py FastAPI app · database.py DB session and engine · users.py User routes · posts.py Post routes
Components 11
API surface
- FastAPI app
app/main.py - User routes
app/routers/users.py - Post routes
app/routers/posts.py - Comment routes
app/routers/comments.py - Swagger UI
app/main.py
Identity and validation
- JWT auth
app/oauth2.py - Request response schemas
app/schemas.py
Relational data
- DB session and engine
app/database.py - User post comment models
app/models.py - PostgreSQL
Other components
- API client
Connections 22
- API client → FastAPI app: sends requests
README.md - FastAPI app → User routes: registers router
app/main.py - FastAPI app → Post routes: registers router
app/main.py - FastAPI app → Comment routes: registers router
app/main.py - User routes → DB session and engine: opens session
app/routers/users.py - Post routes → DB session and engine: opens session
app/routers/posts.py - Comment routes → DB session and engine: opens session
app/routers/comments.py - User routes → User post comment models: queries and mutates
app/routers/users.py - Post routes → User post comment models: queries and mutates
app/routers/posts.py - Comment routes → User post comment models: queries and mutates
app/routers/comments.py - User routes → JWT auth: issues and resolves tokens
app/routers/users.py - Post routes → JWT auth: resolves caller
app/routers/posts.py - Comment routes → JWT auth: resolves caller
app/routers/comments.py - JWT auth → DB session and engine: loads user
app/oauth2.py - JWT auth → User post comment models: loads User
app/oauth2.py - User routes → Request response schemas: validates and shapes
app/routers/users.py - Post routes → Request response schemas: validates and shapes
app/routers/posts.py - Comment routes → Request response schemas: validates and shapes
app/routers/comments.py - DB session and engine → PostgreSQL: connects and persists
README.md - User post comment models → PostgreSQL: defines relational tables
app/models.py - FastAPI app → Swagger UI: exposes API docs
README.md - FastAPI app → DB session and engine: creates tables at startup
README.md