How teyalite/reddit-clone works
Reddit Clone is a FastAPI backend for account creation and login, authenticated post management, and voting. Users call the API routes; route handlers validate request/response data, apply domain rules, and read or mutate PostgreSQL through SQLAlchemy. Authentication issues and verifies JWT bearer tokens, while password utilities hash and check credentials. The README also identifies database migrations as part of operating the application, though migration internals are not sampled. Relationships below follow the shown imports and calls; migration-to-model wiring is not asserted.
Main entry points: database.py Database sessions · auth.py Authentication routes · oauth2.py JWT authentication · models.py ORM domain models
Components 13
API entry and routes
- FastAPI application
app/main.py - User routes
app/routers/user.py - Request and response schemas
app/schemas.py
Identity and access
- Authentication routes
app/routers/auth.py - JWT authentication
app/oauth2.py - Password hashing
app/utils.py
Posts and votes
- Post routes
app/routers/post.py - Vote routes
app/routers/vote.py
Data persistence
- ORM domain models
app/models.py - Database sessions
app/database.py - PostgreSQL
- Application settings
app/config.py
Other components
- API client
Connections 28
- API client → FastAPI application: sends requests
app/main.py - FastAPI application → Authentication routes: registers routes
app/main.py - FastAPI application → User routes: registers routes
app/main.py - FastAPI application → Post routes: registers routes
app/main.py - FastAPI application → Vote routes: registers routes
app/main.py - User routes → Request and response schemas: validates and shapes
app/routers/user.py - Authentication routes → Request and response schemas: validates and shapes
app/routers/auth.py - Post routes → Request and response schemas: validates and shapes
app/routers/post.py - Vote routes → Request and response schemas: validates
app/routers/vote.py - User routes → Password hashing: hashes passwords
app/routers/user.py - Authentication routes → Password hashing: checks passwords
app/routers/auth.py - Authentication routes → JWT authentication: creates tokens
app/routers/auth.py - Post routes → JWT authentication: requires current user
app/routers/post.py - Vote routes → JWT authentication: requires current user
app/routers/vote.py - JWT authentication → ORM domain models: loads user
app/oauth2.py - JWT authentication → Database sessions: opens session
app/oauth2.py - User routes → ORM domain models: queries and creates
app/routers/user.py - Authentication routes → ORM domain models: queries user
app/routers/auth.py - Post routes → ORM domain models: queries and mutates
app/routers/post.py - Vote routes → ORM domain models: queries and mutates
app/routers/vote.py - User routes → Database sessions: opens session
app/routers/user.py - Authentication routes → Database sessions: opens session
app/routers/auth.py - Post routes → Database sessions: opens session
app/routers/post.py - Vote routes → Database sessions: opens session
app/routers/vote.py - ORM domain models → Database sessions: uses declarative base
app/models.py - Database sessions → PostgreSQL: connects and queries
app/database.py - Database sessions → Application settings: reads connection settings
app/database.py - JWT authentication → Application settings: reads JWT settings
app/oauth2.py