URL Shortener & Analytics Platform
A production-grade URL Shortener & Analytics Platform designed to demonstrate core Software Development Engineering (SDE) concepts. Built with Python (Flask), PostgreSQL, SQLAlchemy ORM, JWT Authentication, and modern HTML/CSS/JS, this platform provides reliable link shortening and in-depth traffic analytics.
๐ How It Works (System Flow)
1. Creating a Short URL
When a user enters a long URL via the frontend, a POST /api/urls request is sent to the Flask Backend. The system uses a Base62 Algorithm (converting the Database ID into a short string using 62 alphanumeric characters) to generate a unique short code, saving the mapping in the PostgreSQL database.
2. Visiting a Short URL (Redirection & Analytics)
When a user visits the generated short URL (e.g., /aB72x), the backend searches for the original target in the database and verifies its expiration status. Concurrently, it parses the HTTP request to extract metadata (Browser, OS, Referrer, IP) and records this in the clicks table to increment the counter, before triggering an HTTP 302 Redirect to the target.
๐ ๏ธ Technology Stack & SDE Concepts
- C++ / Python: DSA Concept: Base62 conversion algorithm (0-9, a-z, A-Z) ensuring compact, URL-safe links without special characters.
- Python (Flask): Web Application & RESTful API Backend.
- PostgreSQL: Relational Database Engine.
- SQLAlchemy: Object-Relational Mapping (ORM) & Database migrations.
- JWT (PyJWT): Stateless Authentication & Token Security.
- HTML5 / CSS3 / JS: Responsive Frontend UI with Glassmorphism & Dark Mode.
- Docker & Compose: Containerized multi-service deployment.
๐๏ธ Relational Database Schema
The platform uses a well-structured relational design:
userstable: Handles authentication, storing unique usernames, emails, and password hashes.urlstable: Links to users (One-to-Many). Stores the original URL, short code, expiration dates, and click counts.clickstable: Links to URLs (One-to-Many). Logs analytics including IP addresses, timestamps, browser, OS, and referrers.
๐ก REST API Documentation
Authentication APIs
POST /api/auth/registerโ Register a new userPOST /api/auth/loginโ Sign in user and receive JWT Bearer tokenGET /api/auth/meโ Fetch current user profile
URL Management & Analytics APIs
POST /api/urlsโ Shorten a long URL (supports custom aliases & expiration)GET /api/urlsโ Fetch user's shortened URLsGET /api/urls/<id>/analyticsโ Get click counts, top browsers, OS, referrers, and visit logsDELETE /api/urls/<id>โ Delete a short URL
๐งช Try It Live & View Code
Click here to launch the live Platform
View the complete codebase on GitHub
๐ Connect with Me
๐ www.tauqueeralam.com
๐ฑ LinkedIn | GitHub
View the live demo below:
View Live Demo
Discussion