A high-performance, full-stack URL shortening application to handle scalable link generation, secure redirection, and real-time click tracking.
Built with a focus on robust architecture and strict API security, this application actively mitigates DoS vulnerabilities through a custom-built, in-memory rate-limiting engine.
You can choose either a manual setup or use Docker for a one-command deployment.
Ensure you have Node.js installed.
Terminal 1: Backend
cd backend
npm install
npm run devTerminal 2: Frontend
cd frontend
npm install
npm run devThe application will be accessible at http://localhost:5173.
To spin up the entire infrastructure concurrently:
docker-compose up --buildThe system implements a Sliding Window Log algorithm to manage request frequency by IP address without relying on external dependencies like Redis.
- Request Tracking: For every incoming request, the middleware retrieves a list of previous request timestamps associated with the user's IP from an in-memory
Map. - Window Pruning: It automatically filters out (prunes) any timestamps older than the defined window (e.g., 60 seconds).
- Threshold Validation: If the remaining count of valid timestamps exceeds the allowed limit (e.g., 5 requests per minute), the request is rejected with a
429 Too Many Requestsstatus. - Retry Calculation: Unlike fixed-window counters, this logic calculates the exact time until the oldest request in the window expires, providing the client with a precise
retryAftervalue. - Memory Efficiency: Stale data is cleared on every request, ensuring the memory footprint remains minimal even under high traffic.
.
├── backend/ # Express API & SQLite Data Logic
│ └── middleware/ # Includes the custom rateLimiter logic
├── frontend/ # React Dashboard & Analytics Charting
├── docker-compose.yml # Container orchestration
└── README.md # This file
- Deterministic Redirection: Sub-millisecond URL resolution using indexed SQLite lookups.
- Real-time Analytics: Visualizes click trends over the last 7 days using Chart.js.
- Self-Healing UI: Frontend handles rate-limit cooldowns gracefully with countdown timers.
- Production Ready: Fully containerized with Docker for consistent environment deployment.