Skip to content

Repository files navigation

URL shortener

URL shortener backend built in Go with a PostgreSQL backend and Redis for caching
Example deployment with a simple frontend available at personal.davidenberg.fi/url-shortener

Key Features

  1. Cache-Aside Pattern for managing data caching between Redis and PostgreSQL
  2. Async Analytics via Goroutines to offload analytics tracking from request handling
  3. Docker-compose for setting up entire stack

Tech Stack

  • Backend: Go (Standard library + pgx PostgreSQL driver and Go-Redis)
  • Database: PostgreSQL + Redis
  • Orchestration Docker, Docker Compose

Quick Start

  1. Clone the repository
git clone https://github.com/davidenberg/URL-shortener.git
  1. Build and run the stack
docker compose up --build

API Endpoints

POST /urls
Generates a unique 8-character identifier for the URL
Request body:

{
  "original_url": "https://www.google.com"
}

Success response:

{
  "short_url": "<domain>/urls/:identifier"
}

GET /urls/:identifier
Success Response: 302 Found

Get /urls/stats/:identifier

{
  "creation_time": Timestamp,
  "hits": <Number of hits>
}

System design

System design of the URL shortener

License

MIT

About

URL shortener backend built in GO with PostgreSQL backend

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages