A full-featured REST API built with FastAPI, SQLAlchemy, and JWT authentication, covering user management and a blog system. Built during a GDSC (Google Developer Student Clubs) backend development workshop.
- User Registration & Login with hashed passwords (bcrypt)
- JWT Authentication — access & refresh tokens via PyJWT
- Blog CRUD — Create, Read, Update, Delete blog posts
- MySQL Database integration via SQLAlchemy ORM
- CORS enabled for frontend integration
- Modular project structure (routers, models, schemas, security)
├── main.py # FastAPI app entry point, middleware & router registration
├── database.py # SQLAlchemy engine & session setup
├── models/ # ORM models (User, Blog)
├── routers/ # API route handlers (users, blogs)
├── schemas/ # Pydantic request/response schemas
├── security/ # JWT token creation & OAuth2 password flow
├── requirements.txt # Python dependencies
└── .env # Environment variables (not committed)
git clone https://github.com/imhanick/Workshop_Backend_Dev_with_Python.git
cd Workshop_Backend_Dev_with_Pythonpython -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linuxpip install -r requirements.txtCreate a .env file in the root directory:
DATABASE_URL=mysql+pymysql://user:password@localhost/dbname
SECRET_KEY=your_secret_key_here
ALGORITHM=HS256uvicorn main:app --reloadVisit http://127.0.0.1:8000/docs for the interactive Swagger UI.
| Method | Endpoint | Description |
|---|---|---|
| POST | /users/register |
Register a new user |
| POST | /users/login |
Login and receive JWT tokens |
| GET | /users/me |
Get current authenticated user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /blogs |
Get all blog posts |
| POST | /blogs |
Create a new blog post |
| PUT | /blogs/{id} |
Update a blog post |
| DELETE | /blogs/{id} |
Delete a blog post |
- FastAPI — web framework
- SQLAlchemy — ORM for database models
- PyMySQL — MySQL driver
- PyJWT + Passlib/bcrypt — authentication & password hashing
- Pydantic v2 — data validation & serialization
- Uvicorn — ASGI server