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.
- 🔗 Generate short URLs
- 📊 Track number of clicks
- 🌐 Redirect to original URL
- 📄 View all shortened URLs in a table
- ⚡ Fast and simple UI using EJS
- Backend: Node.js, Express.js
- Database: MongoDB
- Templating Engine: EJS
- Other: Mongoose, NanoID
URL_shortner/
│
├── controllers/
├── models/
├── routes/
├── views/
├── connections/
├── index.js
├── package.json
git clone https://github.com/your-username/url-shortener.git
cd url-shortenernpm installMake sure MongoDB is running locally:
mongodb://localhost:27017/short-urlnode index.jshttp://localhost:5001/
| Method | Route | Description |
|---|---|---|
| POST | /url |
Create short URL |
| GET | /url/:shortId |
Redirect to original URL |
| GET | /url/analytics/:shortId |
Get analytics |
- Enter a long URL
- Click Generate
- Get a short URL
- Click short URL → redirected
- Visit count increases
- Express routing & middleware
- MongoDB with Mongoose
- MVC structure
- Server-side rendering with EJS
- REST API design
- 🔘 Copy to clipboard button
- 📊 Advanced analytics (graphs)
- 🔐 User authentication
- 🌍 Deploy to cloud (Render / Vercel / AWS)
- ⚛️ React frontend
Feel free to fork this repo and improve it!
Garv Saxena