repositorypackage
0.1.0
Repository: https://github.com/hcd233/aris-url-gen.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
Aris-url-gen
[ English | 简体中文 ]
Introduction
A high-performance URL shortening service developed in Go. The project name comes from the character Aris in Blue Archive, as shown in the figure below.
Aris: A character from Blue Archive
Features
- Generate short URLs: Converts long URLs into short links
- Customizable expiration time: Allows setting an expiration date for links
- Bidirectional caching: High-performance caching using Redis
- RESTful API: Provides a standard HTTP interface
- Data persistence: URL mappings are stored in MySQL
Tech Stack
API Endpoints
1. Generate Short URL
POST /v1/shortURL
Content-Type: application/json
{
"originalURL": "https://example.com/very/long/url",
"expireDays": 7 // Optional, expiration in days
}
2. Access Short URL
GET /v1/s/{shortURL}
Project Structure
.
├── cmd/ # Command line entry
├── internal/
│ ├── api/ # API-related code
│ │ ├── dao/ # Data access layer
│ │ ├── dto/ # Data transfer objects
│ │ ├── handler/ # Request handlers
│ │ └── service/ # Business logic layer
│ ├── config/ # Configuration files
│ ├── logger/ # Logging
│ ├── resource/ # Resources
│ └── util/ # Utility functions
└── main.go # Main entry point
Installation and Deployment
Prerequisites
- Go 1.20+
- MySQL 8.0+
- Redis 6.0+
Local Development
- Clone the repository
git clone https://github.com/hcd233/Aris-url-gen.git
cd Aris-url-gen
- Install dependencies
go mod download
- Configure environment variables
Refer to api.env.template
to set up the required environment variables
- Run the service
go run main.go
Deployment
Docker Deployment
- Create required volumes:
docker volume create mysql-data
docker volume create redis-data
- Deploy with docker-compose:
# Development environment
docker compose -f docker/debug-docker-compose.yml up -d
# Production environment
docker compose -f docker/docker-compose.yml up -d
Kubernetes Deployment
- Create namespace and configs:
kubectl apply -f kubernetes/namespace.yml
kubectl apply -f kubernetes/configmaps.yml
- Create secrets (configure secrets.yml first):
cp kubernetes/secrets.yml.template kubernetes/secrets.yml
# Edit secrets.yml with actual secret values
kubectl apply -f kubernetes/secrets.yml
- Create storage and deploy services:
kubectl apply -f kubernetes/pvc.yml
kubectl apply -f kubernetes/deployments.yml
kubectl apply -f kubernetes/services.yml
Helm Deployment
- Configure values.yaml:
cp helm/aris-url-gen/values.yaml.template helm/aris-url-gen/values.yaml
# Edit values.yaml with your configuration
- Install with Helm:
helm install aris-url-gen helm/aris-url-gen
- Upgrade or uninstall:
# Upgrade
helm upgrade aris-url-gen helm/aris-url-gen
# Uninstall
helm uninstall aris-url-gen
License
This project is licensed under the Apache License 2.0. See the LICENSE file for more details.