.NET 9 URL Shortener API (Clean Architecture + CQRS)
Build and ship a blazing-fast URL shortener in minutes—not weeks.
This .NET 9 backend follows Clean Architecture + CQRS so you can scale safely, keep your codebase maintainable, and plug in new integrations without breaking core logic.
Why this API?
- Minimal APIs → tiny overhead, big performance.
- Base62 encoding → short, URL-safe codes that look clean and professional.
- Redis caching → instant redirects and drastically fewer DB round-trips.
- Built-in analytics → log IP, User-Agent, Referrer for every click.
- Docker-ready → run anywhere in minutes.
- FluentValidation → strict URL & custom-code rules out of the box.
- Swagger/OpenAPI → explore & test endpoints instantly.
- Swappable storage → start with SQLite, switch to PostgreSQL/SQL Server when you need it.
- MIT License → use it in personal, commercial, or educational projects.
Perfect for
- Developers embedding a reliable short-link service into existing apps.
- Engineering teams managing internal knowledge, campaigns, or partner links.
- Startups launching a SaaS with click-tracking and clean, maintainable code.
What’s inside
- Full source code with Domain / Application / Infrastructure / API layers
- CQRS with clear command/query boundaries
- Base62 generator + validation rules
- Click logging (IP, user-agent, referrer)
- Dockerfile + ready-to-run compose
- appsettings examples for SQLite/PostgreSQL/SQL Server
- Swagger/OpenAPI docs
Tech stack
.NET 9, Minimal APIs, CQRS, Clean Architecture, EF Core, Redis, FluentValidation, Swagger/OpenAPI, Docker.
Requirements
- .NET 9 SDK
- Docker (optional but recommended)
- Redis (for caching)
- SQLite/PostgreSQL/SQL Server (pick your flavor)
FAQ
Can I change the database later?
Yes. Start with SQLite for speed; move to PostgreSQL or SQL Server with minor config changes.
Does it track unique users?
You get raw signals (IP, user-agent, referrer). You can extend with your own unique-user logic or analytics pipeline.
Is it production-ready?
Yes—clean layering, validation, caching, Dockerization, and MIT licensing. Add your infra (HTTPS, reverse proxy, observability) and deploy.
License
MIT—commercial use allowed.
Production-ready Minimal API with Redis caching, Base62, and click analytics. Dockerized. MIT licensed.