Skip to content

schak04/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

A lightweight URL shortening service built using Node.js, Express, MongoDB, and Mongoose.
It generates unique short IDs for long URLs and redirects users efficiently using dynamic routing.


Tech Stack

  • Node.js
  • Express
  • MongoDB
  • Mongoose
  • nanoid

Features

  • Generate unique short URLs using nanoid
  • Store URL mappings in MongoDB
  • Dynamic route-based redirection
  • Unique constraint enforcement at database level
  • Basic error handling for invalid short IDs
  • Minimal UI for testing functionality

Architecture Overview

  1. User submits a long URL via form
  2. Backend generates a 6-character short ID
  3. Mapping is stored in MongoDB
  4. Visiting /:shortID performs a database lookup
  5. If found -> server responds with HTTP redirect
  6. If not found -> returns 404 response

API Endpoints

  • GET / → Serves UI
  • POST /shorten → Creates short URL
  • GET /:shortID → Redirects to original URL

Project Structure

.
├─ config/
├─ controllers/
├─ models/
├─ routes/
├─ index.js
├─ index.html

Author

© 2026 Saptaparno Chakraborty.
All rights reserved.


About

A lightweight URL shortening service built using Node.js, Express, MongoDB, and Mongoose.

Topics

Resources

Stars

Watchers

Forks

Contributors