A minimalist and fast URL shortener built with Go, Redis, and PostgreSQL. PicoURL focuses on speed, simplicity, and smart caching, providing instant redirects, rate-limited endpoints, and basic analytics.
- Minimalist Design 🎨
- Clean, lightweight UI with zero clutter.
- Instant Shortening ⚡️
- Create short URLs in milliseconds using a compact Base62 ID generator.
- Smart Caching 🧠
- Redis-powered caching for fast redirects and statistics.
- Cache Stampede Protection using the
singleflightpattern to prevent database overload under heavy load. - Includes negative caching to avoid lookups for non-existent links.
- QR Code Generation 📲
- Instantly generate and display a QR code for any shortened URL.
- Automatic Database Maintenance 🧹
- A background worker runs daily to automatically delete click data older than 7 days, keeping the database lean and performant.
- Accurate Statistics 📊
- Referrer analytics for the last 7 days.
- Rate Limiting 🚦
- Protects the API from abuse using a Redis-backed distributed rate limiter.
Frontend:
- React: For building the user interface.
- Tailwind CSS: Utility-first styling for rapid development.
- TypeScript: Type safety and better developer experience.
- Chart.js + react-chartjs-2: For analytics visualization.
- Axios: HTTP requests.
- Nuqs: Lightweight in-url state management.
Backend:
- Go: High-performance API server.
- Gin: Minimalistic HTTP framework.
- pgx + sqlc: Safe, low-level PostgreSQL queries.
- PostgreSQL: Reliable, production-grade database.
- Redis: Caching & rate limiting.
- singleflight: Cache stampede protection.
- golang-migrate: Schema migrations.
DevOps & Testing:
- Docker & Docker Compose: Containerization and orchestration.
- Taskfile: Developer workflow automation.
- Shorten a URL
- Enter a long URL and get a short, compact link instantly.
- Redirect
- Visiting /abc123 immediately resolves to the original target URL. Popular links and statistics are cached in redis.
- Get a QR Code
- Instantly view and use the QR code for your new short URL.
- View Statistics
- View the number of clicks by referrers.
- Rate Limiting
- Every endpoint is automatically protected.
To quickly get a demo of the application up and running, you can use the provided npm scripts.
Prerequisites:
- You must have Docker installed.
Commands:
-
To start the demo environment:
pnpm run demo:start
This will build and start the necessary services in detached mode.
-
To stop the demo environment:
pnpm run demo:stop
This will stop the running containers.
This project is licensed under the MIT License - see the LICENSE file for details.
