Skip to content

Latest commit

 

History

History
96 lines (63 loc) · 2.04 KB

File metadata and controls

96 lines (63 loc) · 2.04 KB

Simple URL Shortener

This project is a Simple URL Shortener developed as part of the CodeAlpha Backend Development Internship.

The application takes a long URL from the user, generates a short and unique URL, stores the mapping in a MongoDB database, and redirects users to the original URL when the short link is accessed.


What the project does

  • Generates short URLs for long links
  • Redirects short URLs to the original website
  • Stores URLs in MongoDB
  • Avoids duplicate entries for the same URL
  • Validates incorrect or empty input
  • Shows user-friendly error messages
  • Includes a simple and aesthetic frontend interface

Technologies used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • HTML, CSS, and JavaScript

Project structure

CodeAlpha_URL_Shortener
src

  • config (database connection)
  • models (MongoDB schemas)
  • controllers (application logic)
  • routes (API routes)
  • app.js

public (frontend files)
server.js (server entry point)
.env (environment variables)
README.md


API endpoints

POST /shorten
This endpoint accepts a long URL and returns a shortened URL.

Example request body: originalUrl: https://example.com

GET /:shortCode
This endpoint redirects the user to the original URL associated with the short code.


How to run the project locally

  1. Clone the repository
    git clone https://github.com/your-username/CodeAlpha_URL_Shortener.git

  2. Navigate to the project folder
    cd CodeAlpha_URL_Shortener

  3. Install dependencies
    npm install

  4. Create a .env file and add your MongoDB connection string
    MONGO_URI=your_mongodb_connection_string

  5. Start the server
    node server.js

  6. Open your browser and visit
    http://localhost:5000


Internship information

Organization: CodeAlpha
Domain: Backend Development
Task: Simple URL Shortener


Learning outcomes

This project helped me strengthen my understanding of backend development, REST API design, MongoDB integration, input validation, error handling, and writing clean, structured code.

Thank you for reviewing my project.