A full-stack URL Shortener application built with React, Node.js, Express, and MongoDB, featuring user authentication, real-time analytics tracking, customizable link expiry, and a premium interactive WebGL water-ripple glassmorphism user interface.
This project is designed to be highly responsive, modern, and engaging. It includes random background image selections on every page load with interactive water distortion physics that react dynamically to cursor movement.
The application utilizes an interactive WebGL-based water ripple distortion effect.
- Dynamic Physics: When a user moves their mouse over any page, realistic water ripples follow the cursor.
- Randomized Themes: Every time the application is loaded, the frontend randomly selects one of 6 high-definition background images (
img1.jpgtoimg6.jpg) located infrontend/public/bg/, offering a unique aesthetic experience on every visit while keeping the water simulation intact.
- Frosted glass cards with high-contrast elements, neon glowing gradients, and clean layout cards.
- Custom particle trail cursors that track mouse movement.
- Fully responsive styling optimized for mobile, tablet, and desktop layouts.
The development followed a modular, structured AI pair-programming workflow:
- Requirements Analysis & Planning: Mapping the hackathon requirements, user specifications, and technical constraints.
- Database Modeling: Planning schemas for User authentication, URLs, and Analytics event tracking, adding index optimizations.
- Core API Backend: Establishing REST API endpoints for user authentication, URL shortening, redirect handlers, and analytics reporting.
- Interactive UI Foundation: Creating the WebGL Canvas pool and custom CSS design system variables to style pages without generic browser presets.
- Dashboard & Expiry Pickers: Developing components for managing URLs, generating instant copy actions, and implementing collapsible selection controls for custom link lifespans.
- Automation & Cleanup: Building a scheduled cron system to automatically delete expired links or links left inactive for 6 months to optimize database sizing.
- Verification & Refinement: Running builds, checking environment configuration safety, and wiring up permanent account deletion settings.
graph TD
Client[Browser / React Frontend] <-->|REST API / JWT Auth| Server[Node.js / Express Backend]
Client <-->|Short Code Redirect Request| Server
Server <-->|Mongoose ODM| DB[(MongoDB Database)]
Server -.->|Scheduled Task / Daily at 2 AM| Cron[Cleanup Cron Job]
Cron -->|Permanent Cascade Deletions| DB
subgraph MongoDB Collections
Users[users Collection]
URLs[urls Collection]
Analytics[analytics Collection]
end
DB --- Users
DB --- URLs
DB --- Analytics
User Inputs Long URL + Expiry Timer -> Frontend Validates URL Format -> API Requests Backend
-> Backend Generates Unique 6-8 Character Short Code
-> Backend Calculates 'expiresAt' (e.g. Current Time + 5 minutes or 6 months)
-> Saved to MongoDB
Visitor Clicks shortlq.io/abc123 -> Express Route Handles GET /:shortCode
-> Queries URL in MongoDB
-> IF isExpired === true OR (expiresAt exists AND expiresAt < now):
Returns 410 Gone Error page / Informs Visitor Link has expired
-> ELSE:
Increments total clicks count in background
Logs new Analytics event (timestamp, user agent, IP)
Returns HTTP 302 Redirect to the original long destination URL
Runs automatically every day at 2:00 AM to free database storage:
- Expired Links: Searches for URLs where
expiresAt < now. - Inactive Links: Searches for URLs where
lastVisitedis older than 6 months, or if never visited,createdAtis older than 6 months. - Cascade Deletion: Permanently deletes these URL documents and their corresponding click analytics entries to maintain high performance.
Available directly in the Account Settings modal:
- User clicks "Settings" in the authenticated Navbar.
- Enters password and types
DELETEto verify intent. - Backend deletes the User document, and automatically cascade-deletes all associated URLs and their analytics data.
- Authentication:
- Secure user signup and login with hashed passwords.
- JWT-based authorization with protected route guards.
- Strict user ownership (users can only view/delete their own links).
- URL Shortening:
- Input validation (supports only valid URLs starting with
http://orhttps://). - Automatic unique 6-8 character short code generation.
- Server-side redirection with analytics tracking.
- Input validation (supports only valid URLs starting with
- User Dashboard:
- Clean, responsive, full-grid layout.
- Table/Cards showing original URL, short URL, created date, and total clicks.
- Easy copy-to-clipboard action button.
- Quick delete button for URLs.
- Analytics Details:
- Tracks total click counts per URL.
- Records visit timestamps, IP addresses, referrers, and user agents.
- Detailed stats page displaying total clicks, last visited timestamp, and full chronological visit history list.
- Custom Link Expiry: Options from 5 minutes, 1 hour, 1 day, 7 days, 1 month, 3 months, 6 months, to "Never".
- Automated DB Cleanup: Background cron schedule cleaning inactive and expired links.
- Interactive WebGL Visuals: Live water ripple animation running on custom fragment shaders.
- Randomized Themes: Dynamically chooses background image assets on every load.
- Permanent Cascade Account Deletion: Self-service security dashboard allowing full user data wipe.
{
_id: ObjectId,
email: String, // Unique, normalized index
password: String, // Hashed with bcrypt (10 rounds)
createdAt: Date
}{
_id: ObjectId,
userId: ObjectId, // Reference -> User._id (indexed)
originalUrl: String,
shortCode: String, // Unique alphanumeric key (indexed)
createdAt: Date,
clicks: Number,
lastVisited: Date,
expiresAt: Date, // Optional, user-defined limit
isExpired: Boolean // Quick redirect validation flag
}{
_id: ObjectId,
urlId: ObjectId, // Reference -> URL._id (indexed, cascade deleted)
timestamp: Date,
userAgent: String,
referer: String,
ipAddress: String
}- Node.js (v16.x or higher)
- MongoDB (running locally on default port 27017 or a MongoDB Atlas cloud URI)
- npm or yarn package manager
git clone https://github.com/sarthar3/ShortLQ.git
cd ShortLQ- Navigate to the backend directory:
cd backend - Install dependecies:
npm install
- Create a
.envfile by copying the example:cp .env.example .env
- Define your config variables in
.env:PORT=5000 MONGODB_URI=mongodb://localhost:27017/shortlq JWT_SECRET=your_super_secret_jwt_signature_key NODE_ENV=development FRONTEND_URL=http://localhost:5173
- Start the backend development server:
The server runs on
npm run dev
http://localhost:5000.
- Open a new terminal and navigate to the frontend directory:
cd ../frontend - Install dependencies:
npm install
- Create a
.envfile by copying the example:cp .env.example .env
- Configure the API endpoint in
.env:VITE_API_URL=http://localhost:5000
- Start the frontend development server:
The application will open on
npm run dev
http://localhost:5173.
- Users will input valid URLs with protocol headers (
http://orhttps://). If omitted, the app validation flags an instruction to include the protocol. - Short codes should remain simple and alphanumeric for readability.
- Once an account is deleted, the cascade behavior permanently cleans all tracking records to preserve database space. No backup soft-deleting exists.
- Database cleanups run daily at 2:00 AM, using the server host's local timezone.
https://youtu.be/88dAz-sRD54?si=e5CMzxG8lwt41CnT
This project is a part of a hackathon run by https://katomaran.com