Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐️Custom Rate-Limited URL Shortener

A high-performance, full-stack URL shortening application to handle scalable link generation, secure redirection, and real-time click tracking.

Built with a focus on robust architecture and strict API security, this application actively mitigates DoS vulnerabilities through a custom-built, in-memory rate-limiting engine.


🛠 Tech Stack

Frontend

React Vite Chart.js Lucide

Backend

Node.js Express SQLite JavaScript

Logic & DevOps

Sliding Window Base62 Docker


⚙️ How to Run the App

You can choose either a manual setup or use Docker for a one-command deployment.

1. Prerequisite

Ensure you have Node.js installed.

2. Standard Manual Setup

Terminal 1: Backend

cd backend
npm install
npm run dev

Terminal 2: Frontend

cd frontend
npm install
npm run dev

The application will be accessible at http://localhost:5173.

3. Docker Deployment (Recommended)

To spin up the entire infrastructure concurrently:

docker-compose up --build

🧠 Core Logic: Rate Limiting Implementation

The system implements a Sliding Window Log algorithm to manage request frequency by IP address without relying on external dependencies like Redis.

How it Works:

  1. Request Tracking: For every incoming request, the middleware retrieves a list of previous request timestamps associated with the user's IP from an in-memory Map.
  2. Window Pruning: It automatically filters out (prunes) any timestamps older than the defined window (e.g., 60 seconds).
  3. Threshold Validation: If the remaining count of valid timestamps exceeds the allowed limit (e.g., 5 requests per minute), the request is rejected with a 429 Too Many Requests status.
  4. Retry Calculation: Unlike fixed-window counters, this logic calculates the exact time until the oldest request in the window expires, providing the client with a precise retryAfter value.
  5. Memory Efficiency: Stale data is cleared on every request, ensuring the memory footprint remains minimal even under high traffic.

📂 Project Structure

.
├── backend/            # Express API & SQLite Data Logic
│    └── middleware/    # Includes the custom rateLimiter logic
├── frontend/           # React Dashboard & Analytics Charting
├── docker-compose.yml  # Container orchestration
└── README.md           # This file

📊 Key Features

  • Deterministic Redirection: Sub-millisecond URL resolution using indexed SQLite lookups.
  • Real-time Analytics: Visualizes click trends over the last 7 days using Chart.js.
  • Self-Healing UI: Frontend handles rate-limit cooldowns gracefully with countdown timers.
  • Production Ready: Fully containerized with Docker for consistent environment deployment.

About

A full-stack URL shortening service build with Node.js, Express, and SQLite.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages