# rasahq/rasa architecture

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

- Interactive diagram: https://gitdiagram.com/rasahq/rasa
- Repository: https://github.com/rasahq/rasa

## Overview

##### Main components
- Core Conversational Engine – This includes the NLU components (tokenizers, featurizers, classifiers in the rasa/nlu directory) and the dialogue management parts (policies, actions, story processing in the rasa/core directory).
- Graph/Engine & Training Pipelines – The engine directory (rasa/engine) and training/training_data components are used for managing models, processing conversation graphs, caching, and training.
- Channel Connectors & API Endpoints – There are many connectors under rasa/core/channels (e.g., for Facebook, Slack, Telegram) that handle incoming and outgoing messages, as well as a REST API.
- Action Server/Custom Actions – Components found in examples as well as the action code within the initial_project and examples directories showing how custom business logic is integrated.
- External Integrations – Event brokers (Kafka, Pika, SQL, etc. in the brokers folder) and support for external libraries (spacy, mitie, Hugging Face transformers, etc.) form an important part of the system.
- Configuration and Domain Management – Multiple configuration files (YAML for domains, stories, rules) and the configuration management provided in the “data” folder.
- Developer/Testing Infrastructure – The project includes extensive tests, CI/CD pipelines (GitHub workflows, Dockerfiles, and Makefiles), documentation, and scripts for building/deployment. Although these are not “runtime” components, they are integral to the overall system design.

##### Relationships and interactions
- User or Messaging Channel (client endpoints) → Connector/Channel Layer (rasa/core/channels) receives input.
- Incoming messages are then passed to the NLU module (rasa/nlu) which extracts intents and entities.
- The processed NLU output is sent into the dialogue manager (rasa/core/agent, policies in rasa/core/policies, and the engine/graph modules) where conversation state is maintained.
- If required, control passes to the action server (custom actions defined in examples or the Rasa SDK integration) to execute business logic.
- Responses and follow-up events are then generated and relayed back via the channel connectors.
- Data artifacts such as training data, domain files, and log/tracker data are stored and managed (represented in the “data” and “tests/tracker_stores” directories).

##### Architectural patterns and key design decisions
- Modular Design – The separation between the NLU, Core (dialogue management), connectors, and training/persistence clearly follows modular principles.
- Extensibility – The use of plugins, custom components (graph components, custom action triggers), and a clear separation between configuration, code, and tests are integral design principles.
- Pipeline Architecture – The conversational flow is designed as a pipeline (input → NLU → dialogue management → actions → output) with each module having clear inter–dependencies.
- Integration with external tooling – Dockerfiles, GitHub workflows, CI/CD pipelines, and documentation directories show a robust deployment and development automation strategy.

##### Relevant technology and libraries
- Python as the main programming language.
- Tools such as Poetry for dependency management.
- Integration libraries/frameworks: Spacy, Mitie, Hugging Face Transformers for NLU; and Docker, Kubernetes, and CI/CD pipelines for deployment.
- Testing frameworks: pytest and numerous integration tests across directories.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface"
        UI("Messaging Channels"):::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        CC("Channel Connectors & API Endpoints"):::connector
        NLU("NLU Pipeline"):::service
        DM("Dialogue Manager (Core Conversational Engine)"):::service
        GE("Graph Engine & Training Pipelines"):::service
        AS("Action Server / Custom Actions"):::service
    end

    %% Supporting Services
    subgraph "Supporting Services"
        CF("Configuration Files"):::config
        DF("Domain File"):::config
        EXT("External Integrations (Event Brokers)"):::external
    end

    %% Development and Testing
    subgraph "Development & Testing"
        DEV("Developer / Testing Infrastructure"):::dev
    end

    %% Flow: User to Application Layer
    UI -->|"sendsMessage"| CC
    CC -->|"forwardsTo"| NLU
    NLU -->|"NLUResult"| DM
    DM -->|"invokesAction"| AS
    DM -->|"triggersGraph"| GE
    DM -->|"accessesConfig"| CF
    DM -->|"readsDomain"| DF
    DM -->|"publishesEvent"| EXT
    AS -->|"returnsResult"| DM
    DM -->|"responseToChannel"| CC
    CC -->|"sendsResponse"| UI

    %% Development connections (dashed lines)
    DEV --- NLU
    DEV --- DM
    DEV --- GE
    DEV --- AS
    DEV --- CC
    DEV --- CF
    DEV --- DF
    DEV --- EXT

    %% Click Events
    click NLU "https://github.com/rasahq/rasa/tree/3.6.x/rasa/nlu/"
    click DM "https://github.com/rasahq/rasa/tree/3.6.x/rasa/core/"
    click GE "https://github.com/rasahq/rasa/tree/3.6.x/rasa/engine/"
    click CC "https://github.com/rasahq/rasa/tree/3.6.x/rasa/core/channels/"
    click AS "https://github.com/rasahq/rasa/tree/3.6.x/examples/concertbot/actions/"
    click EXT "https://github.com/rasahq/rasa/tree/3.6.x/rasa/core/brokers/"
    click CF "https://github.com/rasahq/rasa/tree/3.6.x/data/configs_for_docs/"
    click DF "https://github.com/rasahq/rasa/blob/3.6.x/rasa/cli/initial_project/domain.yml"
    click DEV "https://github.com/rasahq/rasa/tree/3.6.x/.github/"

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef connector fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef service fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef external fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#673AB7,stroke-width:2px;
    classDef dev fill:#F0F4C3,stroke:#9E9D24,stroke-width:2px;
```
