Skip to content

crizstian/cinema-microservice-in-GO

Repository files navigation

Go 1.24+ Java 21 MongoDB 8.0 Redis 7 Docker Harness CI/CD

Cinema Microservices Platform

Enterprise-grade cinema ticketing system built with polyglot microservices
Featuring Go + Java services, real-time seat reservations, payment processing, and event-driven notifications

Documentation β€’ Architecture β€’ API Reference β€’ Development Guide


Overview

This platform implements a complete cinema ticketing workflow using a distributed microservices architecture. Each service is independently deployable, follows domain-driven design principles, and communicates via both synchronous REST APIs and asynchronous NATS messaging.

Key Capabilities:

  • Real-time seat availability with distributed locking
  • SAGA-based booking orchestration with automatic rollback
  • Stripe payment integration with idempotency guarantees
  • Event-driven notifications (email, SMS, push)
  • Contract testing with Pact for service compatibility

Architecture

                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚                      CLIENTS                            β”‚
                                    β”‚              Web App  /  Mobile  /  Kiosk               β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                              β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚                    API GATEWAY                          β”‚
                                    β”‚              Load Balancing / Auth / Rate Limit         β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                              β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                    GO SERVICES (Core Platform)                                                   β”‚
   β”‚                                                          β”‚                                                       β”‚
   β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
   β”‚    β”‚  USER    β”‚   β”‚  MOVIE   β”‚   β”‚  CINEMA  β”‚     β”‚ SHOWTIME β”‚    β”‚   SEAT   β”‚   β”‚ BOOKING  β”‚   β”‚ PAYMENT  β”‚   β”‚
   β”‚    β”‚ :8004    β”‚   β”‚ :8000    β”‚   β”‚ :8085    β”‚     β”‚ :3003    β”‚    β”‚ :3004    β”‚   β”‚ :8082    β”‚   β”‚ :8001    β”‚   β”‚
   β”‚    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β”‚
   β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                              β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                 JAVA SERVICES (Business Intelligence)                                            β”‚
   β”‚                                                          β”‚                                                       β”‚
   β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”‚
   β”‚              β”‚    ANALYTICS      β”‚    β”‚     LOYALTY       β”‚    β”‚     REVIEWS       β”‚                            β”‚
   β”‚              β”‚ :8010 SpringBoot  β”‚    β”‚ :8011 Quarkus     β”‚    β”‚ :8012 Micronaut   β”‚                            β”‚
   β”‚              β”‚ Reports & Metrics β”‚    β”‚ Points & Rewards  β”‚    β”‚ Ratings & Stats   β”‚                            β”‚
   β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                              β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚                    NATS                         β”‚
                                    β”‚           Event Bus / JetStream                 β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                               β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚              NOTIFICATION :8002                 β”‚
                                    β”‚           Email / SMS / Push                    β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Services

Go Services (Core Platform)

Service Port Domain Description
user 8004 Identity Authentication, JWT tokens, user profiles
movie 8000 Catalog Movie metadata, search, recommendations
cinema 8085 Catalog Cinema locations, rooms, amenities
showtime 3003 Schedule Show schedules, pricing, availability windows
seat 3004 Inventory Seat maps, real-time holds, distributed locks
booking 8082 Transaction SAGA orchestrator, reservation lifecycle
payment 8001 Financial Stripe integration, refunds, receipts
notification 8002 Communication Multi-channel delivery, templates, tracking

Java Services (Business Intelligence)

Service Port Framework Description
analytics 8010 Spring Boot 3.2 Reports, sales metrics, business intelligence
loyalty 8011 Quarkus 3.x Points program, tiers, rewards
reviews 8012 Micronaut 4.x Movie reviews, ratings, statistics

Quick Start

Prerequisites

  • Go 1.24+
  • Java 21+ (for Java services)
  • Maven 3.9+ / Gradle 8.5+
  • Docker & Docker Compose
  • Task (recommended) or Make

Development Environment

# Clone repository
git clone https://github.com/crizstian/cinema-microservices.git
cd cinema-microservices

# Option 1: DevContainer (recommended)
# Open in VS Code β†’ "Reopen in Container"

# Option 2: Local setup
go work sync

# Start full dev environment (MongoDB 3-node replica + Redis + NATS + all services)
task dev:up

# View logs
task dev:log

# Stop environment
task dev:down

Running Tests

# Unit tests for single service
task test SERVICE=booking

# Unit tests for all services
task test:all

# Contract tests (Pact consumer + provider)
task test:contract

# Full E2E tests (starts test environment automatically)
task test:e2e

# CI pipeline (lint + unit + contracts + coverage)
task test:ci

Technology Stack

Layer Technology Purpose
Languages Go 1.24, Java 21 Polyglot microservices
Go Framework Echo v4 Lightweight HTTP routing, middleware
Java Frameworks Spring Boot, Quarkus, Micronaut Enterprise Java (comparison-ready)
Database MongoDB 8.0 Document store, replica set transactions
Cache Redis 7 Session management, distributed locks
Messaging NATS JetStream Event streaming, pub/sub
Payments Stripe PCI-compliant payment processing
API Specs OpenAPI 3.0 Contract-first design
Contracts Pact Consumer-driven contract testing
CI/CD Harness Test Intelligence, deployment pipelines
Containers Docker Standardized builds, orchestration

Project Structure

cinema-microservices/
β”œβ”€β”€ services/                    # Microservices (polyglot)
β”‚   β”‚
β”‚   β”‚ # Go Services
β”‚   β”œβ”€β”€ booking/                 # SAGA orchestrator
β”‚   β”œβ”€β”€ cinema/                  # Cinema locations
β”‚   β”œβ”€β”€ movie/                   # Movie catalog
β”‚   β”œβ”€β”€ notification/            # Multi-channel notifications
β”‚   β”œβ”€β”€ payment/                 # Stripe integration
β”‚   β”œβ”€β”€ seat/                    # Real-time seat inventory
β”‚   β”œβ”€β”€ showtime/                # Schedule management
β”‚   β”œβ”€β”€ user/                    # Authentication & profiles
β”‚   β”‚
β”‚   β”‚ # Java Services
β”‚   β”œβ”€β”€ analytics/               # Spring Boot - Reports & metrics
β”‚   β”œβ”€β”€ loyalty/                 # Quarkus - Points & rewards
β”‚   └── reviews/                 # Micronaut - Reviews & ratings
β”‚
β”œβ”€β”€ platform/
β”‚   β”œβ”€β”€ docker/                  # All Dockerfiles
β”‚   β”‚   β”œβ”€β”€ devcontainer/        # Development container (Go + Java)
β”‚   β”‚   β”œβ”€β”€ e2e-runner/          # E2E test runner
β”‚   β”‚   β”œβ”€β”€ go-service/          # Go service build template
β”‚   β”‚   β”œβ”€β”€ java-service/        # Java service build template
β”‚   β”‚   └── mongodb/             # MongoDB init + seeds
β”‚   β”œβ”€β”€ deploy/
β”‚   β”‚   └── docker-compose/      # Docker Compose (dev + test profiles)
β”‚   └── scripts/                 # Build & test automation
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ contracts/               # Pact contract tests
β”‚   └── integration/             # E2E test suite
β”œβ”€β”€ docs/                        # Documentation hub
β”œβ”€β”€ go.work                      # Go workspace configuration
β”œβ”€β”€ Taskfile.yml                 # Task automation (Go + Java)
└── VERSION                      # Semantic versioning

Task Automation

All common operations are automated via Taskfile:

task --list             # List all available tasks

# Build (Go)
task build SERVICE=booking      # Build single service Docker image
task build:all                  # Build all Go service images

# Build (Java)
task java:build SERVICE=analytics    # Build Java service Docker image
task java:build:all                  # Build all Java services

# Development Environment
task dev:up                     # Start dev environment (3 MongoDB replicas)
task dev:down                   # Stop and clean volumes
task dev:log                    # Stream logs (optionally: SERVICE=booking)
task dev:clean                  # Remove images and build cache

# Testing (Go)
task test SERVICE=booking       # Unit tests for single service
task test:all                   # Unit tests for all Go services
task test:contract              # Pact contract tests
task test:e2e                   # End-to-end tests (full system)

# Testing (Java)
task java:test SERVICE=analytics     # Unit tests for Java service
task java:test:all                   # Unit tests for all Java services

# Run locally (Java)
task java:run SERVICE=analytics      # Run Java service in dev mode

Documentation

Section Description
Documentation Hub Start here β€” system overview and navigation
Architecture C4 diagrams, data flows, ADRs
Services Detailed service specifications
API Reference OpenAPI specs, error handling
Development Setup, testing, code style
Operations CI/CD pipelines, deployment
Contracts Pact testing, consumer/provider

Contributing

  1. Review the Development Guide
  2. Create a feature branch from main
  3. Write tests following the testing pyramid
  4. Run task test:ci before submitting
  5. Open a Pull Request with a clear description

Version

Current: 0.1.0 | License: MIT

Built with precision for scalability and maintainability

About

Example of a cinema microservice written in Golang deployed on Hashicorp Stack tools

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors