# erxes/erxes-automations architecture

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

- Interactive diagram: https://gitdiagram.com/erxes/erxes-automations
- Repository: https://github.com/erxes/erxes-automations

## Overview

This is a Node.js automation service: automations are represented as connected trigger, condition, and action shapes, with execution progress recorded in queues. The visible runner follows shape connections, evaluates a deal-field condition, executes supported actions, and persists queue state; an Erkhet order action uses RabbitMQ RPC. The tree also contains automation schemas and query/mutation resolvers, plus change-deal trigger support. The README is empty, and several modules were not excerpted, so their runtime wiring is not asserted here.

Main entry points: [`src/data/runnerHelper.ts`](https://github.com/erxes/erxes-automations/blob/master/src/data/runnerHelper.ts) (Automation runner), [`src/messageBroker.ts`](https://github.com/erxes/erxes-automations/blob/master/src/messageBroker.ts) (Message broker), [`src/data/actions/index.ts`](https://github.com/erxes/erxes-automations/blob/master/src/data/actions/index.ts) (Action dispatch), [`src/models/Automations.ts`](https://github.com/erxes/erxes-automations/blob/master/src/models/Automations.ts) (Automation models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Service entry"]
  node_service["HTTP service<br/>[index.ts]"]
  node_dbconnect["Database connection<br/>[connection.ts]"]
end

subgraph group_authoring["Automation authoring"]
  node_automation_api["Automation resolvers"]
  node_automation_schema["Automation schema<br/>[automations.ts]"]
end

subgraph group_runtime["Execution runtime"]
  node_runner["Automation runner<br/>[runnerHelper.ts]"]
  node_deal_condition["Deal-field condition<br/>[checkDealField.ts]"]
  node_action_dispatch["Action dispatch<br/>[index.ts]"]
  node_delay_action["Delay action<br/>[delay.ts]"]
  node_erkhet_action["Erkhet order action<br/>[erkhetPostData.ts]"]
  node_deal_trigger["Deal-change trigger<br/>[changeDeal.ts]"]
  node_trigger_utils["Trigger utilities<br/>[utils.ts]"]
end

subgraph group_persistence["Persistence"]
  node_automation_models["Automation models<br/>[Automations.ts]"]
  node_automation_definitions["Automation definitions<br/>[Automations.ts]"]
  node_shape_store[("Automation and shapes<br/>[Automations.ts]")]
  node_queue_model["Queue model<br/>[Queue.ts]"]
  node_queue_store[("Execution queue<br/>[Queue.ts]")]
end

subgraph group_integration["Messaging integration"]
  node_broker["Message broker<br/>[messageBroker.ts]"]
end

node_rabbitmq["RabbitMQ"]
node_external_api(("Erkhet service"))

node_service -->|"connects through"| node_dbconnect
node_service -->|"loads"| node_broker
node_runner -->|"loads shapes"| node_shape_store
node_runner -->|"records progress"| node_queue_model
node_runner -->|"dispatches actions"| node_action_dispatch
node_runner -->|"evaluates condition"| node_deal_condition
node_action_dispatch -->|"exports action"| node_delay_action
node_action_dispatch -->|"exports action"| node_erkhet_action
node_erkhet_action -->|"requests RPC"| node_broker
node_broker -->|"sends and consumes"| node_rabbitmq
node_broker -->|"checks trigger"| node_trigger_utils
node_automation_models -->|"uses schemas"| node_automation_definitions
node_automation_models -->|"creates models"| node_shape_store
node_queue_model -->|"creates model"| node_queue_store
node_automation_api -.-> node_automation_models
node_automation_api -.-> node_automation_schema
node_deal_trigger -.-> node_trigger_utils
node_rabbitmq -.-> node_external_api

click node_service "https://github.com/erxes/erxes-automations/blob/master/src/index.ts"
click node_dbconnect "https://github.com/erxes/erxes-automations/blob/master/src/connection.ts"
click node_automation_api "https://github.com/erxes/erxes-automations/tree/master/src/data/resolvers"
click node_automation_schema "https://github.com/erxes/erxes-automations/blob/master/src/data/schema/automations.ts"
click node_automation_models "https://github.com/erxes/erxes-automations/blob/master/src/models/Automations.ts"
click node_automation_definitions "https://github.com/erxes/erxes-automations/blob/master/src/models/definitions/Automations.ts"
click node_shape_store "https://github.com/erxes/erxes-automations/blob/master/src/models/Automations.ts"
click node_runner "https://github.com/erxes/erxes-automations/blob/master/src/data/runnerHelper.ts"
click node_deal_condition "https://github.com/erxes/erxes-automations/blob/master/src/data/conditions/checkDealField.ts"
click node_action_dispatch "https://github.com/erxes/erxes-automations/blob/master/src/data/actions/index.ts"
click node_delay_action "https://github.com/erxes/erxes-automations/blob/master/src/data/actions/delay.ts"
click node_erkhet_action "https://github.com/erxes/erxes-automations/blob/master/src/data/actions/erkhetPostData.ts"
click node_deal_trigger "https://github.com/erxes/erxes-automations/blob/master/src/data/triggers/changeDeal.ts"
click node_trigger_utils "https://github.com/erxes/erxes-automations/blob/master/src/data/utils.ts"
click node_queue_model "https://github.com/erxes/erxes-automations/blob/master/src/models/Queue.ts"
click node_queue_store "https://github.com/erxes/erxes-automations/blob/master/src/models/Queue.ts"
click node_broker "https://github.com/erxes/erxes-automations/blob/master/src/messageBroker.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_service,node_dbconnect toneBlue
class node_automation_api,node_automation_schema toneAmber
class node_runner,node_deal_condition,node_action_dispatch,node_delay_action,node_erkhet_action,node_deal_trigger,node_trigger_utils toneMint
class node_automation_models,node_automation_definitions,node_shape_store,node_queue_model,node_queue_store toneRose
class node_broker,node_rabbitmq,node_external_api toneIndigo
```

## Components

### Service entry

- [HTTP service](https://github.com/erxes/erxes-automations/blob/master/src/index.ts): `src/index.ts`
- [Database connection](https://github.com/erxes/erxes-automations/blob/master/src/connection.ts): `src/connection.ts`

### Automation authoring

- [Automation resolvers](https://github.com/erxes/erxes-automations/tree/master/src/data/resolvers): `src/data/resolvers`
- [Automation schema](https://github.com/erxes/erxes-automations/blob/master/src/data/schema/automations.ts): `src/data/schema/automations.ts`

### Execution runtime

- [Automation runner](https://github.com/erxes/erxes-automations/blob/master/src/data/runnerHelper.ts): `src/data/runnerHelper.ts`
- [Deal-field condition](https://github.com/erxes/erxes-automations/blob/master/src/data/conditions/checkDealField.ts): `src/data/conditions/checkDealField.ts`
- [Action dispatch](https://github.com/erxes/erxes-automations/blob/master/src/data/actions/index.ts): `src/data/actions/index.ts`
- [Delay action](https://github.com/erxes/erxes-automations/blob/master/src/data/actions/delay.ts): `src/data/actions/delay.ts`
- [Erkhet order action](https://github.com/erxes/erxes-automations/blob/master/src/data/actions/erkhetPostData.ts): `src/data/actions/erkhetPostData.ts`
- [Deal-change trigger](https://github.com/erxes/erxes-automations/blob/master/src/data/triggers/changeDeal.ts): `src/data/triggers/changeDeal.ts`
- [Trigger utilities](https://github.com/erxes/erxes-automations/blob/master/src/data/utils.ts): `src/data/utils.ts`

### Persistence

- [Automation models](https://github.com/erxes/erxes-automations/blob/master/src/models/Automations.ts): `src/models/Automations.ts`
- [Automation definitions](https://github.com/erxes/erxes-automations/blob/master/src/models/definitions/Automations.ts): `src/models/definitions/Automations.ts`
- [Automation and shapes](https://github.com/erxes/erxes-automations/blob/master/src/models/Automations.ts): `src/models/Automations.ts`
- [Queue model](https://github.com/erxes/erxes-automations/blob/master/src/models/Queue.ts): `src/models/Queue.ts`
- [Execution queue](https://github.com/erxes/erxes-automations/blob/master/src/models/Queue.ts): `src/models/Queue.ts`

### Messaging integration

- [Message broker](https://github.com/erxes/erxes-automations/blob/master/src/messageBroker.ts): `src/messageBroker.ts`

### Other components

- **RabbitMQ**
- **Erkhet service**

## Connections

- HTTP service → Database connection: connects through (evidence: `src/index.ts`)
- HTTP service → Message broker: loads (evidence: `src/index.ts`)
- Automation runner → Automation and shapes: loads shapes (evidence: `src/data/runnerHelper.ts`)
- Automation runner → Queue model: records progress (evidence: `src/data/runnerHelper.ts`)
- Automation runner → Action dispatch: dispatches actions (evidence: `src/data/runnerHelper.ts`)
- Automation runner → Deal-field condition: evaluates condition (evidence: `src/data/runnerHelper.ts`)
- Action dispatch → Delay action: exports action (evidence: `src/data/actions/index.ts`)
- Action dispatch → Erkhet order action: exports action (evidence: `src/data/actions/index.ts`)
- Erkhet order action → Message broker: requests RPC (evidence: `src/data/actions/erkhetPostData.ts`)
- Message broker → RabbitMQ: sends and consumes (evidence: `src/messageBroker.ts`)
- Message broker → Trigger utilities: checks trigger (evidence: `src/messageBroker.ts`)
- Automation models → Automation definitions: uses schemas (evidence: `src/models/Automations.ts`)
- Automation models → Automation and shapes: creates models (evidence: `src/models/Automations.ts`)
- Queue model → Execution queue: creates model (evidence: `src/models/Queue.ts`)
- Automation resolvers → Automation models
- Automation resolvers → Automation schema
- Deal-change trigger → Trigger utilities (evidence: `src/data/utils.ts`)
- RabbitMQ → Erkhet service
