|
Create short URLs with optional custom aliases. Auto-generates 7-character codes or use your own branded link. |
Redis caching delivers sub-millisecond redirects. Rate limiting protects against abuse. |
|
Email + Password with OTP verification. JWT tokens with automatic refresh rotation. Account lockout after 5 failed attempts. |
Track every click. See total links, click counts, and manage your URLs from one dashboard. |
|
Every short link gets a downloadable QR code. Perfect for sharing on print or social media. |
Set links to expire in 1, 7, 30, or 90 days. Expired links automatically return 404. |
src/
├── UrlShortner.Domain/ → Entities & Interfaces
├── UrlShortner.Application/ → Business Logic & Services
├── UrlShortner.Infrastructure/ → Data Access, Redis, Email
└── UrlShortner.Web/ → MVC Controllers & ViewsClean Architecture with 4 layers. Domain knows nothing about databases or UI. Infrastructure implements what Domain defines.
| Layer | Technology |
|---|---|
| Framework | ASP.NET Core MVC (.NET 10) |
| Database | SQL Server + PostgreSQL (dual support) |
| ORM | Dapper |
| Cache | Redis (Upstash) |
| Auth | JWT + Refresh Tokens + OTP |
| MailKit (Brevo/Gmail SMTP) | |
| Frontend | Razor Views + Bootstrap 5 |
| Testing | xUnit + Moq + FluentAssertions |
| Infra | Docker + Railway + Supabase |
# Clone the repo
git clone https://github.com/XPSTARTS/Url-Shortner-MVC.git
cd Url-Shortner-MVC
# Start SQL Server & Redis
docker-compose up -d
# Run database migrations
# Connect to SQL Server and run database/init.sql
# Start the app
dotnet run --project src/UrlShortner.WebOpen https://localhost:7257 in your browser.
💡 OTP codes appear in the console during development. No email setup needed.
Register → Email + Password → OTP → Verify → Account Created
Login → Email + Password → OTP → Verify → JWT + Refresh Token
Request → JWT Cookie → Auto-refresh if expired → Continue- Access Token: 15 minutes (JWT, HTTP-only cookie)
- Refresh Token: 7 days (opaque, stored in DB + Redis)
- OTP: 6 digits, expires in 10 minutes (Redis)
✅ 28 Unit Tests (Services, Validators, Helpers)
✅ 12 Integration Tests (Repositories, Redis, Database)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ 40 Total Tests PassingRun with:
dotnet test| Method | Path | Auth | Description |
|---|---|---|---|
POST | /Url/Create | Optional | Shorten a URL |
GET | /{shortCode} | No | Redirect to original URL |
POST | /Auth/Register | No | Create account |
POST | /Auth/Login | No | Sign in |
POST | /Auth/VerifyOtp | No | Verify OTP |
GET | /Dashboard | JWT | User dashboard |
GET | /Dashboard/Profile | JWT | Profile + stats |
https://url-shortner-mvc-production.up.railway.app
Note: Email delivery is unavailable in the demo. OTP codes are displayed on-screen.
MIT — feel free to use, modify, and learn from this project.

