</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSâ€ēMini Projects
◱

URL Shortener

Software EngineeringAdvanced
System DesignHashing

💡 Overview

This project bridges DSA/DBMS knowledge into real system design — you'll combine a database, an encoding scheme, and basic web routing into one working product.

✅ Features to Build

0/4 done

🧭 Step-by-Step Guide

1

Set up a simple database table: urls(id AUTO_INCREMENT, long_url, short_code).

2

When a long URL is submitted, insert it and get back its auto-generated ID.

3

Convert that ID into a short base-62 string (using characters a-z, A-Z, 0-9) to use as the short_code.

4

Build a route like /:code that looks up the code in the database and issues a redirect to the long_url.

5

Add a check: if the same long URL is submitted again, return the EXISTING short code instead of creating a duplicate.

🚀 Starter Code

const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
function encodeBase62(num) {
  let code = '';
  while (num > 0) {
    code = chars[num % 62] + code;
    num = Math.floor(num / 62);
  }
  return code || '0';
}

💡 Pro Tip

Start with the database ID → base62 encoding working correctly in isolation (test it with plain numbers) before wiring up the actual web server and redirect logic around it.

← Back to all Projects