Skip to content

This is a url shortener: A capstone project carried out in AltSchool Africa

Notifications You must be signed in to change notification settings

adeyinkaoresanya/scissor

Repository files navigation

Scissor

This is a fast and simple URL shortener built as a capstone project from AltSchool Africa.

Product Requirements

  1. Scisor allows users to shorten URLs by pasting a long URL into the Scissor platform and a shorter URL gets automatically generated. The shortened URL must be designed to be as short as possible, making it easy to share on social media or through other channels.

  2. Scissor allows users to also generate and QR codes for the shortened URLs. Users can download the QR code image and use it in their promotional materials or/and on their website. This feature will be implemented using a third-party QR code generator API, which can be integrated into the Scissor platform.

  3. Scissor provides basic analytics that allow users to track their shortened URL's performance. Users can see how many clicks their shortened URL has received and where the clicks are coming from. We need to track when a URL is used.

  4. Scissor allows users to see the history of links they have created so they can easily find and reuse links they have previously created.

  5. The URL should be validated before creating a shortened version of it so as to prevent broken links.

  6. A cache-layer must be implemented to prevent hitting the DB always.

  7. Rate limiting must be implemented

  8. Unit and integration tests should be conducted where possible

  9. Spec and document the API with OpenAPI using https://stoplight.io/

Set up

  • Install Node.js, MongoDB, redis
  • Install project dependencies
  • clone this repo
  • update env with example.env
  • run npm run start:dev

How to clone this repo

git clone https://github.com/adeyinkaoresanya/scissor.git

Install project dependencies

npm install

Update .env with example.env

Run a development server

npm run start:dev

Models


User

field data_type constraints
name string required
email string required
password string optional
createdAt date

Url

field data_type constraints
urlId string required
origUrl string required
shortUrl string required
clicks number required, default: 0
date date
QRString string required
user ref - User required

Usage

Creating a user

  • Route: /register
  • Method: POST
  • Body
{
"name": "Jane",
"email": "[email protected]",
"password": "Janebakes236!"

}

Response

{"name":"Jane", 
"email":"[email protected]"}

Logging in

  • Route: /login
  • Method: POST

Body

{
"email": "[email protected]",
"password": "Janebakes236!"
}

Response

{
  "email": "[email protected]",
  "token": { token }
}

Create a short Url

  • Route: /create
  • Method: POST
  • response cookies {token}

Request [Body]

{
 "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/"}

Response

{
"urlId": "jxPhc",
"user": new ObjectId("64a2ae1043ef0a3eb98bf6d2"),
"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",
"shortUrl": "https://scissor-v4pd.onrender.com/by-user/jxPhc",
"clicks": 0,
"date": "03-Jul-2023",
"QRString": "data:image/png;base64,..."
}

get all urls shortened by user

  • Route: /by-user
  • Method: GET
  • response cookies {token}

Response

{ 
"urlId": "jxPhc",
"user": new ObjectId("64a2ae1043ef0a3eb98bf6d2"),
"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",
"shortUrl": "https://scissor-v4pd.onrender.com/by-user/jxPhc",
"clicks": 0,
"date": "03-Jul-2023",
"QRString": "data:image/png;base64,..."
}
  

redirect shortened url

  • Route: /by-user/:id
  • Method: GET
  • response cookies {token}

Response

{"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",

}
  

get QR Code of a shortened url

  • Route: /ScanQRCode/:id
  • Method: GET
  • response cookies {token}

Response

{
 
"QRString": "data:image/png;base64,..."
}
  

Contributor

  • Adeyinka Oresanya

About

This is a url shortener: A capstone project carried out in AltSchool Africa

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published