Skip to content

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.

Notifications You must be signed in to change notification settings

Pranav4555/url-shortner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. 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).

  1. JWT Authentication Used OAuth2PasswordBearer and JWT tokens.

Ensured only logged-in users could create shortened URLs.

  1. 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.

  1. Rate Limiting & Redis Caching Integrated Redis to:

Rate-limit how often a user can shorten URLs.

Cache redirect lookups to speed up redirection.

  1. Click Tracking On each redirect (GET /{short_key}), I incremented the clicks count.

Also stored metadata like created_at for analytics.

  1. 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

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages