{"id":35266687,"url":"https://github.com/telemetryflow/demo-go-order-service","last_synced_at":"2026-06-01T10:00:44.576Z","repository":{"id":330501060,"uuid":"1122409499","full_name":"telemetryflow/demo-go-order-service","owner":"telemetryflow","description":"[GENERATED TelemetryFlow GO SDK] Order-Service - RESTful API with DDD + CQRS Pattern","archived":false,"fork":false,"pushed_at":"2026-05-27T09:53:40.000Z","size":303,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-27T11:26:50.639Z","etag":null,"topics":["cqrs","cqrs-pattern","ddd-architecture","ddd-patterns","devopscorner","opentelemetry","opentelemetry-collector","opentelemetry-go","telemetryflow"],"latest_commit_sha":null,"homepage":"https://telemetryflow.id","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telemetryflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-24T17:01:27.000Z","updated_at":"2026-05-27T09:52:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/telemetryflow/demo-go-order-service","commit_stats":null,"previous_names":["telemetryflow/order-service","telemetryflow/demo-go-order-service"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/telemetryflow/demo-go-order-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telemetryflow%2Fdemo-go-order-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telemetryflow%2Fdemo-go-order-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telemetryflow%2Fdemo-go-order-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telemetryflow%2Fdemo-go-order-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telemetryflow","download_url":"https://codeload.github.com/telemetryflow/demo-go-order-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telemetryflow%2Fdemo-go-order-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33769492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","cqrs-pattern","ddd-architecture","ddd-patterns","devopscorner","opentelemetry","opentelemetry-collector","opentelemetry-go","telemetryflow"],"created_at":"2025-12-30T10:49:53.125Z","updated_at":"2026-06-01T10:00:44.569Z","avatar_url":"https://github.com/telemetryflow.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Order-Service\n\n\u003cdiv align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/telemetryflow/.github/raw/main/docs/assets/tfo-logo-sdk-dark.svg\"\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/telemetryflow/.github/raw/main/docs/assets/tfo-logo-sdk-light.svg\"\u003e\n    \u003cimg src=\"https://github.com/telemetryflow/.github/raw/main/docs/assets/tfo-logo-sdk-light.svg\" alt=\"TelemetryFlow Logo\" width=\"80%\"\u003e\n  \u003c/picture\u003e\n\n[![Version](https://img.shields.io/badge/Version-1.2.0-orange.svg)](CHANGELOG.md)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Go Version](https://img.shields.io/badge/Go-1.26+-00ADD8?logo=go)](https://golang.org/)\n[![OpenTelemetry](https://img.shields.io/badge/OTLP-100%25%20Compliant-success?logo=opentelemetry)](https://opentelemetry.io/)\n[![Docker](https://img.shields.io/badge/Docker-Ready-2496ED?style=flat\u0026logo=docker)](https://hub.docker.com/r/telemetryflow/telemetryflow-sdk)\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003e[GENERATED TelemetryFlow SDK]\u003c/strong\u003e Order-Service - RESTful API with DDD + CQRS Pattern\n\u003c/p\u003e\n\n---\n\n\n\n## Architecture\n\nThis project follows **Domain-Driven Design (DDD)** with **CQRS (Command Query Responsibility Segregation)** pattern.\n\n```\nOrder-Service/\n├── cmd/\n│   └── api/                    # Application entry point\n├── internal/\n│   ├── domain/                 # Domain Layer (Core Business Logic)\n│   │   ├── entity/             # Domain entities\n│   │   ├── repository/         # Repository interfaces\n│   │   └── valueobject/        # Value objects\n│   ├── application/            # Application Layer (Use Cases)\n│   │   ├── command/            # Commands (write operations)\n│   │   ├── query/              # Queries (read operations)\n│   │   ├── handler/            # Command \u0026 Query handlers\n│   │   └── dto/                # Data Transfer Objects\n│   └── infrastructure/         # Infrastructure Layer\n│       ├── persistence/        # Database implementations\n│       ├── http/               # HTTP server \u0026 handlers\n│       └── config/             # Configuration\n├── pkg/                        # Shared packages\n├── telemetry/                  # TelemetryFlow integration\n├── config/                     # Service configurations\n│   └── otel/                   # OpenTelemetry Collector config\n├── docs/                       # Documentation\n│   ├── api/                    # OpenAPI/Swagger specs\n│   ├── diagrams/               # ERD, DFD diagrams\n│   └── postman/                # Postman collections\n├── migrations/                 # Database migrations\n├── configs/                    # Application configuration files\n└── tests/                      # Tests\n    ├── unit/\n    ├── integration/\n    └── e2e/\n```\n\n## Quick Start\n\n### Prerequisites\n\n- Go 1.26+\n- PostgreSQL 16+\n- Docker \u0026 Docker Compose (recommended)\n\n### Setup\n\n1. Clone the repository\n\n2. Copy environment file:\n   ```bash\n   cp .env.example .env\n   ```\n\n3. Edit `.env` with your configuration\n\n4. Install dependencies:\n   ```bash\n   make deps\n   ```\n\n5. Run migrations:\n   ```bash\n   make migrate-up\n   ```\n\n6. Start the server:\n   ```bash\n   make run\n   ```\n\n## Docker Compose\n\nThe easiest way to run the service with all dependencies:\n\n```bash\n# Start all services (PostgreSQL + API + OpenTelemetry Collector)\nmake docker-compose-up\n\n# Or use profiles for selective startup\ndocker compose --profile all up -d        # Start everything\ndocker compose --profile db up -d         # Start only PostgreSQL\ndocker compose --profile app up -d        # Start only API\ndocker compose --profile monitoring up -d # Start only OTEL Collector\n\n# Stop all services\nmake docker-compose-down\n\n# View logs\ndocker logs -f order_service_api\ndocker logs -f order_service_postgres\ndocker logs -f order_service_otel\n```\n\n### Profiles\n\n| Profile | Services |\n|---------|----------|\n| `db` | PostgreSQL |\n| `app` | API (Order Service) |\n| `monitoring` | TFO-Collector, Prometheus |\n| `platform` | TFO-Backend, TFO-Viz, PostgreSQL, ClickHouse, Redis, NATS |\n| `all` | All services |\n\n```bash\n# Start platform services for end-to-end observability\ndocker compose --profile platform up -d\n\n# Start development stack\ndocker compose --profile db --profile app --profile monitoring up -d\n\n# Start everything\ndocker compose --profile all up -d\n```\n\n### Services\n\n| Service | Container | Port | Description |\n|---------|-----------|------|-------------|\n| PostgreSQL | `TFO-SDK-PostgreSQL` | 5432 | Order database |\n| API | `TFO-SDK-Order-Service` | 8080 | RESTful API |\n| TFO-Collector | `TFO-SDK-OTEL` | 4317, 4318, 8889, 13133, 55679, 1777 | TelemetryFlow Collector (v1.2.1) |\n| Prometheus | `TFO-SDK-Prometheus` | 9090 | Metrics collection |\n| TFO-Backend | `TFO-Platform-Backend` | 8081 | TelemetryFlow Platform API (platform profile) |\n| TFO-Viz | `TFO-Platform-Viz` | 3000 | TelemetryFlow Visualization UI (platform profile) |\n\n### OTEL Collector Ports\n\n| Port  | Protocol | Description           |\n| ----- | -------- | --------------------- |\n| 4317  | gRPC     | OTLP gRPC (v1 \u0026 v2)   |\n| 4318  | HTTP     | OTLP HTTP (v1 \u0026 v2)   |\n| 8889  | HTTP     | Prometheus metrics    |\n| 13133 | HTTP     | Health check          |\n| 55679 | HTTP     | zPages (debugging)    |\n| 1777  | HTTP     | pprof (profiling)     |\n\n### OTLP Endpoints (Dual Ingestion)\n\nThe collector supports both TelemetryFlow (v2) and OTEL Community (v1) endpoints:\n\n**TelemetryFlow Platform (Recommended):**\n\n```text\nPOST http://localhost:4318/v2/traces\nPOST http://localhost:4318/v2/metrics\nPOST http://localhost:4318/v2/logs\n```\n\n**OTEL Community (Backwards Compatible):**\n\n```text\nPOST http://localhost:4318/v1/traces\nPOST http://localhost:4318/v1/metrics\nPOST http://localhost:4318/v1/logs\n```\n\n**gRPC:** `localhost:4317` (both v1 and v2)\n\n### Network Configuration\n\nAll services run on a custom Docker network `order_service_net` with subnet `172.152.0.0/16`:\n\n| Service | IP Address |\n|---------|------------|\n| API | 172.152.152.10 |\n| PostgreSQL | 172.152.152.20 |\n| OTEL Collector | 172.152.152.30 |\n\n## Development\n\n### Running locally\n\n```bash\n# Build and run\nmake run\n\n# Run with hot reload\nmake dev\n\n# Run tests\nmake test\n\n# Build binary\nmake build\n```\n\n### Adding a new entity\n\nUse the TelemetryFlow RESTful API Generator:\n\n```bash\ntelemetryflow-restapi entity -n Product -f 'name:string,price:float64,stock:int'\n```\n\nThis generates:\n- Domain entity\n- Repository interface \u0026 implementation\n- CQRS commands \u0026 queries\n- HTTP handlers\n- Database migration\n\n## API Documentation\n\n| Documentation | Location |\n|--------------|----------|\n| OpenAPI Spec | `docs/api/openapi.yaml` |\n| Swagger JSON | `docs/api/swagger.json` |\n| ERD Diagram | `docs/diagrams/ERD.md` |\n| DFD Diagram | `docs/diagrams/DFD.md` |\n| Postman Collection | `docs/postman/collection.json` |\n\n### API Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| GET | `/health` | Health check |\n| GET | `/api/v1/orders` | List all orders |\n| POST | `/api/v1/orders` | Create order |\n| GET | `/api/v1/orders/:id` | Get order by ID |\n| PUT | `/api/v1/orders/:id` | Update order |\n| DELETE | `/api/v1/orders/:id` | Delete order |\n| GET | `/api/v1/orderitems` | List all order items |\n| POST | `/api/v1/orderitems` | Create order item |\n| GET | `/api/v1/orderitems/:id` | Get order item by ID |\n| PUT | `/api/v1/orderitems/:id` | Update order item |\n| DELETE | `/api/v1/orderitems/:id` | Delete order item |\n\n## Configuration\n\nConfiguration is loaded from environment variables and `.env` file.\n\n### Application Configuration\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `SERVER_PORT` | HTTP server port | `8080` |\n| `SERVER_READ_TIMEOUT` | Read timeout | `15s` |\n| `SERVER_WRITE_TIMEOUT` | Write timeout | `15s` |\n| `ENV` | Environment (development/production) | `development` |\n\n### Database Configuration\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `DB_DRIVER` | Database driver | `postgres` |\n| `DB_HOST` | Database host | `localhost` |\n| `DB_PORT` | Database port | `5432` |\n| `DB_NAME` | Database name | `orders` |\n| `DB_USER` | Database user | `postgres` |\n| `DB_PASSWORD` | Database password | - |\n| `DB_SSL_MODE` | SSL mode | `disable` |\n| `DB_MAX_OPEN_CONNS` | Max open connections | `25` |\n| `DB_MAX_IDLE_CONNS` | Max idle connections | `5` |\n| `DB_CONN_MAX_LIFETIME` | Connection max lifetime | `5m` |\n\n### JWT Configuration\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `JWT_SECRET` | JWT signing secret | - |\n| `JWT_REFRESH_SECRET` | JWT refresh secret | - |\n| `JWT_EXPIRATION` | Token expiration | `24h` |\n| `JWT_REFRESH_EXPIRATION` | Refresh token expiration | `168h` |\n\n### TelemetryFlow / OpenTelemetry Configuration\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `TELEMETRYFLOW_API_KEY_ID` | TelemetryFlow API Key ID | - |\n| `TELEMETRYFLOW_API_KEY_SECRET` | TelemetryFlow API Key Secret | - |\n| `TELEMETRYFLOW_ENDPOINT` | OTLP endpoint | `localhost:4317` |\n| `TELEMETRYFLOW_SERVICE_NAME` | Service name | `Order-Service` |\n| `TELEMETRYFLOW_SERVICE_VERSION` | Service version | `1.2.0` |\n\n### Docker Compose Configuration\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `POSTGRES_VERSION` | PostgreSQL image version | `16-alpine` |\n| `OTEL_VERSION` | OTEL Collector image version | `latest` |\n| `CONTAINER_POSTGRES` | PostgreSQL container name | `order_service_postgres` |\n| `CONTAINER_API` | API container name | `order_service_api` |\n| `CONTAINER_OTEL` | OTEL container name | `order_service_otel` |\n| `PORT_OTEL_GRPC` | OTEL gRPC port | `4317` |\n| `PORT_OTEL_HTTP` | OTEL HTTP port | `4318` |\n| `PORT_OTEL_METRICS` | OTEL metrics port | `8889` |\n\n## Testing\n\n```bash\n# Run all tests\nmake test\n\n# Run unit tests only\nmake test-unit\n\n# Run integration tests\nmake test-integration\n\n# Generate coverage report\nmake test-coverage\n```\n\n## Docker\n\n```bash\n# Build image\nmake docker-build\n\n# Run container\nmake docker-run\n\n# Start all services (app + database + monitoring)\nmake docker-compose-up\n\n# Stop all services\nmake docker-compose-down\n```\n\n## Observability\n\nThe service is instrumented with OpenTelemetry for:\n- **Traces**: Distributed tracing for request flows\n- **Metrics**: Application and runtime metrics\n- **Logs**: Structured logging\n\nThe OpenTelemetry Collector receives telemetry data and exports to:\n- TelemetryFlow Platform (via `platform` profile - TFO-Backend + TFO-Viz)\n- Prometheus (metrics)\n\n### Prometheus Metrics\n\nAccess metrics at: `http://localhost:8889/metrics`\n\n### TelemetryFlow Platform\n\nFor full observability visualization, start the platform profile:\n\n```bash\ndocker compose --profile platform up -d\n```\n\nThis brings up TFO-Backend, TFO-Viz, and supporting infrastructure (PostgreSQL, ClickHouse, Redis, NATS) for end-to-end telemetry visualization.\n\n## License\n\nCopyright (c) 2024-2026 TelemetryFlow. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelemetryflow%2Fdemo-go-order-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelemetryflow%2Fdemo-go-order-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelemetryflow%2Fdemo-go-order-service/lists"}