Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blazingly Fast URL Shortener

A high-performance URL shortener service built with Rust, featuring encryption, MongoDB storage, and a clean REST API.

Features

  • ⚡ High-performance Rust implementation
  • 🔒 URL encryption using AES-256-GCM
  • 📦 MongoDB storage with indexed lookups
  • 🔄 Automatic URL deduplication
  • ⏰ Optional URL expiration
  • 📊 Click tracking
  • 🌐 RESTful API

Demo

Blazingly Fast URL Shortener

Prerequisites

  • Rust (latest stable)
  • MongoDB (4.x or later)
  • OpenSSL development libraries

Quick Start

Clone the repository

git clone https://github.com/sanjaysah101/blazinglyfast-url-shortener
cd url-shortener

Create a .env file

MONGODB_URI=mongodb://localhost:27017/
ENCRYPTION_KEY=your_base64_encoded_32_byte_key

Note: To generate a 32-byte key, you can use the following command:

openssl rand -base64 32

Build and run

cargo run

The server will start at http://127.0.0.1:8080

API Endpoints

Create Short URL

POST /api/urls
Content-Type: application/json

{
    "url": "https://example.com/very/long/url",
    "expires_in_days": 30  // optional
}

Get All URLs

GET /api/urls

Redirect to Original URL

GET /r/{short_code}

Security Features

  • AES-256-GCM encryption for stored URLs
  • Nonce-based encryption for enhanced security
  • Base64-encoded encryption key support
  • URL validation before storage

Performance

  • Asynchronous request handling with Actix Web
  • Indexed MongoDB queries for fast lookups
  • Connection pooling for database operations
  • Efficient in-memory encryption/decryption

Development

Build the project:

cargo build

Run tests:

cargo test

Run with logging:

RUST_LOG=debug cargo run

License

MIT License - See LICENSE for details.

Contributing

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

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages