https://github.com/mstryoda/production-ready-microservice-example
https://github.com/mstryoda/production-ready-microservice-example
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mstryoda/production-ready-microservice-example
- Owner: mstrYoda
- Created: 2025-02-15T22:12:29.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-13T20:06:07.000Z (2 months ago)
- Last Synced: 2025-04-08T10:59:58.856Z (about 1 month ago)
- Language: Go
- Size: 46.9 KB
- Stars: 49
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example Microservice
A Go-based microservice with Couchbase integration, metrics, logging and OpenTelemetry support.
## Overview
This service provides REST API endpoints for managing products, utilizing Couchbase as the primary database and implementing distributed tracing with OpenTelemetry.
## Prerequisites
- Go 1.23.4
- Docker and Docker Compose
- Couchbase Server## Tech Stack
- **Language**: Go
- **Database**: Couchbase
- **Distributed Tracing**: OpenTelemetry, Jaeger
- **Container**: Docker
- **Config**: Viper
- **Logger**: Zap
- **Metrics**: Prometheus
- **Monitoring**: Grafana## Project Structure
```lua
├── app
│ └── healthcheck
│── └── health.go
│ └── product
│── └── create_product_handler.go
│── └── get_product_handler.go
│── └── repository.go
├── config
│ └── config.yaml -- App Configuration File
├── domain
│ └── product.go
├── infra
│ └── couchbase
│── └── repository.go
│ └── postgres
│── └── repository.go
├── pkg
│ └── config
│── └── config.go
│ └── log
│── └── log.go
├── Dockerfile
├── docker-compose.yml
├── main.go
```## Getting Started
1. Clone the repository:
```bash
git clone https://github.com/mstrYoda/production-ready-microservice-example.git
```2. Start the required services using Docker Compose:
```bash
docker-compose up -d
```3. Run the application:
```bash
go run main.go
```## API Endpoints
### Products
- `POST /products` - Create a new product
- `GET /products/{id}` - Retrieve a product by ID## Configuration
Configuration is managed through environment variables and config files and can be set in the `docker-compose.yml` file. Key configuration parameters include:
- Couchbase connection settings
- OpenTelemetry configuration
- Application port## Development
### Building the Docker Image
```bash
docker build -t product-service .
```### Running Tests
```bash
go test ./...
```## Observability
This service implements OpenTelemetry for distributed tracing, allowing you to monitor and debug requests across your distributed system.
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request## License
[Add your license information here]