Skip to content

swag-source/rshrtly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Rshrtly - A Fast & Secure URL shortener service (In-Dev)

  • User Interactivity: Provide the user an interactive interface to generate, access and short URLs information.
  • Colission Minimization: SHA-256 + Entropy encoding algorithm based on NodeJS Crypto library ensure URLs colission minimization.
  • Click Analytics: Real time metrics on link engagement and expiration.
  • Input validation: Automatic URL correctness verification.
  • Security First - Parameterized queries prevent SQL injection on database requests.

🛠️ Implementation Stack

  • Frontend: Next.js

  • Backend: NodeJS - Express.js - TypeScript - MySQL

  • Architecture: RESTful.

⚙️ Installation

For beginners

Never installed a project from a GitHub repository before, but don't want to miss out on the latest tech trends? Fear no more.

For Developers

1. Clone repository to your prefered destination

  # Change directory to prefered destination.
  git clone https://github.com/your-username/rshrtly.git
  cd rshrtly

2. Install project dependencies

  npm install  

3.Set up environment variables. Create a .env file in the root directory:

  PORT=3030
  WEBDOMAIN=http://localhost:3030

  # Database Credentials
  DB_HOST=localhost
  DB_USER=your_username
  DB_PASSWORD=your_password
  DB_NAME=your_db_name

4. Set up database to access & store URLs

CREATE DATABASE your_db_name;
USE your_db_name;

CREATE TABLE urls (
    id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
    long_url VARCHAR(2048) NOT NULL,
    url_hash VARCHAR(8) NOT NULL UNIQUE,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    times_clicked INTEGER DEFAULT 0,
);

5. Start the development server

  npm run dev

The console will output where the development server is running. By default, it is set to http://localhost:3030.

📁 Project Structure

rshrtly/
└── Backend
|  ├── src/
|  │   ├── server.ts              # Main application entry point
|  │   ├── controllers/
|  │   │   ├── redirectController.ts      # Endpoint short URL redirection
|  │   │   └── shortenerController.ts     # Endpoint short URL generation
|  |   ├── helper/
|  │   │   ├── generateHash.ts    # Hash generation algorithm
|  │   │   └── validateUrl.ts     # URL validation
|  │   ├── types/
|  │   │   └── response.ts        # TypeScript interfaces
|  │   └── utils/
|  │       └── db.ts              # Database connection and queries
|  ├── .env                       # Environment variables
|  ├── package.json
|  ├── tsconfig.json
└── Frontend
└── README.md

Base URL

http://localhost:3030

🎯 API endpoints (V.1)

GET /:hash

Redirects user to the long URL stored by the short URL.

Example request:

{
    "shortUrl" : "rshrtly.io/*" 
}

POST /url/shorten

Returns shortened URL based on long URL provided by user's input.

Example request:

{
    "longUrl" : "http://www.long-link-example.com/*"
}

Example response (200): Correctly created

{
    "shortUrl": "https://www.rshrtly.io/8-character-hash",
    "creationTime": "2025-07-10T12:00:00Z",
    "timesClicked": 0
}

Example response (500): Error encoding

{
    "error" : "❌ Error encoding your url."
}

GET /url/list

List all user's generated hashes

Example response (200): Correctly returned

{
    "generated_hashes": ["hash_1", "hash_2", "...", "hash_n"]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors