Skip to content

s3r1msultan/blazingly_fast_url_shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

πŸš€ rxst.me - A Blazingly Fast URL Shortener

Welcome to rxst.me, a high-performance, scalable, and secure URL shortener built using Rust, Actix-Web, and SQLx. This project was developed as part of the BLAZINGLY FAST Hackathon to provide an ultra-fast and reliable solution for shortening and managing URLs.

✨ Features

βœ… Blazing Fast Performance – Built with Rust and Actix-Web, leveraging async operations for speed.
βœ… Short URL Generation – Generates short, Base62-encoded or custom alias URLs.
βœ… Custom Alias Handling – Users can provide their own alias; if taken, alternative suggestions are provided.
βœ… Automatic Expiration (TTL) – URLs expire after 6 months and are automatically deleted.
βœ… Leet (1337) Transformations – If an alias is taken, the system suggests leet-style variations.
βœ… Redirection System – Redirects users to the original URL via /{short_url}.
βœ… URL Info Retrieval – Retrieve URL details (original URL, expiration date) via /u/{short_url}.
βœ… Validation – Ensures valid URLs and prevents invalid alias names.
βœ… Security Headers – Enforced CORS, XSS, and Content Security Policies.
βœ… Zero Downtime Cleanup – A background task automatically deletes expired URLs.


⚑ Tech Stack

  • Rust – Safe, fast, and memory-efficient.
  • Actix-Web – High-performance web framework.
  • SQLx + SQLite – Async database interaction.
  • Tokio – Async runtime for Rust.
  • Regex – For URL validation.
  • dotenv – Manage environment variables.

πŸ“‚ Project Structure

rxst.me/
│── src/
β”‚   │── main.rs        # Main server entry point
β”‚   │── config.rs      # Initializes logging & environment variables
β”‚   │── database.rs    # Handles database interactions & TTL cleanup
β”‚   │── handlers.rs    # HTTP request handlers (shorten, redirect, info)
β”‚   │── hash.rs        # Hashing & encoding for short URLs
β”‚   │── models.rs      # Database models & request structures
β”‚   │── routes.rs      # Actix-Web route configuration
β”‚   │── validation.rs  # URL validation logic
│── migrations/        # SQL migration files
│── static/index.html  # Frontend UI for shortening URLs
│── .env               # Environment configuration
│── Cargo.toml         # Rust dependencies

πŸš€ Quick Start

πŸ“Œ 1️⃣ Clone the Repository

git clone https://github.com/s3r1msultan/blazingly_fast_url_shortener.git
cd blazingly_fast_url_shortener

πŸ“Œ 2️⃣ Setup the Environment

Create a .env file with:

DATABASE_URL=sqlite://url_shortener.db

πŸ“Œ 3️⃣ Run Database Migrations

cargo install sqlx-cli
cargo sqlx migrate run

πŸ“Œ 4️⃣ Start the Server

cargo run

πŸ“Œ 5️⃣ Open in Browser

Visit http://0.0.0.0:8080 and start shortening URLs.


πŸ”— API Endpoints

πŸ”Ή Shorten a URL

POST /shorten

{
    "original_url": "https://example.com",
    "custom_alias": "myalias"
}

Response:

{
    "short_url": "myalias"
}

πŸ”Ή Redirect to Original URL

GET /{short_url}

  • Redirects users to the original website.

πŸ”Ή Get URL Info

GET /u/{short_url} Response:

{
    "short_url": "myalias",
    "expiration_date": "2025-08-03 13:00:00"
}

🎯 How It Works

πŸ”₯ 1️⃣ Hash-Based Short URL Generation

  • Uses FNV-1a Hashing + Base62 Encoding to generate deterministic short URLs.

πŸ›  2️⃣ Alternative Alias Suggestions

  • If an alias is already taken, the system suggests alternative aliases using leet-style replacements:
    • "google" β†’ "9oogle", "90ogle", "900gle"

πŸ•’ 3️⃣ Automatic Expiration & Cleanup

  • URLs expire in 6 months.
  • A background task deletes expired URLs every hour.

πŸ”Ž 4️⃣ Fetch URL Details

  • Users can retrieve info about a short URL via /u/{short_url}.

πŸ›  Contributing

Want to improve rxst.me? Contributions are welcome!
To contribute:

  1. Fork the repo.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Added feature XYZ").
  4. Push to GitHub (git push origin feature-name).
  5. Submit a Pull Request (PR).

πŸ“œ License

This project is licensed under the MIT License.


πŸ‘₯ Team & Credits

Built by s3r1msultan for the BLAZINGLY FAST Hackathon.

πŸš€ Let's make URL shortening faster than ever!

About

A Rust URL shortener

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors