# headmaster21/counter-tours-operator architecture

> Architecture diagram of the GitHub repository headmaster21/counter-tours-operator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/headmaster21/counter-tours-operator
- Repository: https://github.com/headmaster21/counter-tours-operator

## Overview

Counter is a multi-tenant tour-operator operations platform, with separate Angular apps and Spring services; each tenant has its own realm and service databases. The principal workflow runs from booking through dispatch assignment and authorization, GPS tracking, service closure, and optional billing, with reporting and notifications as supporting capabilities. The README documents these domain relationships and the Kafka event architecture. Sampled source confirms route selection and tracking queries, but most service internals were not sampled, so the diagram does not infer finer-grained calls.

Main entry points: [`infrastructure/api-gateway/src/main/java/com/appsworks/counter/gateway`](https://github.com/headmaster21/counter-tours-operator/tree/main/infrastructure/api-gateway/src/main/java/com/appsworks/counter/gateway) (API gateway), [`services/dispatch-service`](https://github.com/headmaster21/counter-tours-operator/tree/main/services/dispatch-service) (Dispatch), [`libs/common-lib/src/main/java/com/appsworks/counter/common/events/Topics.java`](https://github.com/headmaster21/counter-tours-operator/blob/main/libs/common-lib/src/main/java/com/appsworks/counter/common/events/Topics.java) (Kafka events), [`services/tracking-service`](https://github.com/headmaster21/counter-tours-operator/tree/main/services/tracking-service) (Tracking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User applications"]
  node_backoffice["Backoffice"]
  node_booking_site["Booking site"]
  node_partner_portal["Partner portal"]
  node_driver_app["Driver app"]
end

subgraph group_operations["Reservations and operations"]
  node_catalog["Catalog"]
  node_pricing["Pricing"]
  node_booking[("Bookings")]
  node_fleet[("Fleet")]
  node_dispatch[("Dispatch")]
end

subgraph group_tracking["Tracking and insights"]
  node_tracking_service[("Tracking")]
  node_billing[("Billing")]
  node_reports[("Reporting")]
  node_notifications["Notifications"]
end

subgraph group_platform["Platform services"]
  node_gateway["API gateway"]
  node_tenant[("Tenant management")]
  node_identity["Keycloak"]
end

subgraph group_shared["Shared infrastructure"]
  node_kafka["Kafka events<br/>[Topics.java]"]
  node_outbox["Transactional outbox"]
  node_shared_lib["Shared services library"]
end

node_staff(("Operations staff"))
node_customer(("Booking customer"))
node_driver(("Driver"))
node_gps["GPS / Traccar"]

node_staff -->|"operates"| node_backoffice
node_customer -->|"books through"| node_booking_site
node_customer -->|"books through"| node_partner_portal
node_driver -->|"uses"| node_driver_app
node_backoffice -->|"calls services via"| node_gateway
node_booking_site -->|"calls services via"| node_gateway
node_partner_portal -->|"calls services via"| node_gateway
node_driver_app -->|"calls services via"| node_gateway
node_gateway -->|"routes to"| node_catalog
node_gateway -->|"routes to"| node_pricing
node_gateway -->|"routes to"| node_booking
node_gateway -->|"routes to"| node_fleet
node_gateway -->|"routes to"| node_dispatch
node_gateway -->|"routes to"| node_tracking_service
node_gateway -->|"routes to"| node_billing
node_gateway -->|"routes to"| node_reports
node_gateway -->|"routes to"| node_tenant
node_identity -->|"issues JWTs for"| node_gateway
node_booking -->|"confirmed booking creates order"| node_dispatch
node_fleet -->|"validates assignment"| node_dispatch
node_dispatch -->|"authorization opens trip"| node_tracking_service
node_gps -->|"sends positions and events"| node_tracking_service
node_tracking_service -->|"updates service status"| node_dispatch
node_dispatch -->|"service closure feeds billing"| node_billing
node_dispatch -->|"service closure updates manifest"| node_reports
node_dispatch -->|"closure updates odometer"| node_fleet
node_booking -->|"publishes domain events"| node_kafka
node_dispatch -->|"publishes domain events"| node_kafka
node_tracking_service -->|"publishes domain events"| node_kafka
node_kafka -->|"drives notifications"| node_notifications
node_kafka -->|"delivers domain events"| node_billing
node_outbox -.->|"relays events"| node_kafka
node_tenant -.->|"provides tenant profile"| node_backoffice
node_shared_lib -.->|"shared UI and API support"| node_backoffice

click node_backoffice "https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/backoffice/src/app"
click node_booking_site "https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/booking-site/src/app"
click node_partner_portal "https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/partner-portal/src/app"
click node_driver_app "https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/driver-app/src/app"
click node_gateway "https://github.com/headmaster21/counter-tours-operator/tree/main/infrastructure/api-gateway/src/main/java/com/appsworks/counter/gateway"
click node_catalog "https://github.com/headmaster21/counter-tours-operator/tree/main/services/catalog-service"
click node_pricing "https://github.com/headmaster21/counter-tours-operator/tree/main/services/pricing-service"
click node_booking "https://github.com/headmaster21/counter-tours-operator/tree/main/services/booking-service"
click node_fleet "https://github.com/headmaster21/counter-tours-operator/tree/main/services/fleet-service"
click node_dispatch "https://github.com/headmaster21/counter-tours-operator/tree/main/services/dispatch-service"
click node_tracking_service "https://github.com/headmaster21/counter-tours-operator/tree/main/services/tracking-service"
click node_billing "https://github.com/headmaster21/counter-tours-operator/tree/main/services/billing-service"
click node_reports "https://github.com/headmaster21/counter-tours-operator/tree/main/services/report-service"
click node_notifications "https://github.com/headmaster21/counter-tours-operator/tree/main/services/notification-service"
click node_tenant "https://github.com/headmaster21/counter-tours-operator/tree/main/services/tenant-service"
click node_kafka "https://github.com/headmaster21/counter-tours-operator/blob/main/libs/common-lib/src/main/java/com/appsworks/counter/common/events/Topics.java"
click node_outbox "https://github.com/headmaster21/counter-tours-operator/blob/main/libs/common-lib/src/main/java/com/appsworks/counter/common/outbox/OutboxPublisher.java"
click node_shared_lib "https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/shared/src/lib"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backoffice,node_booking_site,node_partner_portal,node_driver_app toneBlue
class node_catalog,node_pricing,node_booking,node_fleet,node_dispatch toneAmber
class node_tracking_service,node_billing,node_reports,node_notifications toneMint
class node_gateway,node_tenant,node_identity toneRose
class node_kafka,node_outbox,node_shared_lib,node_staff,node_customer,node_driver,node_gps toneIndigo
```

## Components

### User applications

- [Backoffice](https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/backoffice/src/app): `frontend/projects/backoffice/src/app`
- [Booking site](https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/booking-site/src/app): `frontend/projects/booking-site/src/app`
- [Partner portal](https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/partner-portal/src/app): `frontend/projects/partner-portal/src/app`
- [Driver app](https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/driver-app/src/app): `frontend/projects/driver-app/src/app`

### Reservations and operations

- [Catalog](https://github.com/headmaster21/counter-tours-operator/tree/main/services/catalog-service): `services/catalog-service`
- [Pricing](https://github.com/headmaster21/counter-tours-operator/tree/main/services/pricing-service): `services/pricing-service`
- [Bookings](https://github.com/headmaster21/counter-tours-operator/tree/main/services/booking-service): `services/booking-service`
- [Fleet](https://github.com/headmaster21/counter-tours-operator/tree/main/services/fleet-service): `services/fleet-service`
- [Dispatch](https://github.com/headmaster21/counter-tours-operator/tree/main/services/dispatch-service): `services/dispatch-service`

### Tracking and insights

- [Tracking](https://github.com/headmaster21/counter-tours-operator/tree/main/services/tracking-service): `services/tracking-service`
- [Billing](https://github.com/headmaster21/counter-tours-operator/tree/main/services/billing-service): `services/billing-service`
- [Reporting](https://github.com/headmaster21/counter-tours-operator/tree/main/services/report-service): `services/report-service`
- [Notifications](https://github.com/headmaster21/counter-tours-operator/tree/main/services/notification-service): `services/notification-service`

### Platform services

- [API gateway](https://github.com/headmaster21/counter-tours-operator/tree/main/infrastructure/api-gateway/src/main/java/com/appsworks/counter/gateway): `infrastructure/api-gateway/src/main/java/com/appsworks/counter/gateway`
- [Tenant management](https://github.com/headmaster21/counter-tours-operator/tree/main/services/tenant-service): `services/tenant-service`
- **Keycloak**

### Shared infrastructure

- [Kafka events](https://github.com/headmaster21/counter-tours-operator/blob/main/libs/common-lib/src/main/java/com/appsworks/counter/common/events/Topics.java): `libs/common-lib/src/main/java/com/appsworks/counter/common/events/Topics.java`
- [Transactional outbox](https://github.com/headmaster21/counter-tours-operator/blob/main/libs/common-lib/src/main/java/com/appsworks/counter/common/outbox/OutboxPublisher.java): `libs/common-lib/src/main/java/com/appsworks/counter/common/outbox/OutboxPublisher.java`
- [Shared services library](https://github.com/headmaster21/counter-tours-operator/tree/main/frontend/projects/shared/src/lib): `frontend/projects/shared/src/lib`

### Other components

- **Operations staff**
- **Booking customer**
- **Driver**
- **GPS / Traccar**

## Connections

- Operations staff → Backoffice: operates
- Booking customer → Booking site: books through
- Booking customer → Partner portal: books through
- Driver → Driver app: uses
- Backoffice → API gateway: calls services via
- Booking site → API gateway: calls services via
- Partner portal → API gateway: calls services via
- Driver app → API gateway: calls services via
- API gateway → Catalog: routes to
- API gateway → Pricing: routes to
- API gateway → Bookings: routes to
- API gateway → Fleet: routes to
- API gateway → Dispatch: routes to
- API gateway → Tracking: routes to
- API gateway → Billing: routes to
- API gateway → Reporting: routes to
- API gateway → Tenant management: routes to
- Keycloak → API gateway: issues JWTs for
- Bookings → Dispatch: confirmed booking creates order
- Fleet → Dispatch: validates assignment
- Dispatch → Tracking: authorization opens trip
- GPS / Traccar → Tracking: sends positions and events
- Tracking → Dispatch: updates service status
- Dispatch → Billing: service closure feeds billing
- Dispatch → Reporting: service closure updates manifest
- Dispatch → Fleet: closure updates odometer
- Bookings → Kafka events: publishes domain events (evidence: `services/booking-service/src/main/java/com/appsworks/counter/booking/application/WebBookingService.java`)
- Dispatch → Kafka events: publishes domain events
- Tracking → Kafka events: publishes domain events
- Kafka events → Notifications: drives notifications
- Kafka events → Billing: delivers domain events (evidence: `services/billing-service/src/main/java/com/appsworks/counter/billing/application/InvoiceService.java`)
- Transactional outbox → Kafka events: relays events
- Tenant management → Backoffice: provides tenant profile
- Shared services library → Backoffice: shared UI and API support
