# leowmjw/go-event-driven architecture

> Architecture diagram of the GitHub repository leowmjw/go-event-driven, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leowmjw/go-event-driven
- Repository: https://github.com/leowmjw/go-event-driven

## Overview

##### Main Components

a) Core Bounded Contexts (Services):
- Customers Service (internal/customers)
- Ordering Service (internal/ordering)
- Analytics Service (internal/analytics)

b) Infrastructure Components:
- MongoDB (indicated by mongodb directory)
- Temporal (workflow engine, indicated by temporal directory)
- Bento (configuration and projections system)

##### Service Layer
- Internal components for each service:
- Customers: Repository, Forwarder, Types
- Ordering: Workflow, Activities, Service
- Analytics: Analytics components

##### Infrastructure Layer
- MongoDB database
- Temporal workflow engine
- Bento projections system

##### Event Flow Layer
- Event buses/channels between services
- Workflow orchestration paths

Specific Instructions:

##### Use these symbols
- Rectangles with rounded corners for bounded contexts
- Hexagons for external services (Temporal)

##### Component Relationships
- Event flow from Customers to other services
- Projection paths from services to Bento
- Database connections to MongoDB

##### Details
- Async workflows in the Ordering service
- Event forwarding paths in the Customer service
- Analytics data flow

Key Architectural Patterns to Highlight:

##### Event-Driven Architecture
- Event publication/subscription patterns
- Event flow directions

##### CQRS Pattern (if used)
- Separation of command and query responsibilities
- How projections are used

##### Workflow Orchestration
- Temporal's role in managing workflows
- Activity execution paths

Level of Detail Guidelines:

- High Level: Show bounded contexts and their interactions
- Medium Level: Include internal service components
- Low Level: Add configuration and deployment details

Additional Notes:
- Annotations for key architectural decisions
- Configuration flow from Bento to services
- Where tests exist (based on _test.go files)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Service_Layer
        subgraph Customers
            CR["Repository"]:::customers
            CF["Forwarder"]:::customers
            CT["Types"]:::customers
        end

        subgraph Ordering
            OW["Workflow"]:::ordering
            OA["Activities"]:::ordering
            OS["Service"]:::ordering
        end

        subgraph Analytics
            AN["Analytics Service"]:::analytics
        end
    end

    subgraph Infrastructure_Layer
        MongoDB[(MongoDB)]:::infra
        Temporal{{"Temporal Engine"}}:::infra
        
        subgraph Bento["Bento Projections"]
            BC["Config"]:::bento
            BP["Projections"]:::bento
            BMI["MongoDB Input"]:::bento
        end
    end

    %% Relationships
    CR --> CF
    CF --> CT
    CF -.-> AN
    
    OW <--> Temporal
    OA <--> Temporal
    OS --> OW
    
    CR --> MongoDB
    OS --> MongoDB
    AN --> MongoDB
    
    CR -.-> Bento
    OS -.-> Bento
    AN -.-> Bento

    %% Click Events
    click CR "https://github.com/leowmjw/go-event-driven/blob/main/internal/customers/repository.go"
    click CF "https://github.com/leowmjw/go-event-driven/blob/main/internal/customers/forwarder.go"
    click CT "https://github.com/leowmjw/go-event-driven/blob/main/internal/customers/types.go"
    click OW "https://github.com/leowmjw/go-event-driven/blob/main/internal/ordering/workflow.go"
    click OA "https://github.com/leowmjw/go-event-driven/blob/main/internal/ordering/activities.go"
    click OS "https://github.com/leowmjw/go-event-driven/blob/main/internal/ordering/service.go"
    click AN "https://github.com/leowmjw/go-event-driven/tree/main/internal/analytics/"
    click MongoDB "https://github.com/leowmjw/go-event-driven/tree/main/mongodb/"
    click Temporal "https://github.com/leowmjw/go-event-driven/tree/main/temporal/"
    click BC "https://github.com/leowmjw/go-event-driven/blob/main/bento/customers-projection/config.yml"
    click BP "https://github.com/leowmjw/go-event-driven/blob/main/bento/customers-projection/config-projection.yml"
    click BMI "https://github.com/leowmjw/go-event-driven/blob/main/bento/customers-projection/config-mongo-input.yml"

    %% Styling
    classDef customers fill:#3498db,stroke:#2980b9,color:white
    classDef ordering fill:#2ecc71,stroke:#27ae60,color:white
    classDef analytics fill:#e67e22,stroke:#d35400,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef bento fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1["Customers Service"]:::customers
        L2["Ordering Service"]:::ordering
        L3["Analytics Service"]:::analytics
        L4["Infrastructure"]:::infra
        L5["Bento Components"]:::bento
    end
```
