simple-url-shortener.

maintenance

A simple URL shortener built with Rust. Takes long URLs and makes them short for local use.

$ cat github.com/arnonsang/simple-url-shortener/README.mdsynced 2026-11-19 10:33 ICT · rebuilt daily

🔗 Simple URL Shortener

A simple URL shortener built with Rust. Takes long URLs and makes them short for local use.

✨ Features

  • 🦀 Built with Rust and Axum
  • 🎨 Web interface with Tailwind CSS
  • 📊 Basic click tracking
  • 🗄️ SQLite database storage
  • 🐳 Docker support

🚀 Quick Start

Prerequisites

  • Rust 1.80+ (latest stable recommended)
  • Git

Installation

  1. Clone and run:

    git clone <your-repo-url>
    cd rust-url-shortener
    cargo run
  2. Open your browser: Go to http://localhost:3000

  3. Start shortening URLs!

🛠️ Development

# Run tests
cargo test

# Build for production
cargo build --release

# Run the server
cargo run --release

# Run with Docker
docker build -t url-shortener .
docker run -p 3000:3000 url-shortener

📡 How it works

  1. POST /api/shorten - Send a URL, get a short code back
  2. GET /{short_code} - Visit the short URL, get redirected to original
  3. GET /api/stats - See all your shortened URLs and click counts

Simple as that!

Key Components

  • Frontend: Modern web interface with Tailwind CSS
  • Backend: Rust web server using Axum framework
  • Database: SQLite for persistent storage
  • URL Generation: Cryptographically secure random short codes
  • Validation: Input validation and sanitization

📁 Project Structure

url-shortener/
├── src/
│   ├── lib.rs          # Core URL shortener logic
│   └── main.rs         # Web server and API endpoints
├── static/
│   ├── index.html      # Web interface
│   └── app.js          # Frontend JavaScript
├── tests/
│   ├── integration_tests.rs
│   └── error_handling_tests.rs
├── Cargo.toml          # Rust dependencies
├── Dockerfile          # Docker configuration
└── README.md

Made with ❤️ and Rust

continue reading on github →