# derxter/nummenu-bot architecture

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

- Interactive diagram: https://gitdiagram.com/derxter/nummenu-bot
- Repository: https://github.com/derxter/nummenu-bot

## Overview

##### Project type and purpose
- This is a Rasa-based chatbot (“NumMenu Bot”) that presents a numbered menu of deep-learning frameworks and returns descriptions.
- It uses Rasa NLU & Core for intent recognition and dialogue management, plus a custom action server (Python) to look up menu items.

##### File structure
Top-level files and folders:
- config.yml – Rasa NLU pipeline & policies
- domain.yml – intents, slots, responses & actions
- endpoints.yml – HTTP endpoints (action server)
- data/
– nlu.yml, rules.yml, stories.yml (training data)
- actions/
– actions.py & menus.py (custom actions & menu definitions)
- menu.yml – static menu definitions
- tests/ – test stories
- story_graph.dot – auto-generated story graph
Key patterns:
- Separation of NLU & Core (data/ + config.yml)
- Custom action server (REST endpoint defined in endpoints.yml)
- Static menu definitions loaded by actions

##### README for additional insights
- Describes training (`rasa train`), interactive learning, running two processes (`rasa run actions` + `rasa shell`).
- Mentions integration possibility (e.g., Twilio+WhatsApp) via Rasa connectors.

##### Main components and their interactions
a. Components
1) Client (shell or messaging platform like WhatsApp/Twilio)
2) Rasa Server (Core + NLU pipeline)
3) Custom Action Server (Python Flask/Starlette serving actions.py & menus.py)
4) Training Data & Model Store (config.yml, data/, domain.yml → models/)
5) External Services (e.g., Twilio API for WhatsApp)
b. Interactions
– User → Connector (shell/HTTP) → Rasa server
– Rasa server:
- Processes text through NLU pipeline → intent/entities
- Core uses stories & rules to decide next action
- If next action is a custom action → HTTP call to Action Server
– Action Server returns data (menu description) → Rasa returns response to user
– Optionally, Rasa logs events or publishes metrics
c. Architectural patterns
– Microservice-style separation (Rasa vs. Action Server)
– Declarative training data (NLU, Stories, Rules) → reproducible model
– External connector plugin approach for channels
d. Key technologies
– Python 3.x, Rasa Open Source
– YAML for configuration & training data
– Custom actions run over REST (Flask/Starlette)
– (Optional) Twilio/WhatsApp connector

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Training Pipeline
    subgraph "Training Pipeline"
        direction TB
        Config["Pipeline & Policies\n(config.yml)"]:::data
        NLUData["NLU Examples\n(data/nlu.yml)"]:::data
        Stories["Stories\n(data/stories.yml)"]:::data
        Rules["Rules\n(data/rules.yml)"]:::data
        Domain["Domain Definitions\n(domain.yml)"]:::data
        Train["Model Artifacts\n(models/)"]:::core
        Tests["Test Stories\n(tests/test_stories.yml)"]:::data
        Graph["Story Graph\n(story_graph.dot)"]:::external

        Config -->|trains| Train
        NLUData -->|trains| Train
        Stories -->|trains| Train
        Rules -->|trains| Train
        Domain -->|trains| Train
        Tests -.->|validates| Train
        Graph -.->|visualizes| Train
    end

    %% Runtime
    subgraph "Runtime"
        direction TB
        User["User"]:::external
        Connector["Connector\n(shell/messaging)"]:::external
        subgraph "Rasa Server"
            direction TB
            Endpoints["Endpoints Config\n(endpoints.yml)"]:::data
            Model["Loaded Model"]:::core
            NLU["Rasa NLU"]:::core
            Core["Rasa Core"]:::core
        end
        subgraph "Action Server"
            direction TB
            Actions["Custom Actions\n(actions.py)"]:::action
            Menus["Menu Logic\n(menus.py)"]:::action
            StaticMenu["Static Menu\n(menu.yml)"]:::action
        end
        ExternalAPI["Twilio/WhatsApp API"]:::external

        User -->|sends message| Connector
        Connector -->|forwards message| NLU
        NLU -->|parses intent| Core
        Core -->|next action: custom| Actions
        Actions -->|loads menu spec| StaticMenu
        Actions -->|responds| Core
        Core -->|sends reply| Connector
        Connector -->|delivers reply| User

        Connector -->|optional channel| ExternalAPI
        ExternalAPI -->|delivers message| Connector
    end

    %% Click Events
    click Config "https://github.com/derxter/nummenu-bot/blob/main/config.yml"
    click NLUData "https://github.com/derxter/nummenu-bot/blob/main/data/nlu.yml"
    click Stories "https://github.com/derxter/nummenu-bot/blob/main/data/stories.yml"
    click Rules "https://github.com/derxter/nummenu-bot/blob/main/data/rules.yml"
    click Domain "https://github.com/derxter/nummenu-bot/blob/main/domain.yml"
    click Train "https://github.com/derxter/nummenu-bot/tree/main/models/"
    click Tests "https://github.com/derxter/nummenu-bot/blob/main/tests/test_stories.yml"
    click Graph "https://github.com/derxter/nummenu-bot/blob/main/story_graph.dot"
    click Endpoints "https://github.com/derxter/nummenu-bot/blob/main/endpoints.yml"
    click Actions "https://github.com/derxter/nummenu-bot/blob/main/actions/actions.py"
    click Menus "https://github.com/derxter/nummenu-bot/blob/main/actions/menus.py"
    click StaticMenu "https://github.com/derxter/nummenu-bot/blob/main/menu.yml"

    %% Styles
    classDef core fill:#D6EAF8,stroke:#21618C,color:#1B4F72
    classDef action fill:#D5F5E3,stroke:#239B56,color:#1E8449
    classDef external fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef data fill:#E8DAEF,stroke:#7D3C98,color:#512E5F
```
