# monid-ai/monid architecture

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

- Interactive diagram: https://gitdiagram.com/monid-ai/monid
- Repository: https://github.com/monid-ai/monid

## Overview

Monid is a declarative connector layer and runtime for agent tools: providers and endpoints define contracts, which are compiled and then executed through a shared engine. The README documents free discovery and inspection, billed execution, metering, and resource lifecycles. The tree and excerpts do not expose the catalog/discovery implementation, so those documented capabilities are shown without guessed internal links; unsampled connector implementations are represented at provider level.

Main entry points: [`engine/engine.ts`](https://github.com/monid-ai/monid/blob/main/engine/engine.ts) (Run engine), [`shared/compiler/compile.ts`](https://github.com/monid-ai/monid/blob/main/shared/compiler/compile.ts) (Contract compiler), [`engine/transport.ts`](https://github.com/monid-ai/monid/blob/main/engine/transport.ts) (HTTP transport), [`shared/core/schema/hooks/lifecycle.ts`](https://github.com/monid-ai/monid/blob/main/shared/core/schema/hooks/lifecycle.ts) (Resource lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Connector catalog"]
  node_catalog["Provider and endpoint catalog<br/>[categories.ts]"]
  node_providers["Provider definitions<br/>[provider.ts]"]
  node_endpoint_defs["Endpoint definitions and schemas<br/>[endpoint.ts]"]
end

subgraph group_compile["Compilation and contracts"]
  node_compiler["Contract compiler<br/>[compile.ts]"]
  node_fn_linker["Function linker<br/>[fns.ts]"]
end

subgraph group_runtime["Execution runtime"]
  node_engine["Run engine<br/>[engine.ts]"]
  node_input_validation["Input validation<br/>[request.ts]"]
  node_auth["Credential injection<br/>[auth.ts]"]
  node_transport["HTTP transport<br/>[transport.ts]"]
  node_fn_utils["Hook utilities<br/>[fn-utils.ts]"]
  node_errors["Runtime errors<br/>[errors.ts]"]
  node_usage["Usage metering<br/>[engine.ts]"]
end

subgraph group_resources["Resources and hooks"]
  node_resource_lifecycle["Resource lifecycle<br/>[lifecycle.ts]"]
  node_webhooks["Webhook contracts<br/>[webhooks.ts]"]
  node_resource_rows["Owned resource records<br/>[row.ts]"]
end

node_agent(("Agent or caller"))
node_discovery["Discover and inspect"]
node_host_store[("Host resource store")]
node_vendor_api["Provider APIs"]

node_agent -->|"discovers or inspects"| node_discovery
node_agent -->|"runs endpoint"| node_engine
node_providers -->|"declares providers"| node_catalog
node_endpoint_defs -->|"declares endpoints"| node_catalog
node_catalog -->|"compiles contracts"| node_compiler
node_compiler -->|"links functions"| node_fn_linker
node_compiler -.->|"produces runtime docs"| node_engine
node_engine -->|"validates input"| node_input_validation
node_engine -->|"injects credentials"| node_auth
node_engine -->|"executes requests"| node_transport
node_engine -->|"settles usage"| node_usage
node_transport -->|"uses auth injection"| node_auth
node_auth -->|"resolves hook"| node_fn_linker
node_engine -->|"provides hook utilities"| node_fn_utils
node_engine -->|"raises runtime errors"| node_errors
node_transport -->|"sends requests"| node_vendor_api
node_engine -.->|"runs resource hooks"| node_resource_lifecycle
node_resource_lifecycle -->|"uses resource records"| node_resource_rows
node_resource_lifecycle -.->|"requests lifecycle writes"| node_host_store
node_webhooks -->|"correlates resources"| node_resource_rows

click node_catalog "https://github.com/monid-ai/monid/blob/main/connectors/categories.ts"
click node_providers "https://github.com/monid-ai/monid/blob/main/connectors/tinyfish/provider.ts"
click node_endpoint_defs "https://github.com/monid-ai/monid/blob/main/connectors/apify/endpoints/google/google-images-api/endpoint.ts"
click node_compiler "https://github.com/monid-ai/monid/blob/main/shared/compiler/compile.ts"
click node_fn_linker "https://github.com/monid-ai/monid/blob/main/shared/compiler/fns.ts"
click node_engine "https://github.com/monid-ai/monid/blob/main/engine/engine.ts"
click node_input_validation "https://github.com/monid-ai/monid/blob/main/engine/request.ts"
click node_auth "https://github.com/monid-ai/monid/blob/main/engine/auth.ts"
click node_transport "https://github.com/monid-ai/monid/blob/main/engine/transport.ts"
click node_fn_utils "https://github.com/monid-ai/monid/blob/main/engine/fn-utils.ts"
click node_errors "https://github.com/monid-ai/monid/blob/main/engine/errors.ts"
click node_usage "https://github.com/monid-ai/monid/blob/main/engine/engine.ts"
click node_resource_lifecycle "https://github.com/monid-ai/monid/blob/main/shared/core/schema/hooks/lifecycle.ts"
click node_webhooks "https://github.com/monid-ai/monid/blob/main/shared/core/schema/hooks/webhooks.ts"
click node_resource_rows "https://github.com/monid-ai/monid/blob/main/shared/core/schema/resource/row.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_catalog,node_providers,node_endpoint_defs toneBlue
class node_compiler,node_fn_linker,node_host_store toneAmber
class node_engine,node_input_validation,node_auth,node_transport,node_fn_utils,node_errors,node_usage,node_vendor_api toneMint
class node_resource_lifecycle,node_webhooks,node_resource_rows toneRose
class node_agent,node_discovery toneIndigo
```

## Components

### Connector catalog

- [Provider and endpoint catalog](https://github.com/monid-ai/monid/blob/main/connectors/categories.ts): `connectors/categories.ts`
- [Provider definitions](https://github.com/monid-ai/monid/blob/main/connectors/tinyfish/provider.ts): `connectors/tinyfish/provider.ts`
- [Endpoint definitions and schemas](https://github.com/monid-ai/monid/blob/main/connectors/apify/endpoints/google/google-images-api/endpoint.ts): `connectors/apify/endpoints/google/google-images-api/endpoint.ts`

### Compilation and contracts

- [Contract compiler](https://github.com/monid-ai/monid/blob/main/shared/compiler/compile.ts): `shared/compiler/compile.ts`
- [Function linker](https://github.com/monid-ai/monid/blob/main/shared/compiler/fns.ts): `shared/compiler/fns.ts`

### Execution runtime

- [Run engine](https://github.com/monid-ai/monid/blob/main/engine/engine.ts): `engine/engine.ts`
- [Input validation](https://github.com/monid-ai/monid/blob/main/engine/request.ts): `engine/request.ts`
- [Credential injection](https://github.com/monid-ai/monid/blob/main/engine/auth.ts): `engine/auth.ts`
- [HTTP transport](https://github.com/monid-ai/monid/blob/main/engine/transport.ts): `engine/transport.ts`
- [Hook utilities](https://github.com/monid-ai/monid/blob/main/engine/fn-utils.ts): `engine/fn-utils.ts`
- [Runtime errors](https://github.com/monid-ai/monid/blob/main/engine/errors.ts): `engine/errors.ts`
- [Usage metering](https://github.com/monid-ai/monid/blob/main/engine/engine.ts): `engine/engine.ts`

### Resources and hooks

- [Resource lifecycle](https://github.com/monid-ai/monid/blob/main/shared/core/schema/hooks/lifecycle.ts): `shared/core/schema/hooks/lifecycle.ts`
- [Webhook contracts](https://github.com/monid-ai/monid/blob/main/shared/core/schema/hooks/webhooks.ts): `shared/core/schema/hooks/webhooks.ts`
- [Owned resource records](https://github.com/monid-ai/monid/blob/main/shared/core/schema/resource/row.ts): `shared/core/schema/resource/row.ts`

### Other components

- **Agent or caller**
- **Discover and inspect**
- **Host resource store**
- **Provider APIs**

## Connections

- Agent or caller → Discover and inspect: discovers or inspects (evidence: `README.md`)
- Agent or caller → Run engine: runs endpoint (evidence: `README.md`)
- Provider definitions → Provider and endpoint catalog: declares providers (evidence: `README.md`)
- Endpoint definitions and schemas → Provider and endpoint catalog: declares endpoints (evidence: `README.md`)
- Provider and endpoint catalog → Contract compiler: compiles contracts (evidence: `README.md`)
- Contract compiler → Function linker: links functions (evidence: `shared/compiler/compile.ts`)
- Contract compiler → Run engine: produces runtime docs (evidence: `README.md`)
- Run engine → Input validation: validates input (evidence: `engine/engine.ts`)
- Run engine → Credential injection: injects credentials (evidence: `engine/engine.ts`)
- Run engine → HTTP transport: executes requests (evidence: `engine/engine.ts`)
- Run engine → Usage metering: settles usage (evidence: `README.md`)
- HTTP transport → Credential injection: uses auth injection (evidence: `engine/transport.ts`)
- Credential injection → Function linker: resolves hook (evidence: `engine/auth.ts`)
- Run engine → Hook utilities: provides hook utilities (evidence: `engine/engine.ts`)
- Run engine → Runtime errors: raises runtime errors (evidence: `engine/engine.ts`)
- HTTP transport → Provider APIs: sends requests
- Run engine → Resource lifecycle: runs resource hooks (evidence: `engine/engine.ts`)
- Resource lifecycle → Owned resource records: uses resource records (evidence: `shared/core/schema/hooks/lifecycle.ts`)
- Resource lifecycle → Host resource store: requests lifecycle writes (evidence: `README.md`)
- Webhook contracts → Owned resource records: correlates resources (evidence: `shared/core/schema/hooks/webhooks.ts`)
