- 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.
Never installed a project from a GitHub repository before, but don't want to miss out on the latest tech trends? Fear no more.
1. Clone repository to your prefered destination
# Change directory to prefered destination.
git clone https://github.com/your-username/rshrtly.git
cd rshrtly2. 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_name4. 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 devThe console will output where the development server is running.
By default, it is set to http://localhost:3030.
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
http://localhost:3030
Redirects user to the long URL stored by the short URL.
{
"shortUrl" : "rshrtly.io/*"
}Returns shortened URL based on long URL provided by user's input.
{
"longUrl" : "http://www.long-link-example.com/*"
}{
"shortUrl": "https://www.rshrtly.io/8-character-hash",
"creationTime": "2025-07-10T12:00:00Z",
"timesClicked": 0
}{
"error" : "❌ Error encoding your url."
}List all user's generated hashes
{
"generated_hashes": ["hash_1", "hash_2", "...", "hash_n"]
}