Skip to content

A URL Shortener Service created using Node.js and MongoDB 🔗

Notifications You must be signed in to change notification settings

McTechie/node-url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener Service (Node.js)

This is a simple example of a URL shortener service created using Express.js, for the purpose of learning.

Architecture

Generate Short URL

sequenceDiagram
    autonumber
    actor Browser Client as User

    Browser Client->>URL Shortener Service: /url

    Note over Browser Client, URL Shortener Service: https://mctechie.vercel.app
    
    rect rgb(127, 12, 232)
        URL Shortener Service-->>URL Shortener Service: Create a `shortID`
        URL Shortener Service-->>MongoDB: Create a URL Document
        MongoDB-->>URL Shortener Service: URL Document
        URL Shortener Service->>Browser Client: Respond with  shortID
    end

    Note over Browser Client, URL Shortener Service: { shortID: agEH-jvH }
Loading

Redirect to Original URL

sequenceDiagram
    autonumber
    actor Browser Client as User
    Browser Client->>URL Shortener Service: /url/:shortID

    Note over Browser Client, URL Shortener Service: /url/agEH-jvH

    rect rgb(0, 100, 0)
        URL Shortener Service-->>MongoDB: Find URL Document
        MongoDB-->>URL Shortener Service: URL Document
        URL Shortener Service->>Browser Client: Redirect to URL
    end

    Note over Browser Client, URL Shortener Service: https://mctechie.vercel.app
Loading

Analytics

sequenceDiagram
    autonumber
    actor Browser Client as User

    Browser Client->>URL Shortener Service: /url/analytics/:shortID

    Note over Browser Client, URL Shortener Service: /url/analytics/agEH-jvH
    
    rect rgb(127, 12, 232)
        URL Shortener Service-->>MongoDB: Find URL Document
        MongoDB-->>URL Shortener Service: URL Document
        URL Shortener Service->>Browser Client: Send Analytics Data
    end

    Note over Browser Client, URL Shortener Service: Visit History, Number of Clicks, etc.
Loading

How to run

This project requires Node.js to run.

# Clone the repository
git clone https://github.com/McTechie/node-url-shortener.git

# Change directory
cd node-url-shortener

# Install dependencies
npm install

# Run the server
npm start

Demo

Client 1

Client 1

Client 2

Client 2

MongoDB

MongoDB

Analytics

Analytics

About

A URL Shortener Service created using Node.js and MongoDB 🔗

Topics

Resources

Stars

Watchers

Forks