# gilbutitbook/007035 architecture

> Architecture diagram of the GitHub repository gilbutitbook/007035, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gilbutitbook/007035
- Repository: https://github.com/gilbutitbook/007035

## Overview

##### Project type and purpose
- This is a multi‐service reference implementation of the “Microservices Patterns” book.
- It demonstrates a suite of independent Spring Boot microservices (Order, Kitchen, Consumer, Accounting, Restaurant, Order‑History) plus API gateways (REST + GraphQL), using saga orchestration, event sourcing (Eventuate Tram), CQRS, per‐service databases, and Docker/Kubernetes deployment.

##### File structure
- Top‑level orchestration:
- build.gradle, settings.gradle, Gradle wrapper, shell scripts, Docker‐Compose file, Kubernetes manifests under deployment/kubernetes
- Common modules:
- ftgo-common, ftgo-common-jpa, common-swagger
- Microservice directories (each with its own build.gradle, src/main/java, Dockerfile, deployment manifests):
- ftgo-order-service
- ftgo-kitchen-service
- ftgo-consumer-service
- ftgo-accounting-service
- ftgo-restaurant-service (+ AWS Lambda variant)
- ftgo-order-history-service
- API Gateways:
- ftgo-api-gateway (Spring Boot, REST)
- ftgo-api-gateway-graphql (Node.js/TypeScript GraphQL)
- Infrastructure:
- dynamodblocal, mysql, Kafka/Zookeeper via Docker Compose or Kubernetes
- CI/CD:
- .circleci, build‐and‐run scripts, end‑to‑end test project

##### README
- Confirms this is the hands‑on codebase for the microservices patterns book.

##### Final advice
- Be exhaustive: include every microservice, gateway, DB, event bus, and shared library.
- Both client‐to‐service and inter‐service event pathways.
- Design patterns (Saga, CQRS, Event Sourcing) near the relevant flow.
- Keep it readable: you may need to create logical groupings (e.g., Domain Services, Infrastructure, Gateways).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Clients["Clients\n(web/mobile)"]

    %% API Gateways
    RESTGW["API Gateway\n(REST)"]:::gateway
    GQLGW["API Gateway\n(GraphQL)"]:::gateway

    %% Domain Services
    subgraph "Domain Services"
        OrderSvc["Order Service"]:::service
        ConsumerSvc["Consumer Service"]:::service
        KitchenSvc["Kitchen Service"]:::service
        AccountingSvc["Accounting Service"]:::service
        RestaurantSvc["Restaurant Service"]:::service
        RestaurantLambda["Restaurant Service\n(AWS Lambda)"]:::service
        OrderHistorySvc["Order History Service\n(CQRS/Event Sourcing)"]:::service
    end

    %% Databases
    subgraph "Databases"
        MySQLOrder["MySQL\n(Order)"]:::db
        MySQLConsumer["MySQL\n(Consumer)"]:::db
        MySQLKitchen["MySQL\n(Kitchen)"]:::db
        MySQLAccounting["MySQL\n(Accounting)"]:::db
        MySQLRestaurant["MySQL\n(Restaurant)"]:::db
        DynamoOrderHistory["DynamoDB\n(Order History)"]:::db
    end

    %% Event Infrastructure
    subgraph "Event Infrastructure"
        Kafka["Kafka Cluster\n+ ZooKeeper"]:::infra
        EventStore["Event Store\n(Eventuate Tram)"]:::infra
    end

    %% Shared Modules
    subgraph "Shared Modules"
        Common["Common Code"]:::common
        JPACommon["JPA Common"]:::common
        SwaggerCommon["Swagger Config"]:::common
    end

    %% Deployment
    subgraph "Deployment"
        DockerCompose["Docker Compose"]:::infra
        K8sStateful["K8s Stateful Services"]:::infra
        K8sCDC["K8s CDC Services"]:::infra
        CICD["CI/CD Pipeline"]:::infra
    end

    %% Connections: Clients to Gateways
    Clients -->|HTTP/gRPC| RESTGW
    Clients -->|HTTP/gRPC| GQLGW

    %% Gateways to Services (Sync)
    RESTGW -->|"sync"| OrderSvc
    RESTGW -->|"sync"| ConsumerSvc
    RESTGW -->|"sync"| KitchenSvc
    RESTGW -->|"sync"| AccountingSvc
    RESTGW -->|"sync"| RestaurantSvc

    GQLGW -->|"sync"| OrderSvc
    GQLGW -->|"sync"| ConsumerSvc
    GQLGW -->|"sync"| KitchenSvc
    GQLGW -->|"sync"| AccountingSvc
    GQLGW -->|"sync"| RestaurantSvc

    %% Services to their Databases
    OrderSvc -->|"writes"| MySQLOrder
    ConsumerSvc -->|"writes"| MySQLConsumer
    KitchenSvc -->|"writes"| MySQLKitchen
    AccountingSvc -->|"writes"| MySQLAccounting
    RestaurantSvc -->|"writes"| MySQLRestaurant

    %% Asynchronous Event Flows
    OrderSvc -->|"publish events"| Kafka
    ConsumerSvc -->|"subscribe/publish"| Kafka
    KitchenSvc -->|"subscribe/publish"| Kafka
    AccountingSvc -->|"subscribe/publish"| Kafka
    RestaurantSvc -->|"subscribe/publish"| Kafka

    Kafka -->|"CDC/Eventuate"| EventStore
    EventStore -->|"streams"| OrderHistorySvc
    OrderHistorySvc -->|"writes"| DynamoOrderHistory

    %% Shared Modules Usage
    Common --> OrderSvc
    Common --> ConsumerSvc
    Common --> KitchenSvc
    Common --> AccountingSvc
    Common --> RestaurantSvc

    JPACommon --> OrderSvc
    JPACommon --> KitchenSvc

    SwaggerCommon --> RESTGW
    SwaggerCommon --> GQLGW

    %% Deployment Orchestration
    DockerCompose -.-> RESTGW
    DockerCompose -.-> GQLGW
    DockerCompose -.-> OrderSvc
    DockerCompose -.-> Kafka

    K8sStateful -.-> RESTGW
    K8sStateful -.-> OrderSvc
    K8sStateful -.-> Kafka

    K8sCDC -.-> EventStore

    CICD -.-> DockerCompose
    CICD -.-> K8sStateful
    CICD -.-> K8sCDC

    %% Click Events
    click RESTGW "https://github.com/gilbutitbook/007035/tree/master/ftgo-api-gateway/src/main/java/net/chrisrichardson/ftgo/apiagateway"
    click GQLGW "https://github.com/gilbutitbook/007035/blob/master/ftgo-api-gateway-graphql/src/index.js"
    click OrderSvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-order-service/src/main/java/net/chrisrichardson/ftgo/orderservice"
    click KitchenSvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-kitchen-service/src/main/java/net/chrisrichardson/ftgo/kitchenservice"
    click ConsumerSvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-consumer-service/src/main/java/net/chrisrichardson/ftgo/consumerservice"
    click AccountingSvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-accounting-service/src/main/java/net/chrisrichardson/ftgo/accountingservice"
    click RestaurantSvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-restaurant-service/src/main/java/net/chrisrichardson/ftgo/restaurantservice"
    click RestaurantLambda "https://github.com/gilbutitbook/007035/tree/master/ftgo-restaurant-service-aws-lambda/src/main/java/net/chrisrichardson/ftgo/restaurantservice/aws"
    click OrderHistorySvc "https://github.com/gilbutitbook/007035/tree/master/ftgo-order-history-service/src/main/java/net/chrisrichardson/ftgo/cqrs/orderhistory"
    click Common "https://github.com/gilbutitbook/007035/tree/master/ftgo-common/src/main/java/net/chrisrichardson/ftgo/common"
    click JPACommon "https://github.com/gilbutitbook/007035/blob/master/ftgo-common-jpa/src/main/resources/META-INF/orm.xml"
    click SwaggerCommon "https://github.com/gilbutitbook/007035/blob/master/common-swagger/src/main/java/net/chrisrichardson/eventstore/examples/customersandorders/commonswagger/CommonSwaggerConfiguration.java"
    click DockerCompose "https://github.com/gilbutitbook/007035/blob/master/docker-compose.yml"
    click K8sStateful "https://github.com/gilbutitbook/007035/tree/master/deployment/kubernetes/stateful-services"
    click K8sCDC "https://github.com/gilbutitbook/007035/tree/master/deployment/kubernetes/cdc-services"
    click CICD "https://github.com/gilbutitbook/007035/blob/master/.circleci/config.yml"

    %% Styles
    classDef gateway fill:#f9f,stroke:#333,stroke-width:1px
    classDef service fill:#ccf,stroke:#333,stroke-width:1px
    classDef db fill:#cfc,stroke:#333,stroke-width:1px
    classDef infra fill:#fcc,stroke:#333,stroke-width:1px
    classDef common fill:#eee,stroke:#333,stroke-width:1px
```
