A modern URL Shortener built with FastAPI, SQLAlchemy, Redis, and React. The application allows users to generate short links, track click analytics, and redirect users efficiently using a caching layer.
Frontend: https://short.harsh-shah.me
Backend API: https://shortapi.harsh-shah.me
- Shorten long URLs into compact links
- Automatic redirection using unique short codes
- Click tracking and analytics
- Redis caching for faster URL lookups
- RESTful API built with FastAPI
- Interactive API documentation with Swagger UI
- React frontend with a modern user interface
- Custom domain support
- Responsive design
- FastAPI
- SQLAlchemy
- SQLite
- Redis
- Pydantic
- Uvicorn
- React
- Vite
- Tailwind CSS
- Render (Backend & Redis)
- Vercel (Frontend)
- Namecheap (Custom Domains)
url_shortner/
│
├── backend/
│ ├── app.py
│ ├── crud.py
│ ├── db_models.py
│ ├── database_generation.py
│ ├── redis_client.py
│ └── schemas.py
│
├── frontend/
│ ├── src/
│ ├── public/
│ └── package.json
│
├── requirements.txt
└── README.md
User
│
▼
React Frontend
(short.harsh-shah.me)
│
▼
FastAPI Backend
(shortapi.harsh-shah.me)
│
├── Redis Cache
│
▼
SQLite Database
Request
│
▼
Redis Cache
│
├── Cache Hit
│ ▼
│ Redirect
│
└── Cache Miss
▼
SQLite
▼
Store in Redis
▼
Redirect
POST /shortenRequest:
{
"url": "https://example.com"
}Response:
{
"shorten_url": "https://short.harsh-shah.me/abc123"
}GET /{short_code}Example:
GET /abc123Redirects to the original URL.
GET /stats/{short_code}Response:
{
"original_url": "https://example.com",
"short_code": "abc123",
"clicks": 15
}GET /healthyResponse:
{
"status": "healthy"
}git clone https://github.com/Enky-yy/URL-Shortner.git
cd url_shortnerpython -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate a .env file:
BASE_URL=http://localhost:8000
REDIS_URL=redis://localhost:6379Run the backend:
uvicorn app.app:app --reloadBackend runs on:
http://localhost:8000
cd frontend
npm installCreate:
VITE_API_URL=http://localhost:8000Run:
npm run devFrontend runs on:
http://localhost:5173
- Custom aliases
- QR code generation
- PostgreSQL support
- User authentication
- Link expiration
- Advanced analytics dashboard
- Rate limiting
- Docker support
- CI/CD pipeline
- REST API development with FastAPI
- Database design using SQLAlchemy
- Redis caching strategies
- Full-stack application development
- Deployment using Render and Vercel
- Environment variable management
- Domain configuration and DNS management
Harsh Shah