A service for shortening URLs, collecting and displaying statistics on visits
Related services: Bitly, Clck, Tinyurl, Goosu
- Registration, authorization
- Shortening links
- Custom links
- Visit statistics
- Access control
Linux, Nginx, REST API, SSR, JWT, Brypt, PostgreSQL
Golang, Gorilla/mux, Gorm, Godotenv, html/template
This application has been developed using the principles of Clean Architecture and Dependency injection. The purpose of this architecture is to create flexible, extensible and easily maintained software by dividing the code into independent layers and layers.
- Controllers: handling requests, parsing data, forming response
- Services: perform bussiness logic
- Repositories: interact with database, ORM mapping
- Entities: describe fields
To install and run this project, follow these steps:
- Clone the repository:
git clone https://github.com/ngrink/url-shortener.git
- Go to the project directory
cd url-shortener
- Install dependencies
go mod tidy
- Update env configuration
vim config/.env.local
APP_PORT=7000
APP_HOST=http://localhost:7000
POSTGRES_HOST=<POSTGRES_HOST>
POSTGRES_PORT=<POSTGRES_PORT>
POSTGRES_USER=<POSTGRES_USER>
POSTGRES_PASSWORD=<POSTGRES_PASSWORD>
POSTGRES_DB=<POSTGRES_DB>
JWT_SECRET="jwUjak517ayqnJaBZHu8i9qybzz"
REDIRECT_CACHE_CONTROL_MAX_AGE=600
- Build and run application
go build ./cmd/url-shortener
./url-shortener
Download prebuilt binaries from the latest release, choose appropriate os/arch version. For example:
wget https://github.com/ngrink/url-shortener/releases/download/v0.2.0/url-shortener_Linux_x86_64.tar.gz
tar -zxf url-shortener_Linux_x86_64.tar.gz
./url-shortener