# prodev717/awfex architecture

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

- Interactive diagram: https://gitdiagram.com/prodev717/awfex
- Repository: https://github.com/prodev717/awfex

## Overview

##### Project type and purpose
- AWFEX is an open-source, full-stack automation workflow engine.
- Frontend: A React + React Flow drag-and-drop UI for designing workflows.
- Backend: An Express.js server that orchestrates workflows by executing individual function modules via HTTP.

##### File structure
Top-level:
- index.js / awfex.js – entry points for the backend service.
- functions/ – directory of custom “node” functions (add.js, sub.js, etc.).
- frontend/ – standalone React app using Vite + React Flow.
- public/ – static files served by the server (public/index.html).
Backend specifics:
- Express.js routes invoked by HTTP triggers, reading workflow JSON, loading functions, chaining execution.
- No database—state passes through JSON payloads.
Frontend specifics:
- src/components – UI panels, toolbars.
- src/nodes – definitions of available node types (FunctionNode, InputNode).
- FlowCanvas.jsx – the core canvas where workflows are drawn.
- Generates JSON representing nodes + edges.

##### Key architectural insights from README
- HTTP-only triggers—makes the engine serverless-friendly.
- Function-first, plugin-style: any JS file dropped into functions/ is automatically available.
- UI feeds JSON to backend; backend returns execution results.

##### Main components & relationships (to represent
A. User / Client
- Web browser interacting with the React UI.
B. Frontend (React + React Flow)
- UI Layer: FlowCanvas, LeftPanel, Toolbar.
- Generates workflow JSON.
- Sends HTTP POST to Backend /execute endpoint.
C. Backend (Express.js)
- HTTP API layer.
- Workflow controller: parses JSON, resolves node graph order.
- Function registry loader: dynamically imports modules from functions/.
- Executor: invokes each function in sequence, passing data payload.
- Returns execution status / output.
D. Functions Library
- Individual JS modules (add, sub, mul, div, print).
- Plugin-style—dropping a file auto-registers it.
E. External Systems (optional)
- Any HTTP endpoint or serverless platform hosting backend.
- Third-party APIs invoked by custom functions if needed.

##### Architectural patterns & design principles
- Plugin architecture: loose coupling between engine and functions.
- Event-driven chaining: each node emits data to the next.
- Separation of concerns: UI purely for design, backend purely for execution.
- JSON-based workflow as an explicit intermediate representation (IR).
- Serverless-friendly: HTTP triggers only, stateless execution.

##### Essential details not to omit
- Dynamic function resolution—make the Function Registry explicit.
- HTTP trigger endpoint as the entry point.
- Separation between design-time (UI) and run-time (execution engine).

- Identifies all key components and their responsibilities.
- Shows data/control flow between User, Frontend, Backend, and Functions.
- Reflects AWFEX’s plugin-first, HTTP-driven architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    subgraph "User/Client"
        User["Web Browser (User)"]
    end

    %% Frontend Layer
    subgraph "Frontend (React, React Flow, Vite)"
        direction TB
        FC["FlowCanvas"]:::frontend
        LP["LeftPanel"]:::frontend
        TBNode["Toolbar"]:::frontend
        FNNode["FunctionNode"]:::frontend
        INNode["InputNode"]:::frontend
        MainFE["main.jsx"]:::frontend
        HTMLFE["index.html"]:::frontend
        PkgFE["package.json"]:::frontend
        JSONIR["Workflow JSON"]:::default
    end

    %% Backend Layer
    subgraph "Backend (Node.js, Express.js)"
        direction TB
        API["Express.js HTTP API\nPOST /execute"]:::backend
        WC["Workflow Controller"]:::backend
        FR["Function Registry"]:::backend
        Exec["Executor"]:::backend
        Static["public/index.html"]:::backend
        PkgBE["package.json"]:::backend
        Result["Result JSON"]:::default
    end

    %% Functions Library
    subgraph "Functions Library (Custom JS modules)" 
        direction TB
        Add["add.js"]:::functions
        Sub["sub.js"]:::functions
        Mul["mul.js"]:::functions
        Div["div.js"]:::functions
        Print["print.js"]:::functions
    end

    %% External Services
    subgraph "External Services / Serverless Host"
        External["HTTP Endpoint / AWS Lambda"]:::external
    end

    %% Connections
    User -->|"interacts"| FC
    FC -->|uses| LP
    FC -->|uses| TBNode
    FC -->|"renders nodes"| FNNode
    FC -->|"renders nodes"| INNode
    FC -->|"serializes graph"| JSONIR
    JSONIR -->|"HTTP POST /execute"| API
    API -->|"workflow.json"| WC
    WC -->|"resolve nodes"| FR
    FR -->|"load modules"| Exec
    Exec -->|"invoke add"| Add
    Exec -->|"invoke sub"| Sub
    Exec -->|"invoke mul"| Mul
    Exec -->|"invoke div"| Div
    Exec -->|"invoke print"| Print
    Exec -->|"calls external APIs if any"| External
    Exec -->|"result JSON"| Result
    Result -->|"returns response"| User

    %% Click Events - Frontend
    click FC "https://github.com/prodev717/awfex/blob/main/frontend/src/components/FlowCanvas.jsx"
    click LP "https://github.com/prodev717/awfex/blob/main/frontend/src/components/LeftPanel.jsx"
    click TBNode "https://github.com/prodev717/awfex/blob/main/frontend/src/components/Toolbar.jsx"
    click FNNode "https://github.com/prodev717/awfex/blob/main/frontend/src/nodes/FunctionNode.jsx"
    click INNode "https://github.com/prodev717/awfex/blob/main/frontend/src/nodes/InputNode.jsx"
    click MainFE "https://github.com/prodev717/awfex/blob/main/frontend/src/main.jsx"
    click HTMLFE "https://github.com/prodev717/awfex/blob/main/frontend/index.html"
    click PkgFE "https://github.com/prodev717/awfex/blob/main/frontend/package.json"

    %% Click Events - Backend
    click API "https://github.com/prodev717/awfex/blob/main/index.js"
    click API "https://github.com/prodev717/awfex/blob/main/awfex.js"
    click WC "https://github.com/prodev717/awfex/blob/main/awfex.js"
    click WC "https://github.com/prodev717/awfex/blob/main/index.js"
    click FR "https://github.com/prodev717/awfex/blob/main/awfex.js"
    click FR "https://github.com/prodev717/awfex/blob/main/index.js"
    click PkgBE "https://github.com/prodev717/awfex/blob/main/package.json"
    click Static "https://github.com/prodev717/awfex/blob/main/public/index.html"

    %% Click Events - Functions
    click Add "https://github.com/prodev717/awfex/blob/main/functions/add.js"
    click Sub "https://github.com/prodev717/awfex/blob/main/functions/sub.js"
    click Mul "https://github.com/prodev717/awfex/blob/main/functions/mul.js"
    click Div "https://github.com/prodev717/awfex/blob/main/functions/div.js"
    click Print "https://github.com/prodev717/awfex/blob/main/functions/print.js"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef backend fill:#DDF4DD,stroke:#333,stroke-width:1px
    classDef functions fill:#FFF3C4,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef default fill:#FFFFFF,stroke:#333,stroke-width:1px
```
