# corazawaf/coraza architecture

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

- Interactive diagram: https://gitdiagram.com/corazawaf/coraza
- Repository: https://github.com/corazawaf/coraza

## Overview

Coraza is a Go web application firewall that accepts SecLang rules and inspects HTTP transactions, returning interruptions and audit information. The main workflow is application or HTTP-server input → WAF configuration and rule parsing → transaction processing across request and response phases → enforcement and logging. The graph also preserves the documented plugin extension surface and the internal rule, body-processing, and audit subsystems. Some runtime links are omitted because the sampled excerpts do not show their callers.

Main entry points: [`internal/corazawaf/transaction.go`](https://github.com/corazawaf/coraza/blob/main/internal/corazawaf/transaction.go) (Transaction processing), [`types/transaction.go`](https://github.com/corazawaf/coraza/blob/main/types/transaction.go) (Transaction API), [`internal/seclang/rule_parser.go`](https://github.com/corazawaf/coraza/blob/main/internal/seclang/rule_parser.go) (Rule parser), [`http/interceptor.go`](https://github.com/corazawaf/coraza/blob/main/http/interceptor.go) (HTTP adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Integration"]
  node_http["HTTP adapter<br/>[interceptor.go]"]
  node_middleware["HTTP middleware<br/>[middleware.go]"]
end

subgraph group_configuration["Configuration"]
  node_wafapi["WAF API<br/>[waf.go]"]
  node_config["WAF configuration<br/>[config.go]"]
  node_seclang["SecLang parser<br/>[parser.go]"]
  node_ruleparser["Rule parser<br/>[rule_parser.go]"]
end

subgraph group_runtime["Transaction runtime"]
  node_transaction["Transaction processing<br/>[transaction.go]"]
  node_transactionapi["Transaction API<br/>[transaction.go]"]
  node_variables["Rule variables<br/>[variables.go]"]
  node_collections["Variable collections<br/>[map.go]"]
  node_audit["Audit logging<br/>[auditlog.go]"]
end

subgraph group_inspection["Inspection engine"]
  node_rule["Rule evaluation<br/>[rule.go]"]
  node_bodyprocessors["Body processors<br/>[bodyprocessors.go]"]
  node_operators["Rule operators<br/>[operators.go]"]
  node_actions["Rule actions<br/>[actions.go]"]
  node_transformations["Transformations<br/>[transformations.go]"]
end

subgraph group_extensions["Extensions"]
  node_plugins["Plugin interfaces<br/>[transaction.go]"]
  node_pluginregistry["Plugin registration<br/>[actions.go]"]
end

node_app(("Application"))

node_app -->|"configures WAF"| node_wafapi
node_app -.->|"serves requests"| node_http
node_app -->|"integrates WAF"| node_middleware
node_http -->|"feeds HTTP data"| node_transactionapi
node_middleware -->|"uses transactions"| node_transactionapi
node_wafapi -.->|"builds configuration"| node_config
node_config -->|"parses directives"| node_seclang
node_ruleparser -->|"resolves operators"| node_operators
node_ruleparser -->|"resolves actions"| node_actions
node_seclang -.->|"creates rules"| node_rule
node_transactionapi -.->|"exposes phases"| node_transaction
node_transaction -->|"processes bodies"| node_bodyprocessors
node_transaction -->|"collects audit data"| node_audit
node_transaction -.->|"uses variables"| node_variables
node_variables -.->|"stores values"| node_collections
node_rule -->|"uses plugin types"| node_plugins
node_pluginregistry -.->|"implements interfaces"| node_plugins

click node_http "https://github.com/corazawaf/coraza/blob/main/http/interceptor.go"
click node_middleware "https://github.com/corazawaf/coraza/blob/main/http/middleware.go"
click node_wafapi "https://github.com/corazawaf/coraza/blob/main/waf.go"
click node_config "https://github.com/corazawaf/coraza/blob/main/config.go"
click node_seclang "https://github.com/corazawaf/coraza/blob/main/internal/seclang/parser.go"
click node_ruleparser "https://github.com/corazawaf/coraza/blob/main/internal/seclang/rule_parser.go"
click node_rule "https://github.com/corazawaf/coraza/blob/main/internal/corazawaf/rule.go"
click node_transaction "https://github.com/corazawaf/coraza/blob/main/internal/corazawaf/transaction.go"
click node_transactionapi "https://github.com/corazawaf/coraza/blob/main/types/transaction.go"
click node_variables "https://github.com/corazawaf/coraza/blob/main/internal/variables/variables.go"
click node_bodyprocessors "https://github.com/corazawaf/coraza/blob/main/internal/bodyprocessors/bodyprocessors.go"
click node_collections "https://github.com/corazawaf/coraza/blob/main/internal/collections/map.go"
click node_audit "https://github.com/corazawaf/coraza/blob/main/internal/auditlog/auditlog.go"
click node_operators "https://github.com/corazawaf/coraza/blob/main/internal/operators/operators.go"
click node_actions "https://github.com/corazawaf/coraza/blob/main/internal/actions/actions.go"
click node_transformations "https://github.com/corazawaf/coraza/blob/main/internal/transformations/transformations.go"
click node_plugins "https://github.com/corazawaf/coraza/blob/main/experimental/plugins/plugintypes/transaction.go"
click node_pluginregistry "https://github.com/corazawaf/coraza/blob/main/experimental/plugins/actions.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_http,node_middleware toneBlue
class node_wafapi,node_config,node_seclang,node_ruleparser toneAmber
class node_transaction,node_transactionapi,node_variables,node_collections,node_audit toneMint
class node_rule,node_bodyprocessors,node_operators,node_actions,node_transformations toneRose
class node_plugins,node_pluginregistry,node_app toneIndigo
```

## Components

### Integration

- [HTTP adapter](https://github.com/corazawaf/coraza/blob/main/http/interceptor.go): `http/interceptor.go`
- [HTTP middleware](https://github.com/corazawaf/coraza/blob/main/http/middleware.go): `http/middleware.go`

### Configuration

- [WAF API](https://github.com/corazawaf/coraza/blob/main/waf.go): `waf.go`
- [WAF configuration](https://github.com/corazawaf/coraza/blob/main/config.go): `config.go`
- [SecLang parser](https://github.com/corazawaf/coraza/blob/main/internal/seclang/parser.go): `internal/seclang/parser.go`
- [Rule parser](https://github.com/corazawaf/coraza/blob/main/internal/seclang/rule_parser.go): `internal/seclang/rule_parser.go`

### Transaction runtime

- [Transaction processing](https://github.com/corazawaf/coraza/blob/main/internal/corazawaf/transaction.go): `internal/corazawaf/transaction.go`
- [Transaction API](https://github.com/corazawaf/coraza/blob/main/types/transaction.go): `types/transaction.go`
- [Rule variables](https://github.com/corazawaf/coraza/blob/main/internal/variables/variables.go): `internal/variables/variables.go`
- [Variable collections](https://github.com/corazawaf/coraza/blob/main/internal/collections/map.go): `internal/collections/map.go`
- [Audit logging](https://github.com/corazawaf/coraza/blob/main/internal/auditlog/auditlog.go): `internal/auditlog/auditlog.go`

### Inspection engine

- [Rule evaluation](https://github.com/corazawaf/coraza/blob/main/internal/corazawaf/rule.go): `internal/corazawaf/rule.go`
- [Body processors](https://github.com/corazawaf/coraza/blob/main/internal/bodyprocessors/bodyprocessors.go): `internal/bodyprocessors/bodyprocessors.go`
- [Rule operators](https://github.com/corazawaf/coraza/blob/main/internal/operators/operators.go): `internal/operators/operators.go`
- [Rule actions](https://github.com/corazawaf/coraza/blob/main/internal/actions/actions.go): `internal/actions/actions.go`
- [Transformations](https://github.com/corazawaf/coraza/blob/main/internal/transformations/transformations.go): `internal/transformations/transformations.go`

### Extensions

- [Plugin interfaces](https://github.com/corazawaf/coraza/blob/main/experimental/plugins/plugintypes/transaction.go): `experimental/plugins/plugintypes/transaction.go`
- [Plugin registration](https://github.com/corazawaf/coraza/blob/main/experimental/plugins/actions.go): `experimental/plugins/actions.go`

### Other components

- **Application**

## Connections

- Application → WAF API: configures WAF
- Application → HTTP adapter: serves requests
- Application → HTTP middleware: integrates WAF
- HTTP adapter → Transaction API: feeds HTTP data (evidence: `http/interceptor.go`)
- HTTP middleware → Transaction API: uses transactions (evidence: `http/middleware.go`)
- WAF API → WAF configuration: builds configuration
- WAF configuration → SecLang parser: parses directives
- Rule parser → Rule operators: resolves operators (evidence: `internal/seclang/rule_parser.go`)
- Rule parser → Rule actions: resolves actions (evidence: `internal/seclang/rule_parser.go`)
- SecLang parser → Rule evaluation: creates rules
- Transaction API → Transaction processing: exposes phases
- Transaction processing → Body processors: processes bodies (evidence: `internal/corazawaf/transaction.go`)
- Transaction processing → Audit logging: collects audit data (evidence: `internal/corazawaf/transaction.go`)
- Transaction processing → Rule variables: uses variables
- Rule variables → Variable collections: stores values
- Rule evaluation → Plugin interfaces: uses plugin types (evidence: `internal/corazawaf/rule.go`)
- Plugin registration → Plugin interfaces: implements interfaces
