A secure and reliable full-stack web application to shorten long URLs and manage them with user authentication and session-based access.
- 🔗 Shorten any valid URL
- 🔐 User authentication with sessions (Login/Register/Logout)
- 👤 Authenticated dashboard to manage your short URLs
- 📊 Track the number of clicks on each URL
- 🧠 Middleware-based custom authentication system
- 🖥️ Simple, clean UI with EJS templates and CSS
| Layer | Technology |
|---|---|
| Frontend | HTML, CSS, EJS |
| Backend | Node.js, Express.js |
| Database | MongoDB, Mongoose |
| Auth | Sessions + Middleware |
project-root/ │ ├── models/ # Mongoose schemas (User, URL) |── controllers/ # functions of routes ├── routes/ # Express routes (auth, urls, etc.) ├── views/ # EJS templates (home, login, dashboard, about) ├── public/css/ # Static CSS styling ├── middleware/ # Custom authentication middleware ├── connection.js ├── /service # hashmap to get and set id ├── index.js # Main server file └── README.md # Project documentation
- Clone the repository
git clone https://github.com/yourusername/url-shortener.git cd url-shortener - Install dependencies (npm install)
- Start server (node index.js)
This app uses custom session-based authentication:
- Passwords are securely hashed using
bcrypt. - Sessions are managed using
express-sessionwith a MongoDB store. - Custom middleware protects routes (e.g., dashboard, URL management).
- Clone the repo
git clone https://github.com/your-username/url-shortener.git
cd url-shortener
Install dependencies
npm install
npm start