Skip to content
shin0biXPublic

About

URL shortener with custom aliases, password-protected links, Redis caching, and click analytics (FastAPI + React)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

🔗 Shorty

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


✨ Features

  • 🔗 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

🛠️ Tech Stack

Area Technologies
Backend FastAPI, Python, SQLAlchemy
Frontend React, Vite, CSS
Database SQLite
Caching Redis
Analytics user-agents, ip-api.com

🏗️ Architecture

Shorty separates the user interface, application logic, caching, and persistent storage:

┌──────────────────┐
│  React Frontend  │
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ FastAPI Backend  │
└───────┬─────┬────┘
        │     │
        ▼     ▼
┌──────────┐ ┌──────────┐
│  Redis   │ │  SQLite  │
│  Cache   │ │ Database │
└──────────┘ └──────────┘
        │
        ▼
 Background Analytics

How it works

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:

  1. Shorty checks Redis for a cached URL.
  2. If it isn't cached, it falls back to the database.
  3. Password-protected links require authentication before access.
  4. Click analytics are processed in the background to keep redirects fast.
  5. Frequently accessed links are cached for future requests.

🚀 Getting Started

Prerequisites

  • Python 3.9+
  • Node.js 16+
  • Redis
  • SQLite (included with Python)

Backend Setup

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 --reload

The backend will be available at http://127.0.0.1:8000.

Frontend Setup

cd frontend

npm install
npm run dev

📡 API Overview

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.


📁 Project Structure

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

🔮 Future Improvements

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!

About

URL shortener with custom aliases, password-protected links, Redis caching, and click analytics (FastAPI + React)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages