A hands-on backend development repository focused on building scalable REST APIs using FastAPI, PostgreSQL, SQLAlchemy, Redis, JWT Authentication, and Alembic.
This repository contains practical implementations of core backend concepts including authentication, database migrations, caching, rate limiting, Pub/Sub messaging, and CRUD operations.
- User Registration
- User Login
- JWT Token Authentication
- Password Hashing with Passlib
- Protected Routes
- PostgreSQL Integration
- SQLAlchemy ORM
- Alembic Database Migrations
- RESTful API Design
- CRUD Operations
- Request Validation with Pydantic
- Dependency Injection
- Redis Strings
- Hashes
- Lists
- TTL (Time To Live)
- Cache-Aside Pattern
- Redis Pub/Sub
- Persistence (RDB vs AOF)
- Eviction Policies (LRU)
- Login Rate Limiting
- API Response Caching
- FastAPI
- PostgreSQL
- SQLAlchemy
- Alembic
- Redis
- JWT Authentication
- Passlib
- Pydantic
- Docker
- Uvicorn
FASTAPI/
├── alembic/
│ ├── versions/
│ ├── env.py
│ └── script.py.mako
│
├── FastAPI/
│ ├── routers/
│ │ ├── auth.py
│ │ ├── posts.py
│ │ └── students.py
│ │
│ ├── redis_practice/
│ │ ├── 01_strings.py
│ │ ├── 02_ttl.py
│ │ ├── 03_hashes.py
│ │ ├── 04_lists.py
│ │ ├── 05_caching_demo.py
│ │ ├── publisher.py
│ │ ├── subscriber.py
│ │ └── redis_client.py
│ │
│ ├── .env
│ ├── crud.py
│ ├── database.py
│ ├── hashing.py
│ ├── jwt_handler.py
│ ├── main.py
│ ├── models.py
│ └── schemas.py
│
├── .gitignore
├── alembic.ini
├── requirements.txt
└── README.md
git clone https://github.com/<your-username>/fast_api_practice.git
cd fast_api_practicepython -m venv .venv
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtCreate a .env file inside the FastAPI/ directory:
DATABASE_URL=your_postgresql_connection_string
SECRET_KEY=your_secret_keyalembic upgrade headdocker run -d --name redis -p 6379:6379 redisuvicorn FastAPI.main:app --reloadOpen:
http://127.0.0.1:8000/docs
to access the interactive Swagger UI.
Navigate to:
cd FastAPI/redis_practiceRun examples:
python 01_strings.py
python 02_ttl.py
python 03_hashes.py
python 04_lists.py
python 05_caching_demo.pyPub/Sub example:
Terminal 1:
python subscriber.pyTerminal 2:
python publisher.py