Skip to content

ryuoraiden/Workshop-Backend-Dev-with-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Development with Python — FastAPI Workshop

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.


Features

  • 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)

Project Structure

├── 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)

Setup

1. Clone the repo

git clone https://github.com/imhanick/Workshop_Backend_Dev_with_Python.git
cd Workshop_Backend_Dev_with_Python

2. Create a virtual environment

python -m venv venv
venv\Scripts\activate      # Windows
source venv/bin/activate   # macOS/Linux

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Create a .env file in the root directory:

DATABASE_URL=mysql+pymysql://user:password@localhost/dbname
SECRET_KEY=your_secret_key_here
ALGORITHM=HS256

5. Run the server

uvicorn main:app --reload

Visit http://127.0.0.1:8000/docs for the interactive Swagger UI.


API Endpoints

Auth / Users

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

Blogs

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

Tech Stack

  • 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

About

FastAPI REST API with JWT authentication, SQLAlchemy ORM, user management and blog CRUD — GDSC Backend Workshop

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages