docs/architecture/modules.mdx
Modules are the interface between the Engine and the rest of the application. They are responsible for establishing connections to services, implementing trigger types, and supplying application Context.
Every capability in iii (HTTP endpoints, cron scheduling, state management, queues, streams, observability) is implemented as a Module. This modular architecture means the Engine itself stays small and focused on orchestration, while Modules handle all external concerns.
graph TB
subgraph Engine[Engine]
subgraph Module[Module]
Context[Context]
Triggers[Triggers]
end
end
Module <--> Postgres[(Postgres)]
Module <--> Redis[(Redis)]
Module <--> ExtAPI[External API]
| Module | Provides | Config key |
|---|---|---|
| HTTP | HTTP trigger type, request/response handling | rest_api |
| Queue | Async message processing with retries | queue |
| Cron | Scheduled task execution | cron |
| State | Key-value state storage with atomic updates | state |
| Stream | Real-time data streams with WebSocket push | stream |
| PubSub | Publish/subscribe messaging | pubsub |
| Observability | Structured logging, tracing, and metrics | observability |
| Exec | Shell command execution | exec |
| Bridge | WebSocket bridge for SDK connections | bridge |
A Module has two responsibilities:
Register trigger types: A Module can introduce new ways to invoke Functions. For example, the HTTP module registers the http trigger type, and the Cron module registers the cron trigger type.
Supply Context: A Module can add capabilities to the Context object that gets passed to every Function. For example, the State module adds state::get, state::set, and other state operations.
Modules are configured in config.yaml (the engine default). Use -c iii-config.yaml to specify a custom path:
modules:
- class: modules::api::RestApiModule
config:
port: 3111
host: 0.0.0.0
- class: modules::state::StateModule
config:
adapter:
class: modules::state::adapters::KvStore
config:
store_method: in_memory
- class: modules::queue::QueueModule
config:
adapter:
class: modules::queue::BuiltinQueueAdapter
config:
store_method: in_memory