/URL_Shortener

Takes a url and return the shorten one, keep track of total visits and total clicks

Primary LanguageJavaScript

URL Shortener ๐ŸŒ

A web application that shortens long URLs into compact, easy-to-share links. This project includes user authentication, click tracking, and an admin portal for managing statistics and user roles.

โœจ Features

  • โœ‚๏ธ URL shortening
  • ๐Ÿ› ๏ธ Custom short URL creation
  • ๐Ÿ“Š Click tracking for each shortened URL
  • ๐Ÿ” User authentication and role management
  • โš™๏ธ Admin portal for statistics and user management
  • ๐Ÿ•’ 3-day history retention for URL clicks
  • ๐Ÿ—‘๏ธ Ability to clear history (for users and admins)
  • ๐Ÿงน Admin capability to delete any entry

๐Ÿ› ๏ธ Technologies Used

  • Node.js
  • Express.js
  • MongoDB Atlas
  • EJS (Embedded JavaScript templating)
  • JavaScript
  • CSS
  • JWT for authentication

๐Ÿ“ฆ Dependencies

{
  "dependencies": {
    "cookie-parser": "^1.4.6",
    "dotenv": "^16.4.5",
    "ejs": "^3.1.10",
    "express": "^4.19.2",
    "jsonwebtoken": "^9.0.2",
    "mongoose": "^8.3.0",
    "nodemon": "^3.1.0",
    "shortid": "^2.2.16",
    "sweetalert": "^2.1.2"
  }
}

๐Ÿš€ Installation

  1. Clone the repository.
  2. Run npm install to install dependencies.
  3. Set up your MongoDB Atlas cluster and add the connection string to your .env file.
  4. Run npm start to start the server.

๐Ÿ’ก Usage

  1. Navigate to the homepage.
  2. Enter a long URL in the input field.
  3. Click "Shorten" to generate a short URL.
  4. Copy and share the shortened URL.

๐Ÿ”ง Admin Portal

Access the admin portal to:

  • View overall statistics.
  • Manage user roles.
  • View and delete individual URL entries.
  • Clear history for all users.

โš ๏ธ Disclaimer

The length of the shortened URL ID may vary depending on the domain being used. While we aim for 8-character IDs, the actual length might be different to ensure uniqueness across the system.

๐Ÿค Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.