# sap-samples/event-driven-integrations-codejam architecture

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

- Interactive diagram: https://gitdiagram.com/sap-samples/event-driven-integrations-codejam
- Repository: https://github.com/sap-samples/event-driven-integrations-codejam

## Overview

##### Project type and purpose
- This repository is a hands-on training (“CodeJam”) for building event-driven integrations on SAP Integration Suite’s Advanced Event Mesh.
- It’s organized as a sequence of exercises that progressively introduce CloudEvents, pub-sub patterns, SDK usage, REST/webhook delivery points, CAP-based consumers, and a final integration adapter.

##### File structure
- Top-level scaffolding (.devcontainer, Dockerfile, VSCode settings) for a consistent dev environment.
- A “.sap” folder with minimal sample apps demonstrating CloudEvents production and consumption.
- Exercise 08: Node.js CloudEvents SDK emitter & listener
- Exercise 09: REST delivery points/webhooks
- Exercise 10: CAP project (CDS models, srv layer, UI5 front ends) consuming from AMQP
- Exercise 11: AEM-Cloud Integration adapter
- Root files: slides (Marp), prerequisites, troubleshooting, licensing, and a master README describing the overall scenario.

##### Key insights from the README
- Scenario: ITeLO Entertainment’s ticket-sales website publishes events (“TicketPurchased”, “VIPPackageOrdered”, “BusinessPartnerApproved”).
- These events flow through SAP’s Advanced Event Mesh (broker) topics.
- Multiple downstream services subscribe: PDF-ticket generator, physical delivery service, VIP-package handler, SAP Build Process Automation (for BP approvals), and more.
- Each exercise simulates one part of this pipeline, culminating in cross-broker routing and SAP Cloud Integration.

##### Components & interactions
a. Producers (left side)
- Ticketing Web App (simulated via sample JSON or CloudEvents SDK)
- VIP-package service
- SAP S/4HANA → sends “BusinessPartnerApproved” events
- CloudEvents SDK demo app (.sap/code/08-cloud-events-sdk)
b. Event Mesh (center)
- SAP Integration Suite, Advanced Event Mesh
- Topics: TicketPurchasedTopic, VIPTopic, BPPApprovedTopic
- Subscriptions: dynamic message routing between brokers
c. Consumers (right side)
- CAP-based AMQP consumer (exercises/10-…/srv/queueConsumer.js)
- PDF-generator microservice (exercises/06)
- REST Delivery Point (exercises/09 → webhook endpoint)
- AEM Cloud Integration Adapter (exercises/11)
- SAP Build Process Automation flow (for BP approvals)
d. Data stores & UIs
- CDS data model and SQLite/HANA instance in CAP project
- UI5 Web UIs for “Consumed Messages” and “Ticket QRCodes” (ex. webapp folders)
e. External systems
- Third-party PDF/print service
- Email/SMS delivery gateway
- SAP Cloud Integration runtime (optional per exercise 11)

##### Architectural patterns & design principles
- Publish-Subscribe: events published to broker topics; multiple independent subscribers.
- CloudEvents specification: ensures uniform event envelope across producers/consumers.
- CAP (Cloud Application Programming) pattern: CDS-first modeling, srv layer, UI5 front ends.
- Microservices: each exercise implements a small service with a single responsibility.
- Dynamic message routing: exchanges messages between Event Broker instances programmatically.

##### Technologies, frameworks & libraries
- Node.js (app.js, server.js, topicPublisher.js)
- AMQP client library (queueConsumer.js)
- CloudEvents SDK for JavaScript (exercises/08)
- CAP framework (cds, annotations.cds, service.cds)
- UI5 for Fiori-style UIs (ui5.yaml, Component.js, manifest.json)
- Docker (Dockerfiles in .devcontainer and CAP microservice)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Producers"
        direction TB
        TP["Ticket Web App\n(Sample JSON)"]:::producer
        CESDKDemo["CloudEvents SDK Demo App"]:::producer
        click CESDKDemo "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/.sap/code/08-cloud-events-sdk/app.js"
        CESDKEx["CloudEvents SDK Exercise"]:::producer
        click CESDKEx "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/08-cloudevents-sdk/code/app.js"
        S4["SAP S/4HANA\n(BP Approved)"]:::sap
    end

    EventMesh["SAP Integration Suite\nAdvanced Event Mesh"]:::sap

    subgraph "Topics"
        direction TB
        TPTopic["TicketPurchasedTopic"]:::sap
        VIPTopic["VIPTopic"]:::sap
        BPPTopic["BPPApprovedTopic"]:::sap
    end

    subgraph "Consumers"
        direction TB
        CAPConsumer["CAP-based AMQP Consumer"]:::consumer
        click CAPConsumer "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/srv/queueConsumer.js"
        PDFService["PDF Generator Microservice"]:::consumer
        click PDFService "https://github.com/sap-samples/event-driven-integrations-codejam/tree/main/exercises/06-publish-and-subscribe-events"
        RESTWebhook["REST Delivery Point\n(Webhook)"]:::consumer
        click RESTWebhook "https://github.com/sap-samples/event-driven-integrations-codejam/tree/main/exercises/09-rest-delivery-points"
        AEMAdapter["AEM Cloud Integration Adapter"]:::consumer
        click AEMAdapter "https://github.com/sap-samples/event-driven-integrations-codejam/tree/main/exercises/11-aem-cloud-integration-adapter"
        BuildFlow["SAP Build Process Automation"]:::sap
    end

    subgraph "CAP Service\n(edi-codejam-cap-processor)"
        direction TB
        CAPServer["CAP Server\n(server.js)"]:::cap
        click CAPServer "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/srv/server.js"
        TopicPub["CAP Topic Publisher"]:::cap
        click TopicPub "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/srv/topicPublisher.js"
        ServiceDef["CAP Service Definitions\n(service.cds)"]:::cap
        click ServiceDef "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/srv/service.cds"
        DataModel["CDS Data Model\n(data-model.cds)"]:::cap
        click DataModel "https://github.com/sap-samples/event-driven-integrations-codejam/blob/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/db/data-model.cds"
        UIConsumed["UI5 \"Consumed Messages\""]:::ui
        click UIConsumed "https://github.com/sap-samples/event-driven-integrations-codejam/tree/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/app/consumed-messages/webapp"
        UITicket["UI5 \"Ticket QR Codes\""]:::ui
        click UITicket "https://github.com/sap-samples/event-driven-integrations-codejam/tree/main/exercises/10-consume-message-from-CAP/code/edi-codejam-cap-processor/app/ticket-qrcodes/webapp"
    end

    subgraph "Persistence"
        DB["SQLite/HANA\n(CDS)"]:::db
    end

    %% Flows
    TP -->|CloudEvents| EventMesh
    CESDKDemo -->|CloudEvents| EventMesh
    CESDKEx -->|CloudEvents| EventMesh
    S4 -->|CloudEvents| EventMesh

    EventMesh -->|AMQP| CAPConsumer
    EventMesh -->|Pub/Sub| PDFService
    EventMesh -->|HTTP/Webhook| RESTWebhook
    EventMesh -->|AMQP| CAPServer
    EventMesh -->|CloudEvents| AEMAdapter
    EventMesh -->|CloudEvents| BuildFlow

    CAPConsumer -->|Insert| DB
    CAPConsumer -->|Notify| UIConsumed
    CAPServer -->|publish| TopicPub
    TopicPub -->|CloudEvents| EventMesh
    UIConsumed -->|query| ServiceDef
    UITicket -->|query| ServiceDef

    classDef producer fill:#cfe2f3,stroke:#084b8a,color:#084b8a
    classDef sap fill:#e7e6e6,stroke:#6f6f6f,color:#333
    classDef consumer fill:#d9ead3,stroke:#38761d,color:#38761d
    classDef cap fill:#f9cb9c,stroke:#b45f06,color:#b45f06
    classDef ui fill:#fff2cc,stroke:#bf9000,color:#bf9000
    classDef db fill:#f4cccc,stroke:#a61c00,color:#a61c00
```
