A simple and efficient URL shortener service written in Go that allows you to create shortened URLs. The service uses Google Sheets as a database for storing URL mappings and Redis for caching.
- Create shortened URLs with custom paths
- URL validation to ensure valid input
- Google Sheets integration for persistent storage
- Redis caching for improved performance
- Dockerized application for easy deployment
- Go 1.18 or higher
- Redis server
- Google Sheets API credentials
- Docker (optional)
- github.com/asaskevich/govalidator - For URL validation
- github.com/go-redis/redis/v9 - Redis client for caching
- google.golang.org/api - Google Sheets API client
- Clone the repository:
git clone https://github.com/emre-guler/url-shortener.git
cd url-shortener
-
Set up Google Sheets:
- Create a new Google Sheet
- Set up Google Cloud Project and enable Google Sheets API
- Download credentials.json and place it in the
db
directory - Set the environment variable for your spreadsheet ID:
export URL_SHORTENER_PROJECT_SPREADSHEET_ID=your_spreadsheet_id
-
Install dependencies:
go mod download
- Start Redis server:
redis-server
- Run the application:
go run main.go
The project includes a Dockerfile for containerized deployment:
docker build -t url-shortener .
docker run -e URL_SHORTENER_PROJECT_SPREADSHEET_ID=your_spreadsheet_id url-shortener
- Run the application
- Enter the URL you want to shorten when prompted
- Enter your desired custom path
- The application will return your shortened URL in the format:
https://www.emreguler.dev/your-custom-path
- ✅ Google Sheets as DB
- ✅ Environment Variables for SpreadsheetId
- ✅ Dockerization
- ✅ Redis Caching
Feel free to submit issues, fork the repository, and create pull requests for any improvements.