Skip to content

theujjwalsingh18/GoURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔗 GoURL - Lightning-Fast URL Shortener

Go Version Docker AWS EC2 License

Live demo: https://gourl.live

A high-performance URL shortening service written in Go, containerized with Docker, and deployed on AWS infrastructure.

API Demo

✨ Features

  • ⚡️ 1000+ requests/second throughput
  • 🔒 TLS/HTTPS secure redirects
  • 📦 Docker container support
  • ☁️ AWS EC2 deployment ready
  • 📈 Built-in health monitoring
  • 📝 Custom alias support (optional)

🚀 Usage

Web Interface

Visit https://gourl.live and enter your URL.

API Endpoints

Shorten URL:

curl -X POST https://gourl.live/\
-H "Content-Type: application/json" \
-d '{"url": "https://your-long-url.com"}'

Response:

{
  "short_url": "https://gourl.live/abc12",
  "original_url": "https://your-long-url.com",
}

Redirect (Use in browsers):

https://gourl.live/abc12

🐳 Deployment

With Docker:

docker run -dp 3000:3000 --name url-shortener yourusername/go-url-shortener

Build from source:

# Clone repository
git clone https://github.com/yourusername/go-url-shortener.git

# Build and run
cd go-url-shortener
go build -o shortener
./shortener

Access at: http://localhost:3000

☁️ AWS EC2 Deployment

  1. Launch EC2 instance (Ubuntu Linux 2023)

  2. Install Docker:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y
sudo systemctl start docker
sudo systemctl enable docker
  1. Run container:
docker run -dp 80:3000 \
-e PORT=3000 \
-e STORAGE_TYPE=memory \
--restart always \
yourusername/go-url-shortener:latest
  1. Configure security groups to allow HTTP/HTTPS traffic

🛠️ Configuration

Set via environment variables:

Variable Default Description
PORT 3000 Port the server listens on
MAX_URL_LENGTH 2000 Maximum allowed URL length
STORAGE_TYPE memory Storage backend (memory)
CACHE_SIZE 10000 In-memory cache size (if using memory storage)

📦 Storage Backends

Memory (Default)

  • Simple in-memory map
  • Data lost on restart
  • Great for testing

🤝 Contributing

  1. Fork the project
  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

📄 License

Distributed under the MIT License. See LICENSE for more information.


Happy shortening! ✂️🚀