How mithgal-jh/fastapi_training_project works
Project type and purpose
• This is a backend‐only RESTful API service built with FastAPI, whose sole responsibility is to serve as the backend for a Blog Management System.
• Purpose: allow users to register, authenticate (JWT/OAuth2), and perform CRUD operations on blog posts, following clean architecture and the Repository Pattern.
File structure
• Top‐level:
• main.py (entry stub)
• requirements.txt
• app/ (all application code)
• app/ contains:
• main.py – mounts FastAPI instance and routers
• database.py – SQLAlchemy engine & session setup (SQLite default)
• models.py – ORM entity definitions (User, Blog with 1-to-many relationship)
• schemas.py – Pydantic request/response models
• hashing.py – Passlib BCrypt hashing utility
• JWTtoken.py & oauth2.py – JWT creation/validation & OAuth2 dependency
• repository/ – business logic and DB CRUD operations (repository pattern)
• routers/ – APIRouter modules for user, blog, authentication endpoints
README for insights
• Emphasizes:
• Clean separation of concerns using the Repository Pattern.
• Security via JWT and OAuth2 password grant.
• Data validation with Pydantic.
• CRUD implementation with SQLAlchemy.
• Interactive docs via Swagger UI / ReDoc.
• Clear labels for every component (e.g., “Auth Router”, “Blog Repository”, “SQLite DB”)
• Blue for FastAPI layers (API Gateway, Routers)
• Green for Business Logic (Repository modules)
• Orange for Security (Hashing, JWT, OAuth2)
• Gray for Data Models & Database