https://github.com/hoan02/puchi-user-service
https://github.com/hoan02/puchi-user-service
go microservices puchi
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hoan02/puchi-user-service
- Owner: hoan02
- License: mit
- Created: 2025-07-30T02:38:27.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-08-01T12:32:44.000Z (10 months ago)
- Last Synced: 2025-08-01T14:37:50.532Z (10 months ago)
- Topics: go, microservices, puchi
- Language: Go
- Homepage:
- Size: 447 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Puchi User Service
A microservice for user management and translation functionality built with Go, following clean architecture principles.
## ๐ Features
- **Translation Service**: Translate text using Google Translate API
- **History Management**: Store and retrieve translation history
- **Multiple Protocols**: HTTP REST API, gRPC, and AMQP RPC
- **Swagger Documentation**: Auto-generated API documentation
- **Health Checks**: Built-in health monitoring endpoints
- **Metrics**: Prometheus metrics integration
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ HTTP API โ โ gRPC API โ โ AMQP RPC โ
โ (Port 8002) โ โ (Port 9002) โ โ (Port 5672) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ Application โ
โ Layer โ
โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ Repository โ
โ Layer โ
โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ PostgreSQL โ โ Google API โ โ RabbitMQ โ
โ (Port 5432) โ โ (External) โ โ (Port 5672) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
```
## ๐ ๏ธ Tech Stack
- **Language**: Go 1.24
- **Framework**: Fiber (HTTP), gRPC, AMQP
- **Database**: PostgreSQL
- **Message Queue**: RabbitMQ
- **Documentation**: Swagger/OpenAPI
- **Monitoring**: Prometheus
- **Containerization**: Docker & Docker Compose
## ๐ Prerequisites
- Go 1.24+
- Docker & Docker Compose
- PostgreSQL
- RabbitMQ
## ๐ Quick Start
### Using Docker Compose
```bash
# Start all services
make compose-up-all
# Or start only dependencies
make compose-up
```
### Manual Setup
```bash
# Install dependencies
make deps
# Run migrations
make migrate-up
# Start the service
make run
```
## ๐ API Endpoints
### HTTP API (Port 8002)
- `GET /v1/translation/history` - Get translation history
- `POST /v1/translation/do-translate` - Translate text
- `GET /healthz` - Health check
- `GET /metrics` - Prometheus metrics
- `GET /swagger/*` - API documentation
### gRPC API (Port 9002)
- Translation service with history management
### AMQP RPC (Port 5672)
- Asynchronous translation requests
## ๐งช Testing
```bash
# Run all tests
make test
# Run integration tests
make integration-test
# Run pre-commit checks
make pre-commit
```
## ๐ Monitoring
- **Health Check**: `http://localhost:8002/healthz`
- **Metrics**: `http://localhost:8002/metrics`
- **Swagger UI**: `http://localhost:8002/swagger/`
## ๐ง Development
```bash
# Format code
make format
# Run linter
make linter-golangci
# Generate mocks
make mock
# Generate swagger docs
make swag-v1
```
## ๐ฆ Environment Variables
```bash
# App
APP_NAME=puchi-user-service
APP_VERSION=1.0.0
# HTTP settings
HTTP_PORT=8002
HTTP_USE_PREFORK_MODE=false
# gRPC
GRPC_PORT=9002
# Database
PG_URL=postgres://user:password@localhost:5432/userdb
PG_POOL_MAX=2
# RabbitMQ
RMQ_URL=amqp://guest:guest@localhost:5672/
RMQ_RPC_SERVER=user_rpc_server
RMQ_RPC_CLIENT=user_rpc_client
# Features
METRICS_ENABLED=true
SWAGGER_ENABLED=true
LOG_LEVEL=debug
```
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Run pre-commit checks (`make pre-commit`)
4. Commit your changes (`git commit -m 'Add amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.