Skip to content

duyaivy/SHORTEN_URL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— ShortLink – URL Shortening & QR Management Platform

Version Status NodeJS Express TypeScript MongoDB License

A modern, scalable, and secure backend service for URL shortening, QR generation, and link analytics.


🌟 Introduction

ShortLink is a backend API platform that powers the ShortLink web application.
It provides core functionalities such as URL shortening, QR code generation, authentication, and analytics.
Built with Node.js, Express, and TypeScript, it follows a clean modular architecture ensuring scalability, maintainability, and developer productivity.


🧠 Tech Stack

Backend

NodeJS ExpressJS MongoDB JWT AWS S3 QRCode Nodemailer Zod Agenda

DevOps & Tools

Docker Postman ESLint Prettier Husky


βš™οΈ Features

Category Description
πŸ” Authentication Secure login, registration, and token refresh using JWT.
πŸ”— URL Shortening (CRUD) Create, update, retrieve, and delete short URLs with optional password protection.
πŸ“· QR Code Generation Generate downloadable QR codes for shortened URLs using built-in QR utilities.
🧾 QR History Management Track user QR scans and store them with pagination.
πŸ“Š Link Analytics Count and visualize number of visits per alias.
🧠 Rate Limiting Prevent abuse with request throttling.
🧰 Validation Layer Schema validation via Zod and Joi equivalents.
☁️ File & Image Storage AWS S3 integration for uploaded assets.
πŸ“¬ Email Service Nodemailer for password recovery and notifications.
🧱 ServiceResponse Model Standard response structure across APIs.
πŸ›‘οΈ Error Handling Middleware Centralized error management & logging.
🧩 Modular Architecture Each API (auth, user, url) is self-contained for clarity and scalability.

πŸ—οΈ Project Structure

πŸ“¦ shortlink-backend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/                # Authentication (JWT, login/register)
β”‚   β”‚   β”œβ”€β”€ url/                 # URL Shortening & QR
β”‚   β”‚   └── user/                # User management
β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”œβ”€β”€ constant/            # Enums, messages, config
β”‚   β”‚   β”œβ”€β”€ middleware/          # Logger, rateLimiter, errorHandler
β”‚   β”‚   β”œβ”€β”€ models/              # Mongoose models & response objects
β”‚   β”‚   β”œβ”€β”€ services/            # Database & utility services
β”‚   β”‚   └── utils/               # Helper modules (JWT, email, QR, random, etc.)
β”‚   β”œβ”€β”€ server.ts                # Express app setup
β”‚   β”œβ”€β”€ index.ts                 # Entry point
β”‚   └── type.d.ts                # Type declarations
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ .env.example
└── README.md

⚑ Quick Start

# 1. Install dependencies
pnpm install

# 2. Set up environment variables
cp .env.example .env

# 3. Run development server
pnpm dev

# 4. Build production bundle
pnpm build

# 5. Start production server
pnpm start

🧩 API Overview

Method Endpoint Description
POST /auth/register Register new user
POST /auth/login User login
POST /auth/refresh-token Refresh JWT token
GET /auth/forgot-password Send email forgot password
POST /auth/reset-password Reset password
POST /auth/logout Logout to the application
GET /user/get-me Get user information
POST / Create short URL
GET /my-urls Get list user’s URLs
PATCH /:alias Update URL
DELETE /my-urls Delete URL
POST /qr-history Save QR scan history
GET /:alias Resolve short link to destination
... .... And more...

πŸ—οΈ Architecture Overview

ShortLink Backend follows a Layered Architecture for better scalability:

  • Controller Layer β†’ Handles HTTP requests and responses.
  • Service Layer β†’ Core business logic and database operations.
  • Model Layer β†’ Mongoose schemas and document modeling.
  • Middleware Layer β†’ Security, validation, and logging.
  • Utility Layer β†’ Shared helpers (QR, JWT, Email, etc).

πŸ§ͺ Testing

The project supports integration tests with Vitest.

# Run all tests
pnpm test

# Run a specific test
pnpm test src/api/user/__tests__/user.integration.test.ts

πŸ’Ž Author & Contact

πŸ‘¨β€πŸ’» Project: ShortLink
πŸ“§ Contact: shortlink.tool@gmail.com
🌐 Website: https://shortlinkz.online


Made by duyaivy with πŸ’–.

Releases

No releases published

Packages

 
 
 

Contributors