{"id":44492627,"url":"https://github.com/thanhdaon/tickets","last_synced_at":"2026-02-13T04:01:31.365Z","repository":{"id":336581811,"uuid":"1150247126","full_name":"thanhdaon/tickets","owner":"thanhdaon","description":"Event-driven ticket booking system in Go using CQRS, Event Sourcing, and the Outbox Pattern with Watermill, PostgreSQL, and Redis.","archived":false,"fork":false,"pushed_at":"2026-02-05T10:10:53.000Z","size":469,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-05T17:13:36.393Z","etag":null,"topics":["cqrs","docker","echo","event-driven","go","golang","jaeger","opentelemetry","outbox-pattern","prometheus","ticketing-system","watermill"],"latest_commit_sha":null,"homepage":"https://tickets.previewhub.app","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/thanhdaon.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":"2026-02-05T03:50:31.000Z","updated_at":"2026-02-05T10:10:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/thanhdaon/tickets","commit_stats":null,"previous_names":["thanhdaon/tickets"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/thanhdaon/tickets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhdaon%2Ftickets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhdaon%2Ftickets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhdaon%2Ftickets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhdaon%2Ftickets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanhdaon","download_url":"https://codeload.github.com/thanhdaon/tickets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhdaon%2Ftickets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29395889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T00:53:09.511Z","status":"online","status_checked_at":"2026-02-13T02:00:10.076Z","response_time":78,"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","docker","echo","event-driven","go","golang","jaeger","opentelemetry","outbox-pattern","prometheus","ticketing-system","watermill"],"created_at":"2026-02-13T04:01:24.610Z","updated_at":"2026-02-13T04:01:31.359Z","avatar_url":"https://github.com/thanhdaon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tickets\n\nA Go-based event ticketing system demonstrating event-driven architecture patterns including CQRS, Event Sourcing, and the Outbox Pattern.\n\n## Live Demo\n\n- **Application**: https://tickets.previewhub.app/\n- **Container Logs**: https://dozzle.previewhub.app/\n- **Jaeger Dashboard**: https://jaeger.previewhub.app/\n\n## Features\n\n- **Ticket Management** - Create, track, and manage event tickets\n- **Show Management** - Configure shows with external provider integration (Dead Nation)\n- **Booking System** - Book tickets for shows with confirmation workflows\n- **Refund Processing** - Handle ticket cancellations with receipt voiding and payment refunds\n- **Event-Driven Architecture** - Loosely coupled components communicating via events and commands\n- **Observability** - Distributed tracing, metrics, and health checks\n\n## Demo Screenshots\n\n### Shows Management\n![Shows](./images/shows.png)\n*Create and manage shows with Dead Nation integration*\n\n### Ticket Booking\n![Book Tickets](./images/book-tickets.png)\n*Book tickets for available shows*\n\n### Tickets Overview\n![Tickets](./images/tickets.png)\n*View and manage tickets*\n\n### Operations Report\n![Ops Report](./images/ops-report.png)\n*Monitor bookings and operations with detailed reporting*\n\n## Architecture\n\n### Key Patterns\n\n- **CQRS** (Command Query Responsibility Segregation) - Separate command and event buses\n- **Event Sourcing** - Events as the source of truth for state changes\n- **Outbox Pattern** - Reliable event publishing with PostgreSQL-based outbox\n- **Read Models** - Denormalized views for efficient queries (e.g., ops bookings)\n\n### External Integrations\n\n- **Dead Nation API** - External ticket booking provider\n- **Receipts Service** - Issue and void receipts\n- **Payments Service** - Process refunds\n- **Files API** - Upload ticket files\n- **Spreadsheets API** - Track tickets for printing/refunding\n\n## Tech Stack\n\n| Component | Technology |\n|-----------|------------|\n| Language | Go 1.25.5 |\n| HTTP Framework | Echo v4 |\n| Event Bus | Watermill |\n| Message Broker | Redis Streams |\n| Database | PostgreSQL |\n| Cache | Redis |\n| Tracing | OpenTelemetry + Jaeger |\n| Metrics | Prometheus |\n\n## Project Structure\n\n```\ntickets/\n├── cmd/server/         # Application entrypoint\n├── adapters/           # External service adapters (Dead Nation, Payments, Receipts, Files)\n├── db/                 # Database repositories and migrations\n├── entities/           # Domain entities, events, and commands\n├── http/               # HTTP handlers and routing\n├── message/\n│   ├── command/        # Command bus configuration and handlers\n│   ├── event/          # Event bus configuration and handlers\n│   └── outbox/         # Outbox pattern implementation\n├── observability/      # Tracing and metrics configuration\n├── service/            # Service composition and startup\n├── tests/              # Component and integration tests\n└── docker/             # Docker configuration (Prometheus)\n```\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.25.5+\n- Docker \u0026 Docker Compose\n\n### Environment Setup\n\nCreate `.env.local` for development:\n\n```env\nPOSTGRES_URL=postgres://user:password@localhost:5432/db?sslmode=disable\nREDIS_URL=localhost:6379\nGATEWAY_URL=http://localhost:8888\nOTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318\n```\n\nCreate `.env.test` for testing with similar configuration.\n\n### Running with Docker\n\n```bash\n# Start all dependencies (PostgreSQL, Redis, Prometheus, Jaeger)\nmake docker-up\n\n# Stop and remove volumes\nmake docker-down\n```\n\n### Development\n\n```bash\n# Run the server\nmake dev\n\n# Run tests\nmake test\n\n# Run tests with verbose output\nmake test-verbose\n\n# Run linter\nmake lint\n```\n\n## API Endpoints\n\n### Ticket Operations\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| GET | `/api/tickets` | List all tickets |\n| POST | `/api/tickets-status` | Update ticket status |\n| PUT | `/api/ticket-refund/:ticket_id` | Initiate ticket refund |\n\n### Show Management\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| POST | `/api/shows` | Create a new show |\n\n### Booking Operations\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| POST | `/api/book-tickets` | Book tickets for a show |\n\n### Operations \u0026 Monitoring\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| GET | `/api/ops/bookings` | List all bookings (with optional date filter) |\n| GET | `/api/ops/bookings/:id` | Get booking by ID |\n| GET | `/health` | Health check |\n| GET | `/metrics` | Prometheus metrics |\n\n## Events\n\nThe system publishes and handles the following events:\n\n- `TicketBookingConfirmed_v1` - Ticket booking confirmed\n- `TicketBookingCanceled_v1` - Ticket booking canceled\n- `TicketPrinted_v1` - Ticket file generated\n- `TicketReceiptIssued_v1` - Receipt issued for ticket\n- `TicketRefunded_v1` - Ticket refund completed\n- `BookingMade_v1` - Booking created for a show\n\n## Commands\n\n- `RefundTicket` - Initiates the ticket refund process\n\n## Testing\n\n```bash\n# Run all tests\nmake test\n\n# Run with verbose output\nmake test-verbose\n```\n\nTests cover:\n- Component integration tests\n- Ticket booking workflows\n- Show booking workflows\n- Ticket cancellation flows\n- Refund processing\n\n## Observability\n\n### Jaeger (Tracing)\n\n- **Local**: Access the Jaeger UI at `http://localhost:16686` to view distributed traces\n- **Live Demo**: https://jaeger.previewhub.app/\n\n### Prometheus (Metrics)\n\nAccess Prometheus at `http://localhost:9090`. Metrics are exposed at `/metrics`.\n\n## Docker Services\n\n| Service | Port | Description | Live Demo |\n|---------|------|-------------|-----------|\n| Application | 8080 | Main application | [tickets.previewhub.app](https://tickets.previewhub.app/) |\n| Gateway | 8888 | Event-driven gateway | - |\n| PostgreSQL | 5432 | Database | - |\n| Redis | 6379 | Message broker \u0026 cache | - |\n| Prometheus | 9090 | Metrics collection | - |\n| Jaeger | 16686 | Tracing UI | [jaeger.previewhub.app](https://jaeger.previewhub.app/) |\n| Jaeger OTLP | 4318 | OTLP collector | - |\n| Dozzle | - | Container logs viewer | [dozzle.previewhub.app](https://dozzle.previewhub.app/) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhdaon%2Ftickets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanhdaon%2Ftickets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhdaon%2Ftickets/lists"}