# thisshonrobert/zapier architecture

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

- Interactive diagram: https://gitdiagram.com/thisshonrobert/zapier
- Repository: https://github.com/thisshonrobert/zapier

## Overview

Zapier-style workflow automation: users configure Zaps, external triggers create runs, and a queued worker executes ordered actions. The monorepo also includes a separate, read-only AI triage preview and backend investigation/replay capabilities. The main execution links are documented in the README; triage service wiring is supported by the sampled backend entry point and source index. Other unsampled implementation details are represented only where the tree or documentation supports them.

Main entry points: [`apps/primary_backend/route/triage.ts`](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/triage.ts) (Triage API routes), [`packages/db/prisma/db.ts`](https://github.com/thisshonrobert/zapier/blob/main/packages/db/prisma/db.ts) (PostgreSQL), [`apps/worker/index.ts`](https://github.com/thisshonrobert/zapier/blob/main/apps/worker/index.ts) (Stage consumer), [`apps/primary_backend/index.ts`](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/index.ts) (Primary API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard and builder"]
  node_frontend_app["Dashboard and builder"]
  node_triage_ui["Triage screens<br/>[page.tsx]"]
end

subgraph group_automation["Zap execution"]
  node_primary_api["Primary API<br/>[index.ts]"]
  node_zap_routes["Zap CRUD routes<br/>[zap.ts]"]
  node_trigger_routes["Trigger routes<br/>[trigger.ts]"]
  node_webhook["Webhook ingress<br/>[index.ts]"]
  node_processor["Outbox processor<br/>[index.ts]"]
  node_worker["Stage consumer<br/>[index.ts]"]
  node_orchestration["Stage orchestration<br/>[orchestration.ts]"]
  node_execution_store["Execution state<br/>[execution-store.ts]"]
  node_action_handlers["Action handlers<br/>[index.ts]"]
end

subgraph group_triage["Triage and recovery"]
  node_triage_routes["Triage API routes<br/>[triage.ts]"]
  node_triage_evidence["Evidence service<br/>[triage-evidence.ts]"]
  node_triage_operator["Operator service<br/>[triage-operator.ts]"]
  node_investigation["Investigation services"]
  node_proposals["Proposal services"]
  node_replay["Replay service<br/>[replay.ts]"]
  node_agent_client["AI agent client<br/>[triage-agent.ts]"]
  node_agent_graph["Triage graph<br/>[graph.ts]"]
  node_runbook_search["Runbook retrieval<br/>[search-runbooks.ts]"]
end

subgraph group_shared["Shared data"]
  node_run_outbox[("Run outbox")]
  node_kafka["Kafka events"]
  node_database[("PostgreSQL<br/>[db.ts]")]
end

node_user(("User"))
node_trigger_source(("Trigger source"))

node_user -->|"configures Zaps"| node_frontend_app
node_frontend_app -->|"creates workflows"| node_primary_api
node_primary_api -->|"routes requests"| node_zap_routes
node_primary_api -->|"routes requests"| node_trigger_routes
node_zap_routes -->|"reads and writes"| node_database
node_trigger_routes -->|"reads and writes"| node_database
node_trigger_source -->|"fires trigger"| node_webhook
node_webhook -->|"creates run and outbox"| node_database
node_database -->|"supplies outbox rows"| node_processor
node_processor -->|"publishes events"| node_kafka
node_kafka -->|"delivers events"| node_worker
node_worker -->|"executes stages"| node_orchestration
node_worker -->|"creates and uses"| node_execution_store
node_worker -->|"selects handler"| node_action_handlers
node_orchestration -->|"claims and finalizes"| node_execution_store
node_worker -->|"loads Zap actions"| node_database
node_action_handlers -->|"executes configured action"| node_database
node_primary_api -->|"mounts routes"| node_triage_routes
node_triage_routes -->|"requests evidence"| node_triage_evidence
node_triage_routes -->|"requests operator cases"| node_triage_operator
node_triage_routes -->|"authorizes decisions"| node_investigation
node_triage_routes -->|"creates proposals"| node_proposals
node_triage_routes -->|"requests replay"| node_replay
node_triage_routes -->|"requests agent operations"| node_agent_client
node_agent_client -->|"calls preview service"| node_agent_graph
node_agent_graph -->|"retrieves runbooks"| node_runbook_search
node_triage_ui -.->|"views triage"| node_triage_routes
node_triage_evidence -->|"queries evidence"| node_database
node_investigation -->|"checks authority"| node_database
node_replay -->|"records replay state"| node_database

click node_frontend_app "https://github.com/thisshonrobert/zapier/tree/main/apps/frontend/src/app"
click node_triage_ui "https://github.com/thisshonrobert/zapier/blob/main/apps/frontend/src/app/triage/page.tsx"
click node_primary_api "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/index.ts"
click node_zap_routes "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/zap.ts"
click node_trigger_routes "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/trigger.ts"
click node_webhook "https://github.com/thisshonrobert/zapier/blob/main/apps/webhook/index.ts"
click node_processor "https://github.com/thisshonrobert/zapier/blob/main/apps/processor/index.ts"
click node_worker "https://github.com/thisshonrobert/zapier/blob/main/apps/worker/index.ts"
click node_orchestration "https://github.com/thisshonrobert/zapier/blob/main/apps/worker/orchestration.ts"
click node_execution_store "https://github.com/thisshonrobert/zapier/blob/main/apps/worker/execution-store.ts"
click node_action_handlers "https://github.com/thisshonrobert/zapier/blob/main/apps/worker/actions/index.ts"
click node_database "https://github.com/thisshonrobert/zapier/blob/main/packages/db/prisma/db.ts"
click node_triage_routes "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/triage.ts"
click node_triage_evidence "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-evidence.ts"
click node_triage_operator "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-operator.ts"
click node_investigation "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/investigation-authority.ts"
click node_proposals "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/investigation-proposals.ts"
click node_replay "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/replay.ts"
click node_agent_client "https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-agent.ts"
click node_agent_graph "https://github.com/thisshonrobert/zapier/blob/main/apps/ai_agent/src/graph.ts"
click node_runbook_search "https://github.com/thisshonrobert/zapier/blob/main/apps/ai_agent/src/tools/search-runbooks.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_frontend_app,node_triage_ui,node_user toneBlue
class node_primary_api,node_zap_routes,node_trigger_routes,node_webhook,node_processor,node_worker,node_orchestration,node_execution_store,node_action_handlers toneAmber
class node_triage_routes,node_triage_evidence,node_triage_operator,node_investigation,node_proposals,node_replay,node_agent_client,node_agent_graph,node_runbook_search toneMint
class node_run_outbox,node_kafka,node_database toneRose
class node_trigger_source toneIndigo
```

## Components

### Dashboard and builder

- [Dashboard and builder](https://github.com/thisshonrobert/zapier/tree/main/apps/frontend/src/app): `apps/frontend/src/app`
- [Triage screens](https://github.com/thisshonrobert/zapier/blob/main/apps/frontend/src/app/triage/page.tsx): `apps/frontend/src/app/triage/page.tsx`

### Zap execution

- [Primary API](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/index.ts): `apps/primary_backend/index.ts`
- [Zap CRUD routes](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/zap.ts): `apps/primary_backend/route/zap.ts`
- [Trigger routes](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/trigger.ts): `apps/primary_backend/route/trigger.ts`
- [Webhook ingress](https://github.com/thisshonrobert/zapier/blob/main/apps/webhook/index.ts): `apps/webhook/index.ts`
- [Outbox processor](https://github.com/thisshonrobert/zapier/blob/main/apps/processor/index.ts): `apps/processor/index.ts`
- [Stage consumer](https://github.com/thisshonrobert/zapier/blob/main/apps/worker/index.ts): `apps/worker/index.ts`
- [Stage orchestration](https://github.com/thisshonrobert/zapier/blob/main/apps/worker/orchestration.ts): `apps/worker/orchestration.ts`
- [Execution state](https://github.com/thisshonrobert/zapier/blob/main/apps/worker/execution-store.ts): `apps/worker/execution-store.ts`
- [Action handlers](https://github.com/thisshonrobert/zapier/blob/main/apps/worker/actions/index.ts): `apps/worker/actions/index.ts`

### Triage and recovery

- [Triage API routes](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/route/triage.ts): `apps/primary_backend/route/triage.ts`
- [Evidence service](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-evidence.ts): `apps/primary_backend/services/triage-evidence.ts`
- [Operator service](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-operator.ts): `apps/primary_backend/services/triage-operator.ts`
- [Investigation services](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/investigation-authority.ts): `apps/primary_backend/services/investigation-authority.ts`
- [Proposal services](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/investigation-proposals.ts): `apps/primary_backend/services/investigation-proposals.ts`
- [Replay service](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/replay.ts): `apps/primary_backend/services/replay.ts`
- [AI agent client](https://github.com/thisshonrobert/zapier/blob/main/apps/primary_backend/services/triage-agent.ts): `apps/primary_backend/services/triage-agent.ts`
- [Triage graph](https://github.com/thisshonrobert/zapier/blob/main/apps/ai_agent/src/graph.ts): `apps/ai_agent/src/graph.ts`
- [Runbook retrieval](https://github.com/thisshonrobert/zapier/blob/main/apps/ai_agent/src/tools/search-runbooks.ts): `apps/ai_agent/src/tools/search-runbooks.ts`

### Shared data

- **Run outbox**
- **Kafka events**
- [PostgreSQL](https://github.com/thisshonrobert/zapier/blob/main/packages/db/prisma/db.ts): `packages/db/prisma/db.ts`

### Other components

- **User**
- **Trigger source**

## Connections

- User → Dashboard and builder: configures Zaps
- Dashboard and builder → Primary API: creates workflows
- Primary API → Zap CRUD routes: routes requests (evidence: `apps/primary_backend/index.ts`)
- Primary API → Trigger routes: routes requests (evidence: `apps/primary_backend/index.ts`)
- Zap CRUD routes → PostgreSQL: reads and writes
- Trigger routes → PostgreSQL: reads and writes
- Trigger source → Webhook ingress: fires trigger
- Webhook ingress → PostgreSQL: creates run and outbox (evidence: `apps/webhook/index.ts`)
- PostgreSQL → Outbox processor: supplies outbox rows (evidence: `apps/processor/index.ts`)
- Outbox processor → Kafka events: publishes events
- Kafka events → Stage consumer: delivers events
- Stage consumer → Stage orchestration: executes stages (evidence: `apps/worker/index.ts`)
- Stage consumer → Execution state: creates and uses (evidence: `apps/worker/index.ts`)
- Stage consumer → Action handlers: selects handler (evidence: `apps/worker/index.ts`)
- Stage orchestration → Execution state: claims and finalizes (evidence: `apps/worker/orchestration.ts`)
- Stage consumer → PostgreSQL: loads Zap actions (evidence: `apps/worker/index.ts`)
- Action handlers → PostgreSQL: executes configured action
- Primary API → Triage API routes: mounts routes (evidence: `apps/primary_backend/index.ts`)
- Triage API routes → Evidence service: requests evidence (evidence: `apps/primary_backend/route/triage.ts`)
- Triage API routes → Operator service: requests operator cases (evidence: `apps/primary_backend/index.ts`)
- Triage API routes → Investigation services: authorizes decisions (evidence: `apps/primary_backend/index.ts`)
- Triage API routes → Proposal services: creates proposals (evidence: `apps/primary_backend/index.ts`)
- Triage API routes → Replay service: requests replay (evidence: `apps/primary_backend/index.ts`)
- Triage API routes → AI agent client: requests agent operations (evidence: `apps/primary_backend/route/triage.ts`)
- AI agent client → Triage graph: calls preview service
- Triage graph → Runbook retrieval: retrieves runbooks (evidence: `apps/ai_agent/src/graph.ts`)
- Triage screens → Triage API routes: views triage
- Evidence service → PostgreSQL: queries evidence (evidence: `apps/primary_backend/services/triage-evidence.ts`)
- Investigation services → PostgreSQL: checks authority (evidence: `apps/primary_backend/services/investigation-authority.ts`)
- Replay service → PostgreSQL: records replay state (evidence: `apps/primary_backend/services/replay.ts`)
