# leandrobon/waflow architecture

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

- Interactive diagram: https://gitdiagram.com/leandrobon/waflow
- Repository: https://github.com/leandrobon/waflow

## Overview

##### Project type and purpose
- WAFlow is a full-stack sandbox application for local development and testing of webhook-based WhatsApp-style bots. It consists of three .NET services (Simulator API, Blazor UI, Example Bot), all wired together via Docker Compose or local URLs.

##### File structure
- Top-level services:
- WAFlow.Simulator – Minimal API (.NET) for injecting messages, dispatching webhooks, and storing message feeds in memory.
- WAFlow.Chat – Blazor UI (Razor components) for chat interface, polling the simulator, import/export JSON, and environment status.
- EchoBot.Example – Minimal API example webhook that auto-registers with the simulator and echoes inbound text.
- Shared artifacts: docker-compose.yml, solution file, per-service Dockerfiles, appsettings.json, launchSettings.json.
- Patterns: microservices (three independent processes), in-memory persistence, HTTP-based interfaces, polling vs. webhook callbacks.

##### Key insights from the README
- Ports: UI (5056), Simulator (5080), EchoBot (5199).
- In Docker: inter-service communication via service DNS on port 8080 (`http://sim:8080`, `http://echobot:8080`).
- Core flows: UI → poll Simulator → display messages; Simulator → invoke webhook; webhook → post back to Simulator; UI → import/export/reset.

##### Detailed capture of essential elements
- Both registry and message store sub-components inside the Simulator boundary.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actor
    Developer["Developer/Browser"]:::external

    %% Local Dev / Docker Compose Boundary
    subgraph "Local Dev / Docker Compose"
        direction TB
        UI["WAFlow.Chat (Blazor UI)\nPort: 5056"]:::frontend
        Simulator["WAFlow.Simulator API\nPort: 5080"]:::backend
        Bot["EchoBot.Example Bot\nPort: 5199"]:::bot

        subgraph "In-Memory Stores"
            direction TB
            Registry["Webhook Registry"]:::store
            Messages["Message Feed Store"]:::store
        end

        Compose["docker-compose.yml"]:::config
        Solution["WaFlow.sln"]:::config
    end

    %% File Import/Export
    FileSystem["Import/Export JSON\n(Local FS)"]:::file

    %% Connections
    Developer -->|"Open UI (GET) on localhost:5056"| UI
    UI -->|"GET /messages\nPOST /webhook/register\nPOST /import\nPOST /reset"| Simulator
    UI -->|"Read/Write JSON"| FileSystem
    Simulator -->|CRUD| Registry
    Simulator -->|Append messages| Messages
    Simulator -->|"POST /bot/webhook"| Bot
    Bot -->|"POST BotSendText payload"| Simulator

    %% Click Events
    click UI "https://github.com/leandrobon/waflow/tree/main/WAFlow.Chat/"
    click Simulator "https://github.com/leandrobon/waflow/tree/main/WAFlow.Simulator/"
    click Bot "https://github.com/leandrobon/waflow/tree/main/EchoBot.Example/"
    click Compose "https://github.com/leandrobon/waflow/blob/main/docker-compose.yml"
    click Solution "https://github.com/leandrobon/waflow/blob/main/WaFlow.sln"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E8F1FF,stroke:#0050A0,color:#0050A0;
    classDef bot fill:#FFE8D0,stroke:#D67A00,color:#D67A00;
    classDef store fill:#DFFFE0,stroke:#00A642,color:#00A642,stroke-width:2px;
    classDef config fill:#F0F0F0,stroke:#888888,color:#333333;
    classDef file fill:#FFF4E5,stroke:#CC8E00,color:#CC8E00;
    classDef external fill:#F5E6FF,stroke:#9B59B6,color:#9B59B6;
```
