⚡ High-Performance URL Shortener Dock (FlashURL clone)
Shorten_url is a modern, efficient link-shortening service built to handle high traffic and deliver fast redirects. Unlike a basic CRUD prototype, this project is architected for performance and scalability, employing caching, horizontal scaling, containerisation and persistence.
This repository includes:
- A web service built with Flask (Python)
- Persistent storage via PostgreSQL
- Caching via Redis to serve popular links in-memory
- Container-ready setup with Docker & Docker Compose
- A simple user interface for creating + using short links
- Ultra-fast link redirect via caching layer (Redis)
- Stateless application tier optimized for horizontal scaling
- Persistent storage via PostgreSQL for durability
- Containerised environment for development & deployment consistency
- Clean, responsive web UI (with dark mode)
- API endpoint to programmatically create short URLs
- Easy to deploy via Docker / Docker Compose
Tech Stack:
- Backend: Python + Flask
- Cache: Redis
- Database: PostgreSQL
- Containerisation: Docker, Docker Compose
- Web UI: HTML / CSS / JavaScript
Architecture in a nutshell: User → Web UI/API → Application (Flask + Gunicorn) →
- On each redirect: Check Redis cache → if hit, return redirect; if miss, fetch from PostgreSQL and then populate cache.
- On creation: Validate URL → generate unique short code → store in DB → optionally warm cache.
This design ensures that read-heavy redirect traffic is served from memory (Redis) quickly, reducing load on the primary database.
- Docker & Docker Compose installed on your machine
- (Optional) Local installation of PostgreSQL & Redis if you prefer non-containerised setup
# Clone repository
git clone https://github.com/itz-sidd/Shorten_url.git
cd Shorten_url
# Build and run via Docker Compose
docker-compose up --build Once up, the service will typically be available at http://localhost:5000.
-
Create Short Link
-
Endpoint:
POST /shorten -
Headers:
Content-Type: application/json -
Request Body:
{ "original_url": "https://www.google.com" } -
Response Example:
{ "original_url": "https://www.google.com", "short_url": "http://your-domain.com/1a" }
-
-
Redirect via Short Code
- Endpoint:
GET /<short_code> - Behavior: Redirects the user to the original long URL.
- Endpoint:
Navigate to the base URL of the service (e.g. http://localhost:5000) and use the simple interface to paste a long URL and get back a short link. The UI also supports default dark mode and is mobile responsive.
This project is designed to be deployed in a containerised production environment. You can use the provided docker-compose.yml or adapt it to your favourite orchestration platform (Kubernetes, ECS, etc.).
Environment variables such as DATABASE_URL, REDIS_URL, and PORT must be set in your production environment.
Ensure the following environment variables are set:
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
Connection string for PostgreSQL | postgresql://user:password@host:5432/dbname |
REDIS_URL |
Connection for Redis cache | redis://host:6379/0 |
PORT |
Port on which the Flask app will listen | 5000 |
You may also configure other settings (e.g., short-code length, domain) by editing config.py.
Thanks for considering contribution! Here’s how you can help:
- Fork the repository and create your branch (
git checkout -b feature/YourFeature) - Make your changes, ensure code style / linting is maintained
- Add tests (if applicable) and verify existing functionality
- Submit a pull request with a clear description of your changes
Please follow best practices for commit messages and code structure. You can also open issues for discussion or bug reports.
This project is under the MIT License. See the LICENSE file for details.
Project maintained by Siddharth (GitHub: @itz-sidd). Feel free to reach out for questions, feedback or suggestions!