# opengrep/opengrep architecture

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

- Interactive diagram: https://gitdiagram.com/opengrep/opengrep
- Repository: https://github.com/opengrep/opengrep

## Overview

Opengrep is an open-source static analysis engine. Its main workflow accepts rules and source targets, scans for code patterns and security issues, then presents findings or emits JSON/SARIF. The tree identifies separate CLI, parsing, matching, taint, fixing, reporting, and language-server areas; the README documents broad language support and intrafile taint analysis. Source excerpts did not include the scan implementation, so the graph captures the documented workflow and major capabilities without asserting detailed internal call wiring.

Main entry points: [`src/osemgrep/core_runner`](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/core_runner) (Core runner), [`src/osemgrep/cli_scan`](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/cli_scan) (Scan CLI), [`src/parsing_languages`](https://github.com/opengrep/opengrep/tree/main/src/parsing_languages) (Language parsing), [`src/tainting`](https://github.com/opengrep/opengrep/tree/main/src/tainting) (Taint analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_scan_cli["Scan CLI"]
  node_language_server["Language server"]
end

subgraph group_scan["Scan workflow"]
  node_configuration["Scan configuration"]
  node_targets["Target selection"]
  node_parsing["Language parsing"]
  node_language_grammars["Language parsers"]
  node_generic_ast["Generic AST"]
  node_core_runner["Core runner"]
end

subgraph group_analysis["Analysis capabilities"]
  node_matching["Pattern matching"]
  node_taint["Taint analysis"]
  node_interfile["Interfile analysis"]
  node_fixing["Autofix"]
end

subgraph group_results["Results and integrations"]
  node_findings["Findings"]
  node_reporting["Output formats"]
end

node_developer(("Developer"))
node_rules["Rulesets"]
node_source["Source code"]
node_sarif_json["JSON / SARIF"]
node_terminal(("Terminal results"))

node_developer -->|"invokes"| node_scan_cli
node_developer -->|"uses"| node_language_server
node_rules -->|"supplies rules"| node_scan_cli
node_source -->|"supplies targets"| node_scan_cli
node_scan_cli -->|"configures scan"| node_configuration
node_scan_cli -->|"starts scan"| node_core_runner
node_core_runner -->|"selects files"| node_targets
node_core_runner -->|"parses targets"| node_parsing
node_parsing -->|"uses parsers"| node_language_grammars
node_parsing -->|"produces AST"| node_generic_ast
node_core_runner -->|"runs rules"| node_matching
node_core_runner -->|"runs taint analysis"| node_taint
node_taint -.->|"uses call graphs"| node_interfile
node_matching -->|"produces matches"| node_findings
node_taint -->|"reports flows"| node_findings
node_findings -->|"formats results"| node_reporting
node_reporting -->|"emits JSON/SARIF"| node_sarif_json
node_reporting -->|"prints findings"| node_terminal
node_scan_cli -.->|"offers fixes"| node_fixing
node_language_server -.->|"requests analysis"| node_core_runner

click node_scan_cli "https://github.com/opengrep/opengrep/tree/main/src/osemgrep/cli_scan"
click node_language_server "https://github.com/opengrep/opengrep/tree/main/src/osemgrep/language_server"
click node_configuration "https://github.com/opengrep/opengrep/tree/main/src/osemgrep/configuring"
click node_targets "https://github.com/opengrep/opengrep/tree/main/src/targeting"
click node_parsing "https://github.com/opengrep/opengrep/tree/main/src/parsing_languages"
click node_language_grammars "https://github.com/opengrep/opengrep/tree/main/languages"
click node_generic_ast "https://github.com/opengrep/opengrep/tree/main/libs/ast_generic"
click node_core_runner "https://github.com/opengrep/opengrep/tree/main/src/osemgrep/core_runner"
click node_matching "https://github.com/opengrep/opengrep/tree/main/src/matching"
click node_taint "https://github.com/opengrep/opengrep/tree/main/src/tainting"
click node_interfile "https://github.com/opengrep/opengrep/tree/main/src/call_graph"
click node_fixing "https://github.com/opengrep/opengrep/tree/main/src/fixing"
click node_findings "https://github.com/opengrep/opengrep/tree/main/src/core"
click node_reporting "https://github.com/opengrep/opengrep/tree/main/src/reporting"

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_scan_cli,node_language_server toneBlue
class node_configuration,node_targets,node_parsing,node_language_grammars,node_generic_ast,node_core_runner toneAmber
class node_matching,node_taint,node_interfile,node_fixing toneMint
class node_findings,node_reporting toneRose
class node_developer,node_rules,node_source,node_sarif_json,node_terminal toneIndigo
```

## Components

### User interfaces

- [Scan CLI](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/cli_scan): `src/osemgrep/cli_scan`
- [Language server](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/language_server): `src/osemgrep/language_server`

### Scan workflow

- [Scan configuration](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/configuring): `src/osemgrep/configuring`
- [Target selection](https://github.com/opengrep/opengrep/tree/main/src/targeting): `src/targeting`
- [Language parsing](https://github.com/opengrep/opengrep/tree/main/src/parsing_languages): `src/parsing_languages`
- [Language parsers](https://github.com/opengrep/opengrep/tree/main/languages): `languages`
- [Generic AST](https://github.com/opengrep/opengrep/tree/main/libs/ast_generic): `libs/ast_generic`
- [Core runner](https://github.com/opengrep/opengrep/tree/main/src/osemgrep/core_runner): `src/osemgrep/core_runner`

### Analysis capabilities

- [Pattern matching](https://github.com/opengrep/opengrep/tree/main/src/matching): `src/matching`
- [Taint analysis](https://github.com/opengrep/opengrep/tree/main/src/tainting): `src/tainting`
- [Interfile analysis](https://github.com/opengrep/opengrep/tree/main/src/call_graph): `src/call_graph`
- [Autofix](https://github.com/opengrep/opengrep/tree/main/src/fixing): `src/fixing`

### Results and integrations

- [Findings](https://github.com/opengrep/opengrep/tree/main/src/core): `src/core`
- [Output formats](https://github.com/opengrep/opengrep/tree/main/src/reporting): `src/reporting`

### Other components

- **Developer**
- **Rulesets**
- **Source code**
- **JSON / SARIF**
- **Terminal results**

## Connections

- Developer → Scan CLI: invokes
- Developer → Language server: uses
- Rulesets → Scan CLI: supplies rules
- Source code → Scan CLI: supplies targets
- Scan CLI → Scan configuration: configures scan
- Scan CLI → Core runner: starts scan
- Core runner → Target selection: selects files
- Core runner → Language parsing: parses targets
- Language parsing → Language parsers: uses parsers
- Language parsing → Generic AST: produces AST
- Core runner → Pattern matching: runs rules
- Core runner → Taint analysis: runs taint analysis
- Taint analysis → Interfile analysis: uses call graphs
- Pattern matching → Findings: produces matches
- Taint analysis → Findings: reports flows
- Findings → Output formats: formats results
- Output formats → JSON / SARIF: emits JSON/SARIF
- Output formats → Terminal results: prints findings
- Scan CLI → Autofix: offers fixes
- Language server → Core runner: requests analysis
