S — Situation: As a backend-focused developer, I wanted to build and deploy a real-world FastAPI project that demonstrates my knowledge of API development, authentication, database modeling, caching, rate limiting, and containerization. The goal was to build a URL Shortener service — like bit.ly — with JWT authentication, click tracking, and protection against abuse using Redis.
T — Task: My objective was to:
Build a secure and functional backend using FastAPI.
Add JWT-based login/register, so users can manage their URLs.
Implement click tracking, stats, and a unique shortener logic.
Add rate limiting and Redis caching to prevent abuse and improve speed.
Containerize the project using Docker to run it anywhere.
Be able to explain and demonstrate it end-to-end in interviews.
A — Action:
- Backend with FastAPI Built RESTful API endpoints for:
/register and /login (with hashed password storage).
/shorten (to generate a short key for a given URL).
/{short_key} (for redirection and click counting).
/stats/{short_key} (for showing analytics).
- JWT Authentication Used OAuth2PasswordBearer and JWT tokens.
Ensured only logged-in users could create shortened URLs.
- SQLAlchemy Models Designed two main models:
User for authentication.
URL with fields like original_url, short_key, clicks, owner_id, and timestamps.
Used SQLite for local dev and kept it abstract for PostgreSQL in production.
- Rate Limiting & Redis Caching Integrated Redis to:
Rate-limit how often a user can shorten URLs.
Cache redirect lookups to speed up redirection.
- Click Tracking On each redirect (GET /{short_key}), I incremented the clicks count.
Also stored metadata like created_at for analytics.
- Dockerization Wrote a clean Dockerfile that:
Set Python 3.12 as the base image.
Installed dependencies via requirements.txt.
Launched Uvicorn with reload mode.
R — Result: Successfully built a full-stack backend microservice that’s:
Secure, authenticated
Click-tracked and cache-optimized
Dockerized and portable
I tested the app locally and in other environments using Docker.
Now, I can showcase this in interviews or deploy it to cloud platforms like Render, Fly.io, or Azure Web Apps.
Along the way, I sharpened skills in:
FastAPI, SQLAlchemy, OAuth2, JWT
Redis integration, Docker basics
Clean project structuring and scalable architecture