Skip to content

viaannn/short-url-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

short-url

Go Version License

📌 Overview

A brief description of the project, what it does, and its key features.

🚀 Features

  • ✅ API to Create new short url
  • ✅ API to Redirect to full url

📦 Directory Structure

.
├── cmd/            # Entry points for the application (webserver)
├── internal/       # Private application logic (service, repository layer)
├── config/         # Configuration files (generic variable)
├── migrations/     # Database migrations
├── tests/          # Unit tests
├── Dockerfile      # Docker configuration
├── Makefile        # Build automation
└── README.md       # Project documentation

⚡ Installation

1. Clone the repository

https://github.com/viaannn/short-url-api.git
cd short-url-api

2. Install dependencies

go mod tidy

3. Set up environment variables

Copy the example environment file and update it as needed:

cp .env.example .env

4. Run the application

go run cmd/webserver/main.go

Or using Makefile:

make run

🛠️ Configuration

Environment variables required:

PORT=8080
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=secret
DB_NAME=mydb

🧪 Running Tests

Run all tests

go test ./test

Run tests with coverage

go test -cover ./test

📦 Docker Support

Build Docker Image

docker build -t short-url-api .

Run Docker Container

docker run -p 8080:8080 --env-file .env short-url-api

🚀 Deployment

Using Docker Compose

docker-compose up -d

Using GitHub Actions

See .github/workflows/deploy.yml for CI/CD automation.

🐜 License

This project is licensed under the MIT License.


🌟 Don't forget to give this project a star if you find it useful! 🌟