A scalable, microservice-based URL shortener built with Go, React, Postgres, and Redis — designed to run seamlessly in both Docker Compose (local dev) and Kubernetes (scalable deployments).
| Service | Description |
|---|---|
| Gateway | The single entrypoint to all APIs. Validates JWTs, routes requests to backend services (Auth, CRUD, Redirect). |
| Auth Service | Manages signup/login. Issues JWTs and stores users in Postgres. |
| CRUD Service | Handles URL creation, deletion, and stats for logged-in users. Uses Postgres for persistence. |
| Redirect Service | Public endpoint /:code. Redirects short links via Redis (cache) → Postgres (fallback). |
| Job Runner | Periodically syncs hit counters from Redis → Postgres. |
| Frontend (React + Nginx) | User-facing dashboard and authentication UI. Proxies API + short URLs through the Gateway. |
| Postgres | Primary database for users and URLs. |
| Redis | High-speed cache for redirects and hit counts. |
- Go 1.21 (Gin / Fiber)
- React + Vite + Nginx
- Postgres 15
- Redis 7
- Docker Compose (development)
- Kubernetes (Minikube) (scalable deployment)
- JWT Authentication
CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
role TEXT DEFAULT 'user',
created_at TIMESTAMPTZ DEFAULT now()
);CREATE TABLE IF NOT EXISTS urls (
short_code TEXT PRIMARY KEY,
long_url TEXT NOT NULL,
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT now(),
expiration_at TIMESTAMPTZ,
hits BIGINT DEFAULT 0
);git clone https://github.com/yourname/go-url.git
cd go-urldocker-compose up --build| Service | URL |
|---|---|
| Frontend | http://localhost:5173 |
| Gateway | http://localhost:8080 |
| Auth | http://localhost:8081 |
| CRUD | http://localhost:8082 |
| Redirect | http://localhost:8083 |
minikube start --driver=docker./deploy-to-minikube.shThis script:
- Cleans the previous namespace (
go-url) - Rebuilds all service images inside Minikube
- Applies all manifests in
k8s/ - Waits for all pods to be ready
- Optionally port-forwards services to localhost
| Component | URL |
|---|---|
| Frontend | http://go-url.local (NodePort: 30080) |
| Gateway API | http://go-url.local/api (NodePort: 30081, proxied internally via Nginx) |
kubectl scale deploy crud --replicas=3 -n go-url
kubectl get pods -n go-urlYou'll see multiple CRUD pods handling traffic in parallel.
| Endpoint | Method | Description |
|---|---|---|
/auth/signup |
POST | Register a new user |
/auth/login |
POST | Login, returns JWT |
/auth/me |
GET | Current user (requires JWT) |
/shorten |
POST | Create a short URL (requires JWT) |
/shorten/:id |
DELETE | Delete a short URL (requires JWT) |
/shorten/:id/stats |
GET | URL stats (requires JWT) |
/:code |
GET | Redirect to original long URL |
- Runs periodically
- Syncs
hits:*keys from Redis → Postgres - Resets Redis counters post-sync
Built with Vite + Plain CSS (Dark theme).
Communicates with Gateway via internal Nginx reverse proxy.
- ✅ Signup/Login forms with validation
- ✅ JWT-based session handling
- ✅ Dashboard to create/delete short URLs
- ✅ URL stats (hits, creation date, expiry)
- ✅ Confirmation modal for deletes
- 🧩 Microservice isolation — each service can scale independently via
kubectl scale - 🔁 Kubernetes-native scaling — stateless services (Gateway, CRUD, Redirect) are horizontally scalable
- 🧠 Caching with Redis — offloads redirect lookups
- 🗄️ Persistent storage — Postgres backed by Kubernetes volumes
- 🔒 JWT Security — Gateway enforces user auth for all protected routes
- 🌍 Nginx Frontend Proxy — seamless redirects + unified domain for FE + API
MIT License © 2025 Satyam Shree
Built with ❤️ using Go, React, and Kubernetes