A high-performance URL shortening service built with Go, designed to handle high-throughput URL shortening and redirection with robust caching and rate limiting.
This URL shortener service provides a reliable and scalable solution for creating shortened URLs. Built with Go, it leverages Redis for caching and rate limiting, and PostgreSQL for persistent storage, ensuring both high performance and data durability.
- Go version 1.22.5
- Docker Engine
- Docker Compose Plugin
- Make (for development convenience)
- Docker Engine
- Docker Compose Plugin
git clone https://github.com/0xAFz/kuchak.git
cd kuchak/
# Copy the example environment file
cp .env.example .env
# Edit the environment variables according to your setup
vim .env
The project requires PostgreSQL and Redis, which are configured in the Docker Compose file.
# Start PostgreSQL and Redis containers
docker compose up -d
# Verify containers are running
docker compose ps
There are two ways to run the application locally:
# Option 1: Using Make
make run
# Option 2: Direct Go command
go run main.go
The application should now be running on http://localhost:1323
(or your configured port)
# Install Docker using the official installation script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker
# Copy the production environment file
cp .env.prod .env
# Configure production environment variables
vim .env
# Build and start the application stack
docker compose -f prod.compose.yml up --build -d
# Verify all services are running
docker compose -f prod.compose.yml ps
# Check application logs
docker compose -f prod.compose.yml logs -f app
# Check application health
curl http://sub.domain.tld/healthz
# Development
docker compose logs -f
# Production
docker compose -f prod.compose.yml logs -f
# Development
docker compose down
# Production
docker compose -f prod.compose.yml down
# Connect to PostgreSQL
docker compose exec postgres psql -U <username> -d <database>
# Backup Database
docker compose exec postgres pg_dump -U <username> <database> > backup.sql
# Connect to Redis CLI
docker compose exec redis redis-cli
-
Port Conflicts
- Error:
bind: address already in use
- Solution: Check for processes using required ports
sudo lsof -i :<port>
- Error:
-
Database Connection Issues
- Verify PostgreSQL container is running
- Check environment variables
- Ensure network connectivity between services
-
Redis Connection Issues
- Verify Redis container is running
- Check Redis password in environment variables
- Verify network connectivity
For additional help:
- Check the project's GitHub issues
- Review the error logs using
docker compose logs
- Contact the development team
-
Environment Variables
- Never commit
.env
files to version control - Use strong passwords in production
- Regularly rotate credentials
- Never commit
-
Network Security
- Use internal Docker networks when possible
- Limit exposed ports
- Configure firewalls appropriately
-
Updates
- Regularly update Docker images
- Keep Go dependencies updated
- Monitor security advisories