Microservice-based URL Shortener

About this Project
A modern Microservice-based URL Shortener built with Next.js, Node.js, Express, Prisma, Neon PostgreSQL, Upstash Redis, and Docker. The architecture focuses on scalability, loose coupling, high performance, and production-ready deployment. Frontend: https://lily-link.vercel.app Repository: https://github.com/meheraj786/microservice-url-link-shortener System-Design(HLD): https://meherajdev.vercel.app/system-designs/design-url-shortner Framework: Next.js 16 (App Router) Styling: Tailwind CSS v4 + HeroUI (formerly NextUI) HTTP Client: Axios with automatic JWT token injection via interceptors Deployment: Vercel (Production Static Optimization) Runtime: Node.js + Express + TypeScript ORM: Prisma (v6 & v7) Database: Neon PostgreSQL user_schema url_schema Caching: Upstash Redis (Serverless Distributed Cache) API Gateway: Dockerized Nginx Reverse Proxy SSL Handshaking Custom CORS Preflight Native Rate Limiting (HTTP 429) Containerization: Docker Optimized Builds: Multi-stage Dockerfiles Local Orchestration: Docker Compose CI/CD: GitHub Actions Deployment Strategy: Backend β Render Frontend β Vercel Secure user registration and login handled by the dedicated user-service. Independent microservices communicate using loose-coupled userId string references without enforcing physical database foreign keys. URL lookups first query Upstash Redis (O(1)), then fall back to PostgreSQL, significantly reducing database load. Single centralized gateway powered by Nginx, hiding downstream services behind one public endpoint. Built-in Nginx rate limiting automatically returns HTTP 429 Too Many Requests during excessive traffic. GitHub Actions deploy only affected applications based on commit prefixes. lily-link/ β βββ .github/ β βββ workflows/ β βββ ci-cd.yml β βββ gateway/ β βββ nginx.conf β βββ Dockerfile β βββ services/ β βββ url-service/ β β βββ src/ β β βββ Dockerfile β β β βββ user-service/ β βββ src/ β βββ Dockerfile β βββ frontend/ β βββ docker-compose.yml β βββ .env.sample Docker Docker Compose Node.js pnpm git clone https://github.com/meheraj786/microservice-url-link-shortener.git cd url-shortener Create a .env file in the project root by following the .env.sample template. docker compose up --build The Nginx API Gateway runs on Port 80. Health Check: curl http://localhost/health Microservice Architecture Dockerized Infrastructure Shared PostgreSQL with Isolated Schemas Distributed Redis Cache Centralized API Gateway JWT Authentication Conditional GitHub Actions CI/CD Production Ready Deployment Loose Coupling Between Services JWT Authentication Secure Password Hashing Nginx Rate Limiting Custom CORS Handling Reverse Proxy Isolation Environment Variable Configuration Meheraj Hosen GitHub: https://github.com/meheraj786 This project is licensed under the MIT License.π Live Demo
π οΈ Tech Stack
Frontend (User Interface)
Backend (Microservices Core)
Infrastructure & DevOps
β¨ Features
π JWT Authentication
π Logical Foreign Keys
β‘ Distributed Caching
π API Gateway
π‘οΈ DDoS Protection
π Monorepo CI/CD
π Project Structure
π Local Development
Prerequisites
1οΈβ£ Clone the Repository
2οΈβ£ Configure Environment Variables
3οΈβ£ Start All Services
4οΈβ£ Verify API Gateway
π¦ Microservices
βοΈ Architecture Highlights
π‘οΈ Security
π Deployment
π¨βπ» Author
π License