A backend service that creates short URLs and redirects them to their original destination.
The project is built to demonstrate common backend engineering patterns such as caching, background job processing, rate limiting, and containerized infrastructure.
More detailed design explanations are available in the docs/architecture.md document.
The system runs as multiple containers:
- FastAPI API service
- PostgreSQL database
- Redis for caching and queues
- RQ worker for background jobs
- Prometheus for metrics
- Grafana for visualization
Docker Compose is used to run the entire stack locally.
Backend
- Python
- FastAPI
- SQLAlchemy
Infrastructure
- PostgreSQL
- Redis
- RQ (Redis Queue)
- Docker / Docker Compose
- Prometheus
- Grafana
- URL shortening API
- Redis caching for fast redirects
- Redis-based rate limiting
- asynchronous analytics processing with background workers
- Prometheus metrics
- containerized architecture using Docker
| Method | Endpoint | Description |
|---|---|---|
| POST | /shorten | create short URL |
| GET | /url/{short_code} | redirect to original URL |
| GET | /url/stats/{short_code} | retrieve analytics |
| GET | /health | system health check |
| GET | /metrics | Prometheus metrics |
Interactive API docs are available at:
http://localhost:8000/docs
Requirements:
- Docker
- Docker Compose
Start the system:
docker compose up --build
Services started:
url_shortener_api
url_shortener_worker
url_shortener_postgres
url_shortener_redis
url_shortener_prometheus
url_shortener_grafana
Metrics are exposed by the API at:
/metrics
Prometheus scrapes the API periodically to collect operational metrics.
Grafana can be used to visualize request traffic, cache performance, and latency.
Grafana UI: http://localhost:3000
Prometheus UI: http://localhost:9090
Create a short URL
POST /shorten
{
"original_url": "https://google.com"
}
Response
{
"short_url": "http://localhost:8000/url/a1B"
}
Detailed system design and implementation notes:
This project demonstrates backend engineering concepts such as:
- API design
- caching strategies
- asynchronous background processing
- rate limiting
- containerized service architecture
- observability with metrics and dashboards
- load testing and performance analysis
