Skip to content

Shobhit150/url_shortner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— URL Shortener (Scalable & Zero-Tolerance)

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.


πŸ“ˆ Flow Chart

Flow Chart


πŸ’» Commads to run

Build App

docker compose up --build

Access Postgres

docker compose exec db psql -U user -d urlshortener

Access Redis

docker compose exec redis redis-cli

πŸš€ Features

  • 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.

🧱 Project Structure

 

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



βš™οΈ Tech Stack

  • Language: Go
  • Database: PostgreSQL
  • Cache: Redis
  • Containerization: Docker
  • API: REST (option to switch to gRPC)
  • Queue: Kafka/NATS for analytics

About

πŸ”— Scalable URL shortener with Go, Redis, PostgreSQL, Kafka & NextJS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published