# bilaloumehdi/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/bilaloumehdi/chatbot
- Repository: https://github.com/bilaloumehdi/chatbot

## Overview

##### Project Type and Purpose
- This is a Rasa-based chatbot project (“chatBot”) whose main goal is to process user messages, apply natural language understanding, manage dialogue, and invoke custom actions (e.g., fetching weather data) when needed.

##### File Structure Analysis
- Top-level files:
- README.md – brief description
- config.yml – NLU & Core pipeline and policy definitions
- domain.yml – intents, entities, slots, responses
- endpoints.yml – definitions for action server, tracker store, etc.
- credentials.yml – channels & connectors
- requirements.txt – Python dependencies
- Directories:
- data/ – NLU training data (nlu.yml), dialogue rules (rules.yml), stories (stories.yml)
- actions/ – custom actions (actions.py) and its package metadata
- services/ – helper modules (e.g., weather.py) used by actions
- models/ – trained Rasa model archive(s)
- tests/ – test definitions for stories

##### README Insights
- Minimal description (“a simple rasa chatbot”) implies core functionality rests in Rasa’s standard components plus one or two custom hooks (weather service).

a. Main Components:
1. User (Chat Interface)
2. Rasa Server
- NLU Module (pipeline from config.yml)
- Core Module (policies from config.yml, domain from domain.yml, stories & rules from data/)
3. Action Server
- actions/actions.py
- services/weather.py (external API call)
4. Model Store (models/*.tar.gz)
5. External Services (e.g., Weather API)
b. Interactions:
- User message flows into Rasa Server via a connector (credentials.yml) → NLU module → parsed intent & entities
- Core module uses domain + stories/rules → decides next action
- If next action is “custom,” Rasa calls Action Server (defined in endpoints.yml)
- Action Server runs logic (e.g., services/weather.py calls external API) and returns a response to Rasa Server
- Rasa Server sends final bot reply back to User
c. Architectural Patterns & Principles:
- Separation of concerns: NLU vs. dialogue management vs. custom logic
- Pluggable pipeline & policies (configurable in config.yml)
- External service abstraction (all API calls isolated in services/)
d. Key Technologies:
- Rasa Open Source (NLU & Core)
- Python custom actions
- YAML-based training data & configuration
- External REST API (weather)

##### Details to Capture
- Configuration files (config.yml, endpoints.yml, credentials.yml) that wire up pipelines and connectors
- The services/ module dependency graph under the Action Server
- The relationships between domain.yml, data/stories, and the Core module
- Testing artifacts (tests/) can be shown as a side process verifying story coverage

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User interaction
    User["User (Chat Interface)"]:::user

    %% Rasa Server subgraph
    subgraph "Rasa Server"
        Config["Config (config.yml)"]:::config
        Credentials["Credentials (credentials.yml)"]:::config
        Endpoints["Endpoints (endpoints.yml)"]:::config

        NLUData["NLU Data (data/nlu.yml)"]:::data
        Stories["Stories (data/stories.yml)"]:::data
        Rules["Rules (data/rules.yml)"]:::data
        Domain["Domain (domain.yml)"]:::config

        NLU["Rasa NLU Module"]:::core
        Core["Rasa Core Module"]:::core

        Model["Model Store (models/20231114-145003-corporate-mulberry.tar.gz)"]:::store
    end

    %% Action Server subgraph
    subgraph "Action Server"
        Actions["Action Server Entry Point (actions/actions.py)"]:::actions
        Services["External Service Abstraction (services/weather.py)"]:::services
    end

    %% External API
    External["Weather API"]:::external

    %% Testing and Documentation
    Tests["Tests (tests/test_stories.yml)"]:::test
    Readme["README.md"]:::doc
    Requirements["requirements.txt"]:::doc

    %% Data flow and interactions
    User -->|"send message"| Credentials
    Credentials --> NLU
    NLU -->|"parsed intent & entities"| Core

    Core -->|"loads pipeline & policies from"| Config
    Core -->|"loads domain definitions from"| Domain
    Core -->|"loads stories from"| Stories
    Core -->|"loads rules from"| Rules
    Core -->|"loads model from"| Model

    Core -->|"invoke custom action via"| Endpoints
    Endpoints --> Actions
    Actions -->|"uses helper"| Services
    Services -->|"call API"| External
    External -->|"API response"| Services
    Services --> Actions
    Actions --> Core
    Core -->|"send reply"| User

    %% Side artifacts
    Tests -.-> Core
    Readme -.-> Core
    Requirements -.-> Core

    %% Click Events
    click Config "https://github.com/bilaloumehdi/chatbot/blob/master/config.yml"
    click Domain "https://github.com/bilaloumehdi/chatbot/blob/master/domain.yml"
    click NLUData "https://github.com/bilaloumehdi/chatbot/blob/master/data/nlu.yml"
    click Stories "https://github.com/bilaloumehdi/chatbot/blob/master/data/stories.yml"
    click Rules "https://github.com/bilaloumehdi/chatbot/blob/master/data/rules.yml"
    click Actions "https://github.com/bilaloumehdi/chatbot/blob/master/actions/actions.py"
    click Services "https://github.com/bilaloumehdi/chatbot/blob/master/services/weather.py"
    click Endpoints "https://github.com/bilaloumehdi/chatbot/blob/master/endpoints.yml"
    click Credentials "https://github.com/bilaloumehdi/chatbot/blob/master/credentials.yml"
    click Model "https://github.com/bilaloumehdi/chatbot/blob/master/models/20231114-145003-corporate-mulberry.tar.gz"
    click Tests "https://github.com/bilaloumehdi/chatbot/blob/master/tests/test_stories.yml"
    click Readme "https://github.com/bilaloumehdi/chatbot/blob/master/README.md"
    click Requirements "https://github.com/bilaloumehdi/chatbot/blob/master/requirements.txt"

    %% Styles
    classDef user fill:#dddddd,stroke:#333,stroke-width:1px
    classDef core fill:#a0c4ff,stroke:#333,stroke-width:1px
    classDef actions fill:#caffbf,stroke:#333,stroke-width:1px
    classDef services fill:#fdffb6,stroke:#333,stroke-width:1px
    classDef external fill:#ffadad,stroke:#333,stroke-width:1px
    classDef store fill:#bdb2ff,stroke:#333,stroke-width:1px
    classDef config fill:#ffc6ff,stroke:#333,stroke-width:1px
    classDef data fill:#fffffc,stroke:#333,stroke-width:1px
    classDef test fill:#bde0fe,stroke:#333,stroke-width:1px
    classDef doc fill:#e0ffc1,stroke:#333,stroke-width:1px
```
