Skip to content

Latest commit

ย 

History

History
137 lines (91 loc) ยท 2.11 KB

File metadata and controls

137 lines (91 loc) ยท 2.11 KB

๐Ÿ”— URL Shortener

A simple URL Shortener web application built using Node.js, Express, MongoDB, and EJS. It allows users to shorten long URLs and track visit history.


๐Ÿš€ Features

  • ๐Ÿ”— Generate short URLs
  • ๐Ÿ“Š Track number of clicks
  • ๐ŸŒ Redirect to original URL
  • ๐Ÿ“„ View all shortened URLs in a table
  • โšก Fast and simple UI using EJS

๐Ÿ› ๏ธ Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB
  • Templating Engine: EJS
  • Other: Mongoose, NanoID

๐Ÿ“ Project Structure

URL_shortner/
โ”‚
โ”œโ”€โ”€ controllers/
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ routes/
โ”œโ”€โ”€ views/
โ”œโ”€โ”€ connections/
โ”œโ”€โ”€ index.js
โ”œโ”€โ”€ package.json

โš™๏ธ Installation & Setup

1๏ธโƒฃ Clone the repository

git clone https://github.com/your-username/url-shortener.git
cd url-shortener

2๏ธโƒฃ Install dependencies

npm install

3๏ธโƒฃ Start MongoDB

Make sure MongoDB is running locally:

mongodb://localhost:27017/short-url

4๏ธโƒฃ Run the server

node index.js

5๏ธโƒฃ Open in browser

http://localhost:5001/

๐Ÿ“Œ API Routes

Method Route Description
POST /url Create short URL
GET /url/:shortId Redirect to original URL
GET /url/analytics/:shortId Get analytics

๐Ÿ“ธ How It Works

  1. Enter a long URL
  2. Click Generate
  3. Get a short URL
  4. Click short URL โ†’ redirected
  5. Visit count increases

๐Ÿง  Learning Outcomes

  • Express routing & middleware
  • MongoDB with Mongoose
  • MVC structure
  • Server-side rendering with EJS
  • REST API design

๐Ÿ”ฎ Future Improvements

  • ๐Ÿ”˜ Copy to clipboard button
  • ๐Ÿ“Š Advanced analytics (graphs)
  • ๐Ÿ” User authentication
  • ๐ŸŒ Deploy to cloud (Render / Vercel / AWS)
  • โš›๏ธ React frontend

๐Ÿค Contributing

Feel free to fork this repo and improve it!


๐Ÿ‘จโ€๐Ÿ’ป Author

Garv Saxena