# cortezaproject/corteza architecture

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

- Interactive diagram: https://gitdiagram.com/cortezaproject/corteza
- Repository: https://github.com/cortezaproject/corteza

## Overview

#### Purpose and runtime entry points
Corteza is an open-source low-code platform for structured-data applications, workflow automation, integrations, RBAC, privacy, and federation. The primary runtime is a Go server launched by `server/cmd/corteza/main.go`; application bootstrapping, dependency initialization, and HTTP-server registration are centralized in `server/app/app.go` and `server/app/servers.go`. Container entry points are `server/Dockerfile` and `client/web/Dockerfile`.

#### Server composition and API boundary
The Go monolith is organized into domain components—System, Compose, Automation, Federation, and Discovery—each following a generated REST request/handler layer over domain services and types. REST routes are assembled per component, e.g. `server/system/rest/router.go`, `server/compose/rest/router.go`, and `server/automation/rest/router.go`. Handler code translates API payloads to service calls; services enforce business rules, permissions, events, and persistence.

#### System control plane: identity, policy, and platform services
System owns users, roles, settings, applications, attachments, queues, templates, API-gateway routes, privacy requests, and reporting. Authentication provides local login, sessions, OAuth2, SAML, MFA, and external providers through `server/auth/auth.go`, `server/auth/handlers/routes.go`, and `server/auth/oauth2/oauth2.go`. Authorization is flattened RBAC, implemented centrally in `server/pkg/rbac/service.go` and applied by generated component access-control services such as `server/system/service/access_control.go`. System also exposes SCIM at `server/system/scim/routes.go`.

#### Low-code data and application model
Compose is the primary application-building domain: namespaces contain modules (schemas), records, pages/layouts, charts, attachments, and notifications. Its core services are `server/compose/service/namespace.go`, `server/compose/service/module.go`, and `server/compose/service/record.go`. Record changes publish component events (`server/compose/service/event/record.go`), creating the main boundary into automation. Record values are validated, sanitized, formatted, and evaluated through `server/compose/service/values/`.

#### Automation, workflows, and asynchronous processing
Automation stores workflows, triggers, and execution sessions in `server/automation/service/workflow.go`, `server/automation/service/trigger.go`, and `server/automation/service/session.go`. The workflow executor interprets graph steps, gateways, iterators, prompts, state, and errors in `server/pkg/wfexec/`. Automation handlers bridge workflow steps to Compose, System, HTTP, email, queues, JavaScript, JWT, OAuth2, API-gateway bodies, and Corredor scripts (`server/automation/automation/`). Corredor is a gRPC-connected external automation service defined by `def/protobuf/service-corredor.proto` and integrated through `server/pkg/corredor/service.go`.

#### Data, import/export, and external infrastructure
The storage abstraction is `server/store/`; its RDBMS adapter supports PostgreSQL, MySQL, SQLite, and MSSQL under `server/store/adapters/rdbms/drivers/`. The DAL supports configurable connections, schemas, sensitivity levels, query pipelines, joins, links, aggregates, and multiple physical data sources via `server/pkg/dal/service.go` and `server/system/service/dal_connection.go`. Envoy provides graph-aware import/export of platform resources, YAML, CSV, and JSONL through `server/pkg/envoy/`. Supporting infrastructure includes MinIO-compatible or local object storage (`server/pkg/objstore/`), SMTP mail, message queues, websockets, scheduler, Sentry, and configurable HTTP clients.

#### Web applications and shared client contracts
Separate Vue SPAs serve distinct roles: administration (`client/web/admin/src/main.js`), low-code Compose authoring/runtime (`client/web/compose/src/main.js`), workflow graph editing (`client/web/workflow/src/main.js`), reporting, discovery, privacy, and application selection. Each uses routing and state stores to call server REST APIs. Shared TypeScript API clients and domain models live in `lib/js/src/api-clients/` and `lib/js/src/compose/`; shared Vue controls, auth/API plugins, RBAC, notification, and workflow-prompt facilities live in `lib/vue/src/`. Nginx serves built SPA assets through `client/web/nginx.conf`.

#### Integration-facing subsystems
The API gateway dynamically routes and filters requests, supports proxying and profiling, and is implemented in `server/pkg/apigw/`. Federation exchanges module structure and data with remote Corteza nodes through `server/federation/service/` and `server/federation/rest/router.go`. Discovery has both an in-server resource/feed API (`server/discovery/`) and an optional Elasticsearch-backed service at `extra/server-discovery/`, consumed by the Discovery SPA.

Main entry points: [`server/system/rest/router.go`](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/system/rest/router.go) (Component REST API), [`server/automation/service/workflow.go`](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/automation/service/workflow.go) (Workflow automation), [`server/compose/service/record.go`](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/compose/service/record.go) (Compose low-code data), [`client/web/compose/src/main.js`](https://github.com/cortezaproject/corteza/blob/2024.9.x/client/web/compose/src/main.js) (Role-specific Vue SPAs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Web clients"]
  node_spa["Role-specific Vue SPAs<br/>Vue applications<br/>[main.js]"]
  node_shared_js["Shared JS contracts<br/>TypeScript library<br/>[index.ts]"]
  node_shared_vue["Shared Vue facilities<br/>Vue library<br/>[index.ts]"]
  node_nginx["SPA asset server<br/>Nginx<br/>[nginx.conf]"]
end

subgraph group_server["Go platform"]
  node_server_main{{"Corteza server<br/>Go runtime<br/>[main.go]"}}
  node_app_boot["Application bootstrap<br/>composition root<br/>[app.go]"]
  node_rest_api["Component REST API<br/>HTTP boundary<br/>[router.go]"]
  node_auth["Authentication<br/>identity service<br/>[auth.go]"]
  node_rbac["RBAC policy<br/>authorization service<br/>[service.go]"]
end

subgraph group_domains["Domain services"]
  node_system["System control plane<br/>domain services<br/>[access_control.go]"]
  node_compose["Compose low-code data<br/>domain services<br/>[record.go]"]
  node_record_events["Record events<br/>event boundary<br/>[record.go]"]
  node_automation["Workflow automation<br/>domain services<br/>[workflow.go]"]
  node_wfexec{{"Workflow executor<br/>execution engine<br/>[graph.go]"}}
  node_federation["Federation<br/>domain service<br/>[service.go]"]
  node_discovery["Discovery<br/>resource and feed API<br/>[router.go]"]
end

subgraph group_integration["Data and integrations"]
  node_store[("RDBMS storage<br/>persistence abstraction<br/>[connect.go]")]
  node_dal["Data access layer<br/>data federation<br/>[service.go]"]
  node_envoy["Envoy import/export<br/>resource transfer<br/>[builder.go]"]
  node_apigw["API gateway<br/>dynamic gateway<br/>[service.go]"]
  node_corredor{{"Corredor<br/>external gRPC automation<br/>[service.go]"}}
  node_discovery_es["Optional Discovery service<br/>Elasticsearch-backed service<br/>[main.go]"]
end

node_spa -->|"uses"| node_shared_js
node_spa -->|"uses"| node_shared_vue
node_nginx -->|"serves built assets"| node_spa
node_spa -->|"REST calls"| node_rest_api
node_server_main -->|"boots"| node_app_boot
node_app_boot -->|"registers HTTP routes"| node_rest_api
node_rest_api -->|"authenticates"| node_auth
node_rest_api -->|"System endpoints"| node_system
node_rest_api -->|"Compose endpoints"| node_compose
node_rest_api -->|"Automation endpoints"| node_automation
node_rest_api -->|"Federation endpoints"| node_federation
node_rest_api -->|"Discovery endpoints"| node_discovery
node_system -->|"enforces access"| node_rbac
node_compose -->|"enforces access"| node_rbac
node_automation -->|"enforces access"| node_rbac
node_compose -->|"publishes changes"| node_record_events
node_record_events -->|"triggers workflows"| node_automation
node_automation -->|"executes"| node_wfexec
node_automation -->|"gRPC scripts"| node_corredor
node_system -->|"persists"| node_store
node_compose -->|"queries data"| node_dal
node_dal -->|"uses configured sources"| node_store
node_automation -->|"persists sessions"| node_store
node_federation -->|"syncs structures and data"| node_compose
node_envoy -->|"transfers resources"| node_system
node_envoy -->|"transfers resources"| node_compose
node_apigw -->|"routes integration traffic"| node_rest_api
node_discovery -.->|"optional search backend"| node_discovery_es

click node_spa "https://github.com/cortezaproject/corteza/blob/2024.9.x/client/web/compose/src/main.js"
click node_shared_js "https://github.com/cortezaproject/corteza/blob/2024.9.x/lib/js/src/api-clients/index.ts"
click node_shared_vue "https://github.com/cortezaproject/corteza/blob/2024.9.x/lib/vue/src/index.ts"
click node_nginx "https://github.com/cortezaproject/corteza/blob/2024.9.x/client/web/nginx.conf"
click node_server_main "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/cmd/corteza/main.go"
click node_app_boot "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/app/app.go"
click node_rest_api "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/system/rest/router.go"
click node_auth "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/auth/auth.go"
click node_rbac "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/rbac/service.go"
click node_system "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/system/service/access_control.go"
click node_compose "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/compose/service/record.go"
click node_record_events "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/compose/service/event/record.go"
click node_automation "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/automation/service/workflow.go"
click node_wfexec "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/wfexec/graph.go"
click node_federation "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/federation/service/service.go"
click node_discovery "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/discovery/rest/router.go"
click node_store "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/store/connect.go"
click node_dal "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/dal/service.go"
click node_envoy "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/envoy/builder.go"
click node_apigw "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/apigw/service.go"
click node_corredor "https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/corredor/service.go"
click node_discovery_es "https://github.com/cortezaproject/corteza/blob/2024.9.x/extra/server-discovery/main.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_spa,node_shared_js,node_shared_vue,node_nginx toneBlue
class node_server_main,node_app_boot,node_rest_api,node_auth,node_rbac toneAmber
class node_system,node_compose,node_record_events,node_automation,node_wfexec,node_federation,node_discovery toneMint
class node_store,node_dal,node_envoy,node_apigw,node_corredor,node_discovery_es toneRose
```

## Components

### Web clients

- [Role-specific Vue SPAs](https://github.com/cortezaproject/corteza/blob/2024.9.x/client/web/compose/src/main.js): Vue applications · Admin, Compose, workflow, reporting, discovery, privacy, and app-selection clients. · `client/web/compose/src/main.js`
- [Shared JS contracts](https://github.com/cortezaproject/corteza/blob/2024.9.x/lib/js/src/api-clients/index.ts): TypeScript library · API clients and Compose domain models shared by SPAs. · `lib/js/src/api-clients/index.ts`
- [Shared Vue facilities](https://github.com/cortezaproject/corteza/blob/2024.9.x/lib/vue/src/index.ts): Vue library · Shared controls, auth/API plugins, RBAC, notifications, and workflow prompts. · `lib/vue/src/index.ts`
- [SPA asset server](https://github.com/cortezaproject/corteza/blob/2024.9.x/client/web/nginx.conf): Nginx · `client/web/nginx.conf`

### Go platform

- [Corteza server](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/cmd/corteza/main.go): Go runtime · Primary monolith entry point. · `server/cmd/corteza/main.go`
- [Application bootstrap](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/app/app.go): composition root · Initializes dependencies and registers HTTP servers. · `server/app/app.go`
- [Component REST API](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/system/rest/router.go): HTTP boundary · Generated request and handler layers assemble component routes. · `server/system/rest/router.go`
- [Authentication](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/auth/auth.go): identity service · Local sessions, OAuth2, SAML, MFA, and external providers. · `server/auth/auth.go`
- [RBAC policy](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/rbac/service.go): authorization service · Central flattened role-based access control. · `server/pkg/rbac/service.go`

### Domain services

- [System control plane](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/system/service/access_control.go): domain services · Users, roles, settings, platform resources, privacy, and reporting. · `server/system/service/access_control.go`
- [Compose low-code data](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/compose/service/record.go): domain services · Namespaces, modules, records, pages, charts, and attachments. · `server/compose/service/record.go`
- [Record events](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/compose/service/event/record.go): event boundary · Publishes Compose record changes to automation. · `server/compose/service/event/record.go`
- [Workflow automation](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/automation/service/workflow.go): domain services · Workflows, triggers, and execution sessions. · `server/automation/service/workflow.go`
- [Workflow executor](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/wfexec/graph.go): execution engine · Interprets workflow graphs, gateways, iterators, prompts, and state. · `server/pkg/wfexec/graph.go`
- [Federation](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/federation/service/service.go): domain service · Exchanges module structure and data with remote Corteza nodes. · `server/federation/service/service.go`
- [Discovery](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/discovery/rest/router.go): resource and feed API · In-server discovery resources and feeds. · `server/discovery/rest/router.go`

### Data and integrations

- [RDBMS storage](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/store/connect.go): persistence abstraction · Supports PostgreSQL, MySQL, SQLite, and MSSQL adapters. · `server/store/connect.go`
- [Data access layer](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/dal/service.go): data federation · Configurable schemas, connections, query pipelines, and physical sources. · `server/pkg/dal/service.go`
- [Envoy import/export](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/envoy/builder.go): resource transfer · Graph-aware YAML, CSV, and JSONL import/export. · `server/pkg/envoy/builder.go`
- [API gateway](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/apigw/service.go): dynamic gateway · Routes, filters, proxies, and profiles integration requests. · `server/pkg/apigw/service.go`
- [Corredor](https://github.com/cortezaproject/corteza/blob/2024.9.x/server/pkg/corredor/service.go): external gRPC automation · External script automation service. · `server/pkg/corredor/service.go`
- [Optional Discovery service](https://github.com/cortezaproject/corteza/blob/2024.9.x/extra/server-discovery/main.go): Elasticsearch-backed service · `extra/server-discovery/main.go`

## Connections

- Role-specific Vue SPAs → Shared JS contracts: uses
- Role-specific Vue SPAs → Shared Vue facilities: uses
- SPA asset server → Role-specific Vue SPAs: serves built assets
- Role-specific Vue SPAs → Component REST API: REST calls
- Corteza server → Application bootstrap: boots
- Application bootstrap → Component REST API: registers HTTP routes
- Component REST API → Authentication: authenticates
- Component REST API → System control plane: System endpoints
- Component REST API → Compose low-code data: Compose endpoints
- Component REST API → Workflow automation: Automation endpoints
- Component REST API → Federation: Federation endpoints
- Component REST API → Discovery: Discovery endpoints
- System control plane → RBAC policy: enforces access
- Compose low-code data → RBAC policy: enforces access
- Workflow automation → RBAC policy: enforces access
- Compose low-code data → Record events: publishes changes
- Record events → Workflow automation: triggers workflows
- Workflow automation → Workflow executor: executes
- Workflow automation → Corredor: gRPC scripts
- System control plane → RDBMS storage: persists
- Compose low-code data → Data access layer: queries data
- Data access layer → RDBMS storage: uses configured sources
- Workflow automation → RDBMS storage: persists sessions
- Federation → Compose low-code data: syncs structures and data
- Envoy import/export → System control plane: transfers resources
- Envoy import/export → Compose low-code data: transfers resources
- API gateway → Component REST API: routes integration traffic
- Discovery → Optional Discovery service: optional search backend
