> ## Documentation Index
> Fetch the complete documentation index at: https://motiadev-docs-deployment-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How iii is organized around workers, functions, triggers, and the engine.

iii has three application primitives:

| Primitive    | Role                                                                                                                                                        |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Worker**   | A process that connects to the engine and registers capabilities. Workers can be built in, such as `iii-http`, or external SDK processes.                   |
| **Function** | A named handler that can be invoked directly or by a trigger. Function IDs use the `::` separator, for example `orders::validate`.                          |
| **Trigger**  | A binding that tells iii when to invoke a function. HTTP requests, cron schedules, queue messages, state changes, logs, and stream events are all triggers. |

The engine owns connection management, routing, configuration, and protocol handling. Workers provide the actual capability surface.

<CardGroup cols={2}>
  <Card title="Engine" href="./engine" icon="server">
    Engine runtime, routing, and configuration.
  </Card>

  <Card title="Workers" href="./workers" icon="boxes">
    Built-in and external worker model.
  </Card>

  <Card title="Trigger Types" href="./trigger-types" icon="bolt">
    Trigger registration and call semantics.
  </Card>

  <Card title="Queues" href="./queues" icon="list-ordered">
    Topic-based and named queue models.
  </Card>
</CardGroup>

An iii system is made up of four components working together: the **Engine**, **Workers**, **Modules**, and **Context**.

```mermaid theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
graph TD
    subgraph "External World"
        Client[HTTP Client]
        Redis[(Redis)]
        User[WebSocket<br/>User]
    end

    subgraph "iii Engine Process"
        Core[Engine Core]
        Reg[Worker<br/>Registry]

        subgraph "Core Modules"
            API[RestApiModule]
            Stream[StreamModule]
            Log[OtelModule]
            Queue[QueueModule]
            Cron[CronModule]
        end
    end

    subgraph "Worker Processes"
        W1[Node.js<br/>Worker]
        W2[Python<br/>Worker]
    end

    Client -->|HTTP<br/>Request| API
    User -->|WS<br/>Message| Stream

    API --> Core
    Stream --> Core

    Core -->|Lookup| Reg
    Core -->|Invoke<br/>Function| W1
    Core -->|Invoke<br/>Function| W2

    W1 -->|Register| Core
    W2 -->|Register| Core

    Queue -.->|Persist/Sub| Redis
    Stream -.->|State| Redis
    Cron -.->|Locks| Redis
    Log -.->|Store| Redis
```
