A Full stack URL shorter management system with advanced organization management, analytics, and team collaboration features.
| Section | Description |
|---|---|
| π Overview | Project introduction and key highlights |
| β¨ Features | Comprehensive feature breakdown |
| ποΈ Architecture | Clean Architecture implementation |
| π οΈ Tech Stack | Technologies and frameworks |
| π Database Schema | Entity relationships and structure |
| π API Documentation | Comprehensive API reference |
| π¨ UI | Front-end (under development) |
| π Getting Started | Development setup guide |
| π³ Docker Setup | Containerized deployment |
| π§ SMTP Configuration | Email notification setup |
| π Security | Security implementations |
| β‘ Performance | Performance optimizations |
| π License | License information |
Shortly is a comprehensive, enterprise-grade URL shortening service built with Clean Architecture principles. The initial spark for this project came from roadmap.shβs URL Shortening Service project, but I extended the concept far beyond its basic requirements. Shortly goes beyond simple URL shortening to provide a full platform for organizations to manage their links, collaborate in teams, track detailed analytics, and maintain security at scale.
- π’ Multi-Tenant Organization Management - Complete organization structure with teams and roles
- π Advanced Security - Permission-based authorization, 2FA, account security
- π Comprehensive Analytics - Real-time click tracking with geolocation and traffic analysis
- π₯ Team Collaboration - Invitation system, role management, and team-based URL organization
- π Background Processing - Quartz.NET scheduled jobs and background workers
- π§ Email System - Template-based notifications with queue processing
- π Bulk Operations - Efficient bulk URL creation and management
- π Usage Tracking - Subscription plans and quota management
- π Advanced Search - Powerful search capabilities across all entities
- π‘οΈ Audit Logging - Comprehensive activity tracking and security auditing
- Smart URL Shortening - Generate unique, memorable short codes with collision detection
- Custom Short Codes - User-defined aliases with availability checking
- Bulk Operations - Create, update, and manage thousands of URLs simultaneously
- URL Validation - Comprehensive security checks and malware detection
- Expiration Management - Flexible expiration dates with automatic cleanup
- Password Protection - Secure URLs with custom password requirements
- QR Code Generation - Automatic QR code creation for mobile sharing
- Multi-Tenant Architecture - Complete organization isolation and management
- Team Structure - Hierarchical team organization with managers and members
- Invitation System - Secure email-based invitations with expiration
- Role-Based Access - Granular permissions for different user roles
- Organization Analytics - Aggregate statistics across all organization URLs
- Usage Quotas - Flexible subscription plans with usage tracking
- Ownership Transfer - Seamless organization ownership transitions
- Advanced Authentication - JWT tokens with refresh token rotation
- Two-Factor Authentication - TOTP-based 2FA for enhanced security
- Account Security - Password policies, account locking, security events
- User Profiles - Comprehensive user profile management
- Audit Logging - Complete activity tracking for security and compliance
- Session Management - Secure session handling with automatic cleanup
- Real-Time Click Tracking - Immediate click event processing
- Geographic Analytics - Country and city-level location tracking
- Traffic Source Analysis - Referrer and campaign tracking
- User Agent Parsing - Device, browser, and OS identification
- Time-Series Analytics - Historical data with customizable date ranges
- Performance Metrics - URL performance comparison and ranking
- Export Capabilities - Data export in multiple formats (CSV, JSON, Excel)
- Template-Based Emails - Professional email templates for all communications
- Background Processing - Queue-based email delivery system
- Multi-Provider Support - SMTP, SendGrid, and other email providers
- Notification Preferences - User-configurable notification settings
- Email Verification - Secure email address validation workflow
- Delivery Tracking - Monitor email delivery status and failures
- Admin Dashboard - Comprehensive system administration interface
- User Administration - Bulk user operations and account management
- System Monitoring - Performance metrics, and system status
- Configuration Management - Runtime configuration updates
- Database Administration - Migration management and data maintenance
- Security Monitoring - Real-time security event tracking and alerting
Shortly implements Clean Architecture with Domain-Driven Design principles:
π Shortly/
βββ π Shortly.API/ # Presentation Layer
β βββ Controllers/ # API Controllers (20+ controllers)
β β βββ Base/ # Base controller with common functionality
β β βββ Auth/ # Authentication endpoints
β β βββ Organization/ # Organization management
β β βββ ShortUrl/ # URL management
β β βββ Analytics/ # Analytics and reporting
β β βββ Admin/ # Administrative functions
β βββ Authentication/ # JWT authentication context
β βββ Authorization/ # Permission-based authorization
β βββ Middleware/ # Custom middleware (exception handling)
β βββ HTMLTemplates/ # HTML templates for forms
β
βββ πΌ Shortly.Core/ # Application Layer
β βββ Services/ # Business logic services
β β βββ Authentication/ # Auth and account services
β β βββ UrlManagement/ # URL operations
β β βββ OrganizationManagement/ # Organization services
β β βββ ClickTracking/ # Analytics services
β β βββ Email/ # Email services
β β βββ UserManagement/ # User administration
β βββ DTOs/ # Data Transfer Objects (100+ DTOs)
β βββ Validators/ # FluentValidation rules
β βββ Mappers/ # Entity-DTO mapping
β βββ Exceptions/ # Custom exceptions hierarchy
β βββ Extensions/ # Utility extensions
β
βββ ποΈ Shortly.Domain/ # Domain Layer
β βββ Entities/ # Domain entities (19 entities)
β β βββ User & Security # User, UserProfile, UserSecurity
β β βββ Organizations # Organization, Team, Member
β β βββ URLs # ShortUrl, ClickEvent
β β βββ Tokens # RefreshToken, ActionTokens
β β βββ Subscriptions # SubscriptionPlan, Usage
β βββ Enums/ # Domain enumerations
β βββ Configuration/ # Domain configuration
β
βββ π§ Shortly.Infrastructure/ # Infrastructure Layer
βββ DbContexts/ # Entity Framework context
βββ Repositories/ # Data access implementations
βββ BackgroundServices/ # Background workers
βββ ScheduledJobs/ # Quartz.NET jobs
βββ Services/ # External service implementations
- Separation of Concerns - Each layer has distinct responsibilities
- Testability - Comprehensive unit and integration testing support
- Maintainability - Clear boundaries and well-defined interfaces
- Scalability - Horizontal scaling capabilities with microservices readiness
- Domain Focus - Business logic isolated from technical concerns
- ASP.NET Core 8.0 - Modern, cross-platform web framework
- Entity Framework Core 9.0 - Advanced ORM with SQL Server support
- C# 12 - Latest language features and performance improvements
- JWT Bearer Authentication - Stateless token-based authentication
- BCrypt.Net-Next 4.0.3 - Secure password hashing
- Microsoft.IdentityModel.Tokens - JWT token handling
- FluentValidation 11.3.1 - Elegant model validation
- Quartz.NET 3.15.0 - Enterprise job scheduling and background tasks
- ASP.NET Core Hosted Services - Background worker services
- Queue-based Processing - Scalable background job processing
- SQL Server - Enterprise-grade relational database
- Entity Framework Core Tools - Database migrations and scaffolding
- Connection Pooling - Optimized database connection management
- MethodTimer.Fody 3.2.3 - Automatic method execution timing
- Custom Middleware - Request/response logging and metrics
- Swashbuckle.AspNetCore 9.0.3 - OpenAPI/Swagger documentation
- User Secrets - Secure development configuration
- Docker & Docker Compose - Containerization and orchestration
erDiagram
User ||--o{ UserProfile : has
User ||--o{ UserSecurity : has
User ||--o{ UserUsage : has
User ||--o{ OrganizationMember : "belongs to"
User ||--o{ ShortUrl : creates
User ||--o{ RefreshToken : has
Organization ||--o{ OrganizationMember : contains
Organization ||--o{ OrganizationTeam : has
Organization ||--o{ OrganizationUsage : tracks
Organization ||--o{ ShortUrl : owns
OrganizationTeam ||--o{ OrganizationTeamMember : contains
ShortUrl ||--o{ ClickEvent : tracks
User ||--o{ UserActionToken : has
User ||--o{ EmailChangeToken : has
Check out the API documnetation here
git clone https://github.com/AbdelrahmanTaymour/Shortly.git
cd Shortlycd Shortly.API
# Create user-secrets
dotnet user-secrets init
# JWT Configuration
dotnet user-secrets set "TokenSettings:Key" "your-super-secret-jwt-key-at-least-32-characters-long-for-security"
# Database Connection
dotnet user-secrets set "ConnectionStrings:ConnectionString" "Server=localhost;Database=ShortlyDb;Trusted_Connection=true;TrustServerCertificate=True;"
# Email Configuration (Gmail example)
dotnet user-secrets set "EmailSettings:Smtp:Username" "your-email@gmail.com"
dotnet user-secrets set "EmailSettings:Smtp:Password" "your-app-specific-password"
dotnet user-secrets set "EmailSettings:From:Email" "your-email@gmail.com"
dotnet user-secrets set "EmailSettings:From:Name" "Shortly Team"# Install EF Core tools globally (if not installed)
dotnet tool install --global dotnet-ef
# Verify EF tools installation
dotnet ef --version
# Create database migration
dotnet ef migrations add InitialCreate --project Shortly.Infrastructure --startup-project Shortly.API
# Apply migration to database
dotnet ef database update --project Shortly.Infrastructure --startup-project Shortly.API# Restore all NuGet packages
dotnet restore
# Build the solution
dotnet build# Run the API project
dotnet run --project Shortly.API- API Base URL:
https://localhost:7001orhttp://localhost:5000 - Swagger Documentation:
https://localhost:7001/swagger
-
Copy the environment template:
cp .env.template .env
-
Update the
.envfile:# Database Configuration DB_PASSWORD=[ur-db-password] # JWT Configuration JWT_KEY=[your-super-secret-jwt-key-at-least-32-characters-long-for-security] # Email Configuration EMAIL_USERNAME=your-email@gmail.com EMAIL_PASSWORD=your-app-specific-password # Connection String CONNECTION_STRING=Server=sqlserver;Database=ShortlyDb;User Id=[sa];Password=[ur-strong-password];TrustServerCertificate=True;
# Start all services (API + SQL Server + Background Workers)
docker-compose up -d
# View logs for all services
docker-compose logs -f
# View logs for specific service
docker-compose logs -f shortly-api
# Stop all services
docker-compose down
# Stop and remove all data (β οΈ This will delete the database)
docker-compose down -v# Rebuild after code changes
docker-compose up --build -d
# View running containers
docker ps
# Access API container shell
docker exec -it shortly-api bash
# Access SQL Server container
docker exec -it shortly-sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U [sa] -P [You-db-password]- API: http://localhost:5001
- Swagger: http://localhost:5001/swagger
-
Enable 2-Factor Authentication:
- Go to Google Account Security
- Enable "2-Step Verification"
-
Generate App Password:
- Go to "2-Step Verification" settings
- Click "App passwords"
- Select "Mail" and "Other"
- Name it "Shortly API"
- Copy the 16-character password
-
Configure in User Secrets:
dotnet user-secrets set "EmailSettings:Smtp:Username" "your-email@gmail.com" dotnet user-secrets set "EmailSettings:Smtp:Password" "abcd efgh ijkl mnop"
-
Or in Docker .env:
EMAIL_USERNAME=your-email@gmail.com EMAIL_PASSWORD=abcdefghijklmnop
The system includes professional email templates for:
- Welcome & Registration - User onboarding emails
- Email Verification - Account activation
- Password Reset - Secure password recovery
- Organization Invitations - Team member invitations
- Usage Notifications - Quota and usage alerts
- Security Alerts - Login and security notifications
- JWT Bearer Tokens - Secure stateless authentication
- Refresh Token Rotation - Enhanced security with token rotation
- Role-Based Access Control - Granular permission system
- Two-Factor Authentication - TOTP-based 2FA support
- Permission-Based Authorization - Fine-grained access control
- Password Security - BCrypt hashing with configurable rounds
- Input Validation - Comprehensive FluentValidation rules
- SQL Injection Prevention - EF Core parameterized queries
- XSS Protection - Input sanitization and encoding
- CSRF Protection - Anti-forgery tokens
- Audit Logging - Comprehensive activity tracking
- Failed Login Tracking - Brute force attack detection
- Account Locking - Automatic account protection
- Security Events - Real-time security event logging
- Session Management - Secure session handling
- HTTPS Enforcement - TLS encryption for all communications
- CORS Configuration - Secure cross-origin requests
- Rate Limiting - API abuse prevention
- URL Validation - Malicious URL detection
- Content Security Policy - XSS and injection protection
- Strategic Indexing - Optimized database indexes
- Query Optimization - Efficient EF Core queries
- Connection Pooling - Database connection optimization
- Async Operations - Non-blocking I/O operations
- Bulk Operations - Efficient batch processing
- Response Caching - HTTP response caching
- Memory Caching - In-memory data caching
- Query Result Caching - Database query caching
- Static Content Caching - CDN-ready static assets
- Queue-Based Processing - Scalable background jobs
- Batch Processing - Efficient bulk operations
- Async Email Delivery - Non-blocking notifications
- Scheduled Jobs - Quartz.NET job scheduling
- Method Timing - Execution time monitoring
- Performance Counters - Real-time metrics
- Request Logging - Comprehensive request tracking
LinkedIn - Abdelrahman Taymour
This project is licensed under the MIT License - see the LICENSE file for details.