shortly
This is a backend API built with Go. It is designed for scalability and simplicity.It serves as a URL shortener service with features like generating and retrieving shortened URLs.
Installation
-
Clone the repository:
git clone https://github.com/tin3ga/shortly.git
cd shortly
-
Install dependencies:
go mod tidy
-
Configure .env file:
PORT=8088
DATABASE_URL=postgresql://<user>:<pass>@<host>/<database>
URL=http://localhost:8088/api/v1/
Configuration
-
Add a GOOSE_DBSTRING in makefile
-
Run make to set up migrations, dev dependencies etc.
make help
Usage
-
Run the application
go run main.go
-
Swagger Documentation
Access API documentation at:
http://localhost:8088/swagger/index.html
Deployment
Using Docker:
docker compose up
goose -dir ./sql/schema/ postgres postgresql://postgres:mypassword@localhost:5432/postgres?sslmode=disable up
For production, ensure you:
Testing
Using hey to test rate limiter
./hey -n 1000 -c 10 http://localhost:8088/ap1/v1/links/all
Using autocannon to test caching
enable or disable caching in the .env file
autocannon -d 20 -c 50 --renderStatusCodes http://localhost:8088/api/v1/links/all
License
This project is licensed under the MIT license.
© 2025 tin3ga