Skip to content

Kosha-Nirman/tether

Repository files navigation

Tether Logo

🔗 Tether

Go Version Pre-commit Commitlint Testing License

Tether is a production-ready short URL service built on the Helix framework, demonstrating clean architecture and industry best practices.


⚡ Features

  • 🔗 Short URL Generation: Create short URLs with custom codes or auto-generated ones
  • ⏰ TTL Support: Set expiration times with default 1-month TTL (720 hours)
  • 📊 Comprehensive Analytics: Device, browser, geolocation, and referrer tracking
  • 🔒 Security: CORS, rate limiting, domain blocking, input validation
  • ⚡ Performance: Redis caching, MongoDB TTL indexes, optimized queries
  • 🧹 Auto Cleanup: Background cleanup of expired links with configurable retention
  • 🐳 Production Ready: Docker setup, health checks, graceful shutdown

🚀 Getting Started

Prerequisites

Ensure you have the following installed:

  • Go: v1.25 or later
  • Docker & Docker Compose: For database services
  • Make: For development commands

🐳 Quick Start with Docker

  1. Clone and setup:

    git clone https://github.com/Kosha-Nirman/tether.git
    cd tether
    cp .env.example .env
  2. Start all services:

    docker-compose up -d
  3. Run Tether:

    make dev  # Development with hot reload
    # or
    make run  # Production build
  4. Verify installation:

    curl http://localhost:5000/health
  5. Access API Documentation:

    # Swagger UI
    open http://localhost:5000/docs/index.html
    
    # JSON API spec
    curl http://localhost:5000/docs/swagger.json

📖 API Usage

Create a short link:

curl -X POST http://localhost:5000/api/links \
  -H "Content-Type: application/json" \
  -d '{
    "original_url": "https://example.com",
    "custom_code": "my-link",
    "ttl_hours": 720
  }'

Access short link:

curl -L http://localhost:5000/abc123

View analytics:

curl http://localhost:5000/api/links/abc123/stats

📚 API Documentation

Tether includes comprehensive Swagger/OpenAPI documentation:

  • Interactive UI: Visit http://localhost:5000/docs/ for the Swagger UI
  • JSON Spec: Available at http://localhost:5000/docs/swagger.json
  • YAML Spec: Available at http://localhost:5000/docs/swagger.yaml

Generate updated docs:

make swagger  # Regenerate Swagger docs from code annotations

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


🙌 Acknowledgments

  • Inspired by Go best practices and clean architecture principles
  • Built for developers who value maintainable and scalable code
  • Named Tether for its spiral structure that represents growth and evolution
  • Made with ❤️ to accelerate Go development and reduce boilerplate

About

A lightweight and fast shortlinks service built with Go, designed to securely connect long URLs to short, memorable links.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Generated from Kosha-Nirman/helix