Skip to content

AnshMNSoni/LinkLite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkLite

LinkLite Logo

Python FastAPI React TailwindCSS PostgreSQL Redis Docker

LinkLite is a URL shortener built with FastAPI, PostgreSQL, Redis, React, and Docker.

The project explores caching, asynchronous analytics processing, and performance optimization in a read-heavy system. It implements a cache-aside architecture with Redis, asynchronous click tracking using FastAPI BackgroundTasks, rate limiting, and URL expiration policies.


Features

  • URL Shortening – Generate short, shareable URLs instantly.
  • Custom Short Codes – Create your own aliases or use auto-generated codes.
  • Analytics Dashboard – Track clicks and visualize usage trends over time.
  • Redis Cache Layer – Cache-aside architecture for low-latency redirects.
  • Asynchronous Click Tracking – Analytics logging moved off the request critical path using FastAPI BackgroundTasks.
  • Rate Limiting – Prevent API abuse by limiting request frequencies based on IP.
  • URL Expiration – Configure custom expiration dates and times for shortened links.
  • User Authentication & Ownership – Secure user signup, login, and private dashboard to manage links.
  • URL Safety Verification – Built-in verification scanner checking URLs against suspicious keywords and blocked domains to prevent malicious links.
  • Responsive React UI – Mobile-friendly dashboard built with React, Vite, and Tailwind CSS.
  • Dockerized Development Environment – One-command local setup.

Architecture

LinkLite follows a cache-aside architecture optimized for read-heavy redirect workloads.

Redirect Flow

  1. Incoming request checks Redis for the short code.
  2. Cache hits return immediately.
  3. Cache misses fall back to PostgreSQL.
  4. Results are stored in Redis for future requests.
  5. Click analytics are recorded asynchronously after the response is sent.

Why This Design?

Redirect endpoints are highly read-intensive. A cache layer reduces database load and improves latency, while asynchronous analytics prevent click tracking from blocking redirects.

Quick Start

Backend

cd backend

python -m venv env
source env/Scripts/activate

pip install -r requirements.txt

uvicorn app.main:app --reload

Backend runs on:

http://localhost:8000

Frontend

cd frontend

npm install

npm run dev

Frontend runs on:

http://localhost:3000

Docker

Run the full stack:

docker compose up --build

Technical Decisions

Why Redis?

Redirect workloads repeatedly access the same URLs. Redis reduces database load and provides faster lookups for frequently accessed links.

Why FastAPI BackgroundTasks?

Analytics writes do not need to block redirects.

Using BackgroundTasks keeps the architecture simple while removing analytics latency from the request path without introducing Kafka, RabbitMQ, or Celery.

Why PostgreSQL?

URL mappings require durable storage, indexing, and transactional consistency. PostgreSQL provides all three with minimal operational complexity.


Project Design

linklite-design

Future Improvements

  • Concurrent load testing
  • p95 and p99 latency measurements
  • Redis failure recovery strategies
  • Distributed analytics pipeline

Connect

If you have suggestions, feedback, or would like to discuss system design and backend engineering:

About

LinkLite - Scalable URL Shortening Service (FastAPI, PostgreSQL, Redis)

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors