# couchbase/eventing architecture

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

- Interactive diagram: https://gitdiagram.com/couchbase/eventing
- Repository: https://github.com/couchbase/eventing

## Overview

Couchbase Eventing lets users deploy JavaScript handlers that react to bucket changes. The service accepts and validates function definitions, coordinates their lifecycle and distribution across Eventing nodes, consumes Couchbase DCP changes, and dispatches events to V8 workers. Handlers can access Couchbase buckets, issue N1QL, Analytics, and Search queries, and use timers or HTTP extensions. The graph preserves those documented runtime capabilities; several feature implementations and UI internals were not sampled, so their detailed call paths are omitted.

Main entry points: [`v8_consumer/src/v8worker.cc`](https://github.com/couchbase/eventing/blob/master/v8_consumer/src/v8worker.cc) (V8 handler worker), [`function_manager/function_manager_impl.go`](https://github.com/couchbase/eventing/blob/master/function_manager/function_manager_impl.go) (Function runtime manager), [`application/application.go`](https://github.com/couchbase/eventing/blob/master/application/application.go) (Function definition), [`service_manager2/service_manager_impl.go`](https://github.com/couchbase/eventing/blob/master/service_manager2/service_manager_impl.go) (REST service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Authoring and service"]
  node_ui["Eventing UI<br/>[eventing.js]"]
  node_rest_service["REST service"]
  node_function_definition["Function definition<br/>[application.go]"]
end

subgraph group_coordination["Lifecycle and distribution"]
  node_app_manager["App lifecycle"]
  node_service_manager["Service coordination<br/>[manager.go]"]
  node_function_manager["Function runtime manager"]
  node_supervisor["Worker distribution<br/>[manager.go]"]
  node_process_manager["Process control"]
end

subgraph group_event_runtime["Event processing"]
  node_dcp_manager["DCP stream manager"]
  node_dcp_connection["DCP connection<br/>[client.go]"]
  node_event_consumer["Event consumer<br/>[process_events.go]"]
  node_v8_worker["V8 handler worker<br/>[v8worker.cc]"]
end

subgraph group_handler_features["Handler capabilities"]
  node_bucket_api["Bucket operations<br/>[bucket.cc]"]
  node_query_manager["Query iterators<br/>[manager.cc]"]
  node_query_engine["Query services<br/>[n1ql_query.cc]"]
  node_http_extension["HTTP extension<br/>[curl.h]"]
  node_timer_store["Timer operations<br/>[timer_store.go]"]
end

subgraph group_state["Checkpoint state"]
  node_checkpoint_manager["Checkpoint manager"]
end

node_user(("Eventing user"))
node_couchbase[("Couchbase Server")]

node_user -->|"authors functions"| node_ui
node_ui -.->|"submits configuration"| node_rest_service
node_rest_service -->|"validates configuration"| node_function_definition
node_rest_service -->|"coordinates lifecycle"| node_app_manager
node_app_manager -->|"loads definition"| node_function_definition
node_service_manager -->|"tracks functions"| node_function_definition
node_function_manager -->|"configures runtime"| node_function_definition
node_function_manager -->|"manages processes"| node_process_manager
node_function_manager -->|"distributes workers"| node_supervisor
node_supervisor -.->|"assigns partitions"| node_function_manager
node_process_manager -.->|"dispatches events"| node_event_consumer
node_dcp_manager -->|"manages streams"| node_dcp_connection
node_dcp_connection -.->|"delivers changes"| node_event_consumer
node_event_consumer -.->|"sends events"| node_v8_worker
node_v8_worker -->|"invokes bucket API"| node_bucket_api
node_v8_worker -->|"creates query iterators"| node_query_manager
node_query_manager -.->|"runs queries"| node_query_engine
node_v8_worker -->|"offers HTTP calls"| node_http_extension
node_v8_worker -.->|"supports timers"| node_timer_store
node_bucket_api -.->|"reads and writes"| node_couchbase
node_query_engine -.->|"queries data"| node_couchbase
node_checkpoint_manager -->|"persists progress"| node_couchbase
node_process_manager -->|"coordinates checkpoints"| node_checkpoint_manager

click node_ui "https://github.com/couchbase/eventing/blob/master/ui/eventing-ui/ui-current/eventing.js"
click node_rest_service "https://github.com/couchbase/eventing/blob/master/service_manager2/service_manager_impl.go"
click node_function_definition "https://github.com/couchbase/eventing/blob/master/application/application.go"
click node_app_manager "https://github.com/couchbase/eventing/blob/master/app_manager/app_manager_impl.go"
click node_service_manager "https://github.com/couchbase/eventing/blob/master/service_manager/manager.go"
click node_function_manager "https://github.com/couchbase/eventing/blob/master/function_manager/function_manager_impl.go"
click node_supervisor "https://github.com/couchbase/eventing/blob/master/supervisor2/manager.go"
click node_process_manager "https://github.com/couchbase/eventing/blob/master/process_manager/process_manager_impl.go"
click node_dcp_manager "https://github.com/couchbase/eventing/blob/master/dcp_manager/dcp_manager_impl.go"
click node_dcp_connection "https://github.com/couchbase/eventing/blob/master/dcp_connection/client.go"
click node_event_consumer "https://github.com/couchbase/eventing/blob/master/consumer/process_events.go"
click node_v8_worker "https://github.com/couchbase/eventing/blob/master/v8_consumer/src/v8worker.cc"
click node_bucket_api "https://github.com/couchbase/eventing/blob/master/features/src/bucket.cc"
click node_query_manager "https://github.com/couchbase/eventing/blob/master/features/query/src/manager.cc"
click node_query_engine "https://github.com/couchbase/eventing/blob/master/features/query/src/n1ql_query.cc"
click node_http_extension "https://github.com/couchbase/eventing/blob/master/features/include/curl.h"
click node_timer_store "https://github.com/couchbase/eventing/blob/master/timers/timer_store.go"
click node_checkpoint_manager "https://github.com/couchbase/eventing/blob/master/checkpoint_manager/checkpoint_manager_impl.go"

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_ui,node_rest_service,node_function_definition,node_user toneBlue
class node_app_manager,node_service_manager,node_function_manager,node_supervisor,node_process_manager,node_couchbase toneAmber
class node_dcp_manager,node_dcp_connection,node_event_consumer,node_v8_worker toneMint
class node_bucket_api,node_query_manager,node_query_engine,node_http_extension,node_timer_store toneRose
class node_checkpoint_manager toneIndigo
```

## Components

### Authoring and service

- [Eventing UI](https://github.com/couchbase/eventing/blob/master/ui/eventing-ui/ui-current/eventing.js): `ui/eventing-ui/ui-current/eventing.js`
- [REST service](https://github.com/couchbase/eventing/blob/master/service_manager2/service_manager_impl.go): `service_manager2/service_manager_impl.go`
- [Function definition](https://github.com/couchbase/eventing/blob/master/application/application.go): `application/application.go`

### Lifecycle and distribution

- [App lifecycle](https://github.com/couchbase/eventing/blob/master/app_manager/app_manager_impl.go): `app_manager/app_manager_impl.go`
- [Service coordination](https://github.com/couchbase/eventing/blob/master/service_manager/manager.go): `service_manager/manager.go`
- [Function runtime manager](https://github.com/couchbase/eventing/blob/master/function_manager/function_manager_impl.go): `function_manager/function_manager_impl.go`
- [Worker distribution](https://github.com/couchbase/eventing/blob/master/supervisor2/manager.go): `supervisor2/manager.go`
- [Process control](https://github.com/couchbase/eventing/blob/master/process_manager/process_manager_impl.go): `process_manager/process_manager_impl.go`

### Event processing

- [DCP stream manager](https://github.com/couchbase/eventing/blob/master/dcp_manager/dcp_manager_impl.go): `dcp_manager/dcp_manager_impl.go`
- [DCP connection](https://github.com/couchbase/eventing/blob/master/dcp_connection/client.go): `dcp_connection/client.go`
- [Event consumer](https://github.com/couchbase/eventing/blob/master/consumer/process_events.go): `consumer/process_events.go`
- [V8 handler worker](https://github.com/couchbase/eventing/blob/master/v8_consumer/src/v8worker.cc): `v8_consumer/src/v8worker.cc`

### Handler capabilities

- [Bucket operations](https://github.com/couchbase/eventing/blob/master/features/src/bucket.cc): `features/src/bucket.cc`
- [Query iterators](https://github.com/couchbase/eventing/blob/master/features/query/src/manager.cc): `features/query/src/manager.cc`
- [Query services](https://github.com/couchbase/eventing/blob/master/features/query/src/n1ql_query.cc): `features/query/src/n1ql_query.cc`
- [HTTP extension](https://github.com/couchbase/eventing/blob/master/features/include/curl.h): `features/include/curl.h`
- [Timer operations](https://github.com/couchbase/eventing/blob/master/timers/timer_store.go): `timers/timer_store.go`

### Checkpoint state

- [Checkpoint manager](https://github.com/couchbase/eventing/blob/master/checkpoint_manager/checkpoint_manager_impl.go): `checkpoint_manager/checkpoint_manager_impl.go`

### Other components

- **Eventing user**
- **Couchbase Server**

## Connections

- Eventing user → Eventing UI: authors functions
- Eventing UI → REST service: submits configuration
- REST service → Function definition: validates configuration (evidence: `service_manager2/service_manager_impl.go`)
- REST service → App lifecycle: coordinates lifecycle (evidence: `service_manager2/service_manager_impl.go`)
- App lifecycle → Function definition: loads definition (evidence: `app_manager/app_manager_impl.go`)
- Service coordination → Function definition: tracks functions (evidence: `service_manager/manager.go`)
- Function runtime manager → Function definition: configures runtime (evidence: `function_manager/function_manager_impl.go`)
- Function runtime manager → Process control: manages processes (evidence: `function_manager/function_manager_impl.go`)
- Function runtime manager → Worker distribution: distributes workers (evidence: `function_manager/function_manager_impl.go`)
- Worker distribution → Function runtime manager: assigns partitions
- Process control → Event consumer: dispatches events
- DCP stream manager → DCP connection: manages streams (evidence: `dcp_manager/dcp_manager_impl.go`)
- DCP connection → Event consumer: delivers changes
- Event consumer → V8 handler worker: sends events
- V8 handler worker → Bucket operations: invokes bucket API (evidence: `v8_consumer/src/v8worker.cc`)
- V8 handler worker → Query iterators: creates query iterators (evidence: `v8_consumer/src/v8worker.cc`)
- Query iterators → Query services: runs queries
- V8 handler worker → HTTP extension: offers HTTP calls (evidence: `v8_consumer/src/v8worker.cc`)
- V8 handler worker → Timer operations: supports timers
- Bucket operations → Couchbase Server: reads and writes
- Query services → Couchbase Server: queries data
- Checkpoint manager → Couchbase Server: persists progress (evidence: `checkpoint_manager/checkpoint_manager_impl.go`)
- Process control → Checkpoint manager: coordinates checkpoints (evidence: `process_manager/process_manager_impl.go`)
