Skip to content
/ URLite Public

A REST API web service that allows users to shorten URLs, track clicks and visitor activity, and view statistics. Built with .NET 8, featuring user authentication, caching, and containerized deployment.

Notifications You must be signed in to change notification settings

liadraz/URLite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— URLite

A high-performance URL shortener service built with .NET 8, featuring user authentication, caching, and containerized deployment. Designed to demonstrate full-stack development skills and system design capabilities.

πŸš€ Features

Core Functionality

  • URL Shortening: Convert long URLs into short, shareable links
  • URL Redirection: Fast redirect service with sub-millisecond response times
  • Custom Short Codes: Option to create personalized short URLs (will be implemented on version 2)
  • URL Expiration: Set time-based expiration for links (will be implemented on version 2)

User Management

  • User Authentication: JWT-based authentication. system
  • Track Click: Monitor total and per URL click counts
  • User Dashboard: Manage personal URLs and view statistics (will be implemented on version 2)
  • Rate Limiting: Prevent abuse with configurable rate limits (optional)

Performance & Scalability

  • Multi-layer Caching: Redis + In-memory caching for optimal performance
  • Database Optimization: Indexed queries and efficient data models

DevOps Ready

  • Containerized: Docker and Docker Compose setup
  • Health Checks: Monitoring endpoints for deployment
  • Structured Logging: Comprehensive logging with Serilog
  • API Documentation: OpenAPI/Swagger integration

πŸ› οΈ Technology Stack

  • Backend: ASP.NET Core 8 Web API
  • Database: PostgreSQL with Entity Framework Core
  • Caching: Redis + In-Memory caching
  • Authentication: JWT tokens with ASP.NET Core Identity
  • Containerization: Docker & Docker Compose
  • Documentation: Swagger/OpenAPI
  • Testing: xUnit, Moq, TestContainers

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Load Balancer β”‚    β”‚     Web API     β”‚    β”‚     Redis       β”‚
β”‚                 │───▢│   (.NET Core)   │───▢│    (Cache)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   PostgreSQL    β”‚
                       β”‚   (Database)    β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design Decisions

  • PostgreSQL over NoSQL: Chosen for ACID compliance, rapid development, and excellent .NET integration
  • Base62 Encoding: Using auto-incrementing IDs with Base62 encoding to avoid hash collisions
  • Read-Optimized: Architecture optimized for 100:1 read-to-write ratio typical of URL shorteners
  • Caching Strategy: Cache-aside pattern with Redis for hot URLs and in-memory cache for ultra-fast access

πŸš€ Quick Start

Prerequisites

  • .NET 8 SDK
  • Docker & Docker Compose
  • PostgreSQL (or use Docker)
  • Redis (or use Docker)

Running with Docker Compose

# Clone the repository
git clone https://github.com/liadraz/URLite.git
cd URLite

# Start all services
docker-compose up -d

# The API will be available at http://localhost:8080
# Swagger documentation at http://localhost:8080/swagger

Local Development Setup

# Restore dependencies
dotnet restore

# Update database
dotnet ef database update

# Run the application
dotnet run --project src/URLite.Api

# Run tests
dotnet test

πŸ“š API Documentation

Core Endpoints

Shorten URL

POST /api/urls
Content-Type: application/json
Authorization: Bearer {jwt-token}

{
  "originalUrl": "https://example.com/very-long-url",
  "customCode": "my-link",  // optional
  "expiresAt": "2024-12-31T23:59:59Z"  // optional
}

Access Short URL

GET /{shortCode}
# Redirects to original URL

Get URL Analytics

GET /api/urls/{shortCode}/analytics
Authorization: Bearer {jwt-token}

Authentication Endpoints

Register User

POST /api/auth/register
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "SecurePassword123!",
  "confirmPassword": "SecurePassword123!"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "SecurePassword123!"
}

πŸ§ͺ Testing

# Run all tests
dotnet test

# Run with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run integration tests
dotnet test --filter Category=Integration

Test Coverage

  • Unit Tests: Core business logic and services
  • Integration Tests: API endpoints with TestContainers
  • Performance Tests: Load testing for redirect endpoints

πŸ“ˆ Performance Benchmarks

Metric Target Achieved
URL Creation < 100ms ~45ms
URL Redirect < 10ms ~3ms (cached)
Concurrent Users 1000+ TBD
URLs Stored 10M+ TBD

πŸ”§ Configuration

Environment Variables

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/tinyurl

# Redis
REDIS_CONNECTION_STRING=localhost:6379

# JWT
JWT_SECRET_KEY=your-super-secret-key
JWT_EXPIRY_HOURS=24

# Rate Limiting
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW_MINUTES=1

πŸš€ Deployment

Docker Deployment

# Build production image
docker build -t urlite-api .

# Run with production compose
docker-compose -f docker-compose.prod.yml up -d

Cloud Deployment

  • Azure: Container Apps or App Service
  • AWS: ECS or Elastic Beanstalk
  • GCP: Cloud Run or GKE

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

⭐ If you found this project helpful, please give it a star on GitHub!

URLiet - Scalable URL shortener (Personal Project, 2023) Stack: .NET, PostgreSQL, Redis, Docker, JWT, xUnit Clean Architecture + DDD service with caching, analytics, and comprehensive testing.

About

A REST API web service that allows users to shorten URLs, track clicks and visitor activity, and view statistics. Built with .NET 8, featuring user authentication, caching, and containerized deployment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages