# tforster/webproducer architecture

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

- Interactive diagram: https://gitdiagram.com/tforster/webproducer
- Repository: https://github.com/tforster/webproducer

## Overview

##### Main Components

a. External Systems:
- CMS (Webhook Source)
- AWS Services (Lambda, S3, CloudFront, IAM)
- Data Sources (GraphQL endpoint, with future support for REST, SQL, MongoDB)

b. Core Components:
- WebProducer Lambda Function
- Template System
- File Adapters (S3, Amplify, Zip)
- Configuration Management
- Build Pipeline

**┌─ External Triggers ─┐    ┌─ Core Processing ─┐    ┌─ Storage/Delivery ─┐**

- CMS Webhook     │───▶│  - Lambda Function │───▶│  - S3 Bucket      │
- Build Pipeline  │    │  - CloudFront CDN │
- ┘    └────────────────────┘    └────────────────────┘

##### Component Relationships

Following flows:
- CMS Webhook → Lambda Function
- Lambda Function → Data Source (GraphQL)
- Lambda Function → Template Source
- Build Pipeline → S3/CloudFront
- CloudFront → End Users

##### Detailed Component Breakdown

The Lambda Function should be expanded to show its internal processes:
**┌─ Lambda Function ────────────────────┐**

- 1. Content Fetch                     │
- 2. File List & ETag Check           │
- 3. Theme Loading                     │
- 4. Content/Theme Merger             │
- 5. Asset Processing                  │
- 6. Sitemap/RSS Generation           │
- 7. Diff Generation                   │
- 8. Target Deployment                 │
- 9. CloudFront Invalidation          │
- ┘

##### Configuration Layer

A separate configuration layer that includes:
- webproducer.yml configuration
- Environment variables
- Data source aliases
- Template aliases
- Destination aliases

##### File Adapter Layer

Different file adapters:
- AmplifyFileAdapter
- S3FileAdapter
- ZipFileAdapter

##### Important Details

- Serverless architecture
- Future expansion possibilities (Google, Microsoft)
- Version information
- Environment stages (dev, stage, prod)

##### Notes for Implementation

- Notes about AWS dependency
- Extension points for future provider support

Remember to maintain a balance between showing the overall architecture and including important implementation details that affect the system's behavior and scalability.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Layer"]
        CMS["CMS Webhook Source"]
        GraphQL["GraphQL Endpoint"]:::datasource
    end

    subgraph Lambda["Lambda Function Layer"]
        direction TB
        Entry["Lambda Entry Point"]:::code
        Config["Configuration Manager"]:::code
        DataSource["Data Source Manager"]:::code
        GraphQLAdapter["GraphQL Adapter"]:::code
        PageBuilder["Page Builder"]:::code
        MergeStream["Content Merger"]:::code
        StreamUtils["Stream Utilities"]:::code
        Utils["General Utilities"]:::code
    end

    subgraph FileAdapters["File Adapter Layer"]
        direction TB
        S3Adapter["S3 File Adapter"]:::code
        AmplifyAdapter["Amplify File Adapter"]:::code
        ZipAdapter["Zip File Adapter"]:::code
    end

    subgraph AWS["AWS Services Layer"]
        direction TB
        S3["S3 Bucket"]:::aws
        CloudFront["CloudFront CDN"]:::aws
    end

    subgraph Pipeline["CI/CD Pipeline"]
        direction TB
        CodeQL["CodeQL Analysis"]:::cicd
        ReleaseScript["Release Management"]:::cicd
        DevLink["Development Linking"]:::cicd
    end

    %% Relationships
    CMS --> Entry
    GraphQL --> GraphQLAdapter
    Entry --> Config
    Config --> DataSource
    DataSource --> GraphQLAdapter
    GraphQLAdapter --> PageBuilder
    PageBuilder --> MergeStream
    MergeStream --> StreamUtils
    StreamUtils --> Utils

    MergeStream --> FileAdapters
    FileAdapters --> S3
    S3 --> CloudFront

    %% Click Events
    click Entry "https://github.com/tforster/webproducer/blob/main/src/index.js"
    click Config "https://github.com/tforster/webproducer/blob/main/src/Config.js"
    click S3Adapter "https://github.com/tforster/webproducer/blob/main/src/S3FileAdapter.js"
    click AmplifyAdapter "https://github.com/tforster/webproducer/blob/main/src/AmplifyFileAdapter.js"
    click ZipAdapter "https://github.com/tforster/webproducer/blob/main/src/ZipFileAdapter.js"
    click DataSource "https://github.com/tforster/webproducer/blob/main/src/DataSource.js"
    click GraphQLAdapter "https://github.com/tforster/webproducer/blob/main/src/GraphQLDataAdapter.js"
    click PageBuilder "https://github.com/tforster/webproducer/blob/main/src/PageBuilder.js"
    click MergeStream "https://github.com/tforster/webproducer/blob/main/src/MergeStream.js"
    click CloudFront "https://github.com/tforster/webproducer/blob/main/src/CloudFront.js"
    click StreamUtils "https://github.com/tforster/webproducer/blob/main/src/StreamUtils.js"
    click Utils "https://github.com/tforster/webproducer/blob/main/src/Utils.js"
    click CodeQL "https://github.com/tforster/webproducer/blob/main/.github/workflows/codeql-analysis.yml"
    click ReleaseScript "https://github.com/tforster/webproducer/blob/main/scripts/release.sh"
    click DevLink "https://github.com/tforster/webproducer/blob/main/scripts/link.sh"

    %% Styling
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef code fill:#2496ED,stroke:#13283a,color:white
    classDef datasource fill:#4DB33D,stroke:#1a4016,color:white
    classDef cicd fill:#E6E6E6,stroke:#666666,color:black

    %% Legend
    subgraph Legend
        direction TB
        AWS_Service["AWS Service"]:::aws
        Code_Component["Code Component"]:::code
        Data_Source["Data Source"]:::datasource
        CICD_Component["CI/CD Component"]:::cicd
    end
```
