This is a simple example of a URL shortener service created using Express.js, for the purpose of learning.
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 }
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
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.
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