A highly scalable, zero-tolerance URL shortener built with Go, PostgreSQL, and Redis. Designed to be production-ready with support for fault tolerance, high availability, and extensibility.
docker compose up --builddocker compose exec db psql -U user -d urlshortenerdocker compose exec redis redis-cli- Convert long URLs to short, unique slugs
- Fast redirection using Redis cache
- Unique slug generation with collision handling
- No data loss (strong DB consistency)
- Rate-limiting and retries
- Ready for containerization and cloud deployment
- Extendable for analytics, expiry, QR codes, etc.
url_shortner/ β βββ backend/ # Go backend for URL shortening service β βββ cmd/ β β βββ server/ β β βββ main.go # Entry point: server initialization β βββ internal/ # Application core components β β βββ cache/ # Caching logic (Redis) β β βββ handle/ # HTTP request handlers (Gin) β β βββ kafka/ # Kafka integration for event streaming β β βββ middleware/ # Middleware components for HTTP requests β β βββ repository/ # Database interaction layer (Postgres) β β βββ service/ # Business logic and service layer β β βββ utils/ # Utility/helper functions β βββ proto/ β β βββ urlshortener.proto # gRPC definitions for URL shortening service β βββ dockerfile # Dockerfile to containerize backend service β βββ go.mod # Go module dependencies β βββ go.sum # Dependency checksums β βββ frontend/ # Next.js frontend application β βββ app/ β β βββ global.css # Global CSS styling β β βββ layout.tsx # Application layout component β β βββ page.tsx # Main landing page β βββ components/ β βββ magicui/ # Custom UI components β βββ AnalyticsViewer.tsx # Component for viewing analytics β βββ Shorten.tsx # URL shortening component β βββ docker-compose.yml # Docker Compose configuration for easy setup βββ README.md # Project overview and setup instructions
- Language: Go
- Database: PostgreSQL
- Cache: Redis
- Containerization: Docker
- API: REST (option to switch to gRPC)
- Queue: Kafka/NATS for analytics