A full-stack URL shortener built with FastAPI and React. Shorty goes beyond generating short links with custom aliases, password protection, click analytics, rate limiting, and Redis caching.
🌐 Live Demo: shorty.ujjawalcodes.site
- 🔗 URL Shortening — Turn long URLs into simple, shareable links
- ✏️ Custom Aliases — Choose your own short code or generate one automatically
- 🔒 Password Protection — Restrict access to sensitive links
- 📊 Click Analytics — Track clicks, locations, devices, browsers, and operating systems
- ⚡ Redis Caching — Speed up URL lookups with database fallback
- 🛡️ Rate Limiting — Help prevent abuse and excessive requests
- ⚙️ Background Processing — Collect analytics without slowing down redirects
- 📱 Responsive UI — Works across desktop and mobile devices
| Area | Technologies |
|---|---|
| Backend | FastAPI, Python, SQLAlchemy |
| Frontend | React, Vite, CSS |
| Database | SQLite |
| Caching | Redis |
| Analytics | user-agents, ip-api.com |
Shorty separates the user interface, application logic, caching, and persistent storage:
┌──────────────────┐
│ React Frontend │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ FastAPI Backend │
└───────┬─────┬────┘
│ │
▼ ▼
┌──────────┐ ┌──────────┐
│ Redis │ │ SQLite │
│ Cache │ │ Database │
└──────────┘ └──────────┘
│
▼
Background Analytics
When a user creates a link, Shorty validates and stores the URL with either a custom alias or a generated Base62 short code.
When someone visits a short link:
- Shorty checks Redis for a cached URL.
- If it isn't cached, it falls back to the database.
- Password-protected links require authentication before access.
- Click analytics are processed in the background to keep redirects fast.
- Frequently accessed links are cached for future requests.
- Python 3.9+
- Node.js 16+
- Redis
- SQLite (included with Python)
git clone https://github.com/shin0biX/Shorty.git
cd Shorty
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reloadThe backend will be available at http://127.0.0.1:8000.
cd frontend
npm install
npm run dev| Endpoint | Description |
|---|---|
POST /shorten-link |
Create a new shortened URL |
GET /{short_code} |
Redirect to the original URL |
POST /unlock/{short_code} |
Unlock a password-protected link |
GET /analytics/{short_code} |
View analytics for a specific link |
FastAPI's interactive API documentation is also available when running the backend locally at /docs.
Shorty/
├── main.py # FastAPI application entry point
├── models.py # SQLAlchemy database models
├── database.py # Database configuration and sessions
├── routes/ # API routes and application logic
├── frontend/ # React frontend
│ ├── src/
│ └── package.json
├── requirements.txt # Python dependencies
└── README.md
Ideas I'd like to explore as the project evolves:
- 👤 User accounts and personal link dashboards
- 🌐 Custom domain support
- ⏳ Link expiration
- 📈 Enhanced analytics and trends
- 📱 QR code generation
- 🧪 Automated tests
- 🐳 Docker support
Built with FastAPI and React 🚀
⭐ If you found this project interesting, consider giving it a star!