Skip to content

Repository files navigation

🔗 URL Shortner

.NET 10 SQL Server Redis Docker Railway Tests License

A production-ready URL shortener with analytics, built with Clean Architecture


URL Shortner Landing

📸 Preview

Dashboard Result Page

✨ Features

🔗 URL Shortening

Create short URLs with optional custom aliases. Auto-generates 7-character codes or use your own branded link.

⚡ Lightning Fast

Redis caching delivers sub-millisecond redirects. Rate limiting protects against abuse.

🔐 Secure Auth

Email + Password with OTP verification. JWT tokens with automatic refresh rotation. Account lockout after 5 failed attempts.

📊 Analytics Dashboard

Track every click. See total links, click counts, and manage your URLs from one dashboard.

📱 QR Codes

Every short link gets a downloadable QR code. Perfect for sharing on print or social media.

⏱ URL Expiry

Set links to expire in 1, 7, 30, or 90 days. Expired links automatically return 404.


🏗️ Architecture

src/
├── UrlShortner.Domain/          → Entities & Interfaces
├── UrlShortner.Application/     → Business Logic & Services  
├── UrlShortner.Infrastructure/  → Data Access, Redis, Email
└── UrlShortner.Web/            → MVC Controllers & Views

Clean Architecture with 4 layers. Domain knows nothing about databases or UI. Infrastructure implements what Domain defines.


🛠️ Tech Stack

LayerTechnology
FrameworkASP.NET Core MVC (.NET 10)
DatabaseSQL Server + PostgreSQL (dual support)
ORMDapper
CacheRedis (Upstash)
AuthJWT + Refresh Tokens + OTP
EmailMailKit (Brevo/Gmail SMTP)
FrontendRazor Views + Bootstrap 5
TestingxUnit + Moq + FluentAssertions
InfraDocker + Railway + Supabase

🚀 Quick Start

# 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.Web

Open https://localhost:7257 in your browser.

💡 OTP codes appear in the console during development. No email setup needed.

🔐 Authentication Flow

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)

📊 Tests

✅ 28 Unit Tests (Services, Validators, Helpers)
✅ 12 Integration Tests (Repositories, Redis, Database)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ 40 Total Tests Passing

Run with:

dotnet test

🎯 API Endpoints

MethodPathAuthDescription
POST/Url/CreateOptionalShorten a URL
GET/{shortCode}NoRedirect to original URL
POST/Auth/RegisterNoCreate account
POST/Auth/LoginNoSign in
POST/Auth/VerifyOtpNoVerify OTP
GET/DashboardJWTUser dashboard
GET/Dashboard/ProfileJWTProfile + stats

🌐 Live Demo

https://url-shortner-mvc-production.up.railway.app

Note: Email delivery is unavailable in the demo. OTP codes are displayed on-screen.

📝 License

MIT — feel free to use, modify, and learn from this project.


Built with ☕ and late nights

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages