# machindra7/trustlens-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/machindra7/trustlens-pipeline
- Repository: https://github.com/machindra7/trustlens-pipeline

## Overview

TrustLens scans a selected repository with Checkov, Trivy, and Semgrep, normalizes and deduplicates their results into a unified finding model, writes JSON, and can upload findings to PostgreSQL. A Next.js application exposes findings and database health endpoints and includes landing and dashboard pages. Scanner, normalization, ingestion, and API-to-database relationships are supported by the sampled source. The page-to-API wiring and unsampled dashboard behavior are not shown, so those links are omitted.

Main entry points: [`trustlens/main.py`](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/main.py) (CLI pipeline), [`trustlens/scanners/checkov_scanner.py`](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/checkov_scanner.py) (Checkov scanner), [`trustlens/scanners/trivy_scanner.py`](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/trivy_scanner.py) (Trivy scanner), [`trustlens/scanners/semgrep_scanner.py`](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/semgrep_scanner.py) (Semgrep scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scan["Scanning and normalization"]
  node_pipeline["CLI pipeline<br/>[main.py]"]
  node_checkov["Checkov scanner<br/>[checkov_scanner.py]"]
  node_trivy["Trivy scanner<br/>[trivy_scanner.py]"]
  node_semgrep["Semgrep scanner<br/>[semgrep_scanner.py]"]
  node_normalizer["Finding normalizer<br/>[normalize.py]"]
  node_finding_model["Unified finding model<br/>[finding.py]"]
end

subgraph group_ingest["Ingestion and storage"]
  node_json_output["Findings JSON"]
  node_ingestion["Database ingestion<br/>[ingest_findings.py]"]
  node_findings_table[("Findings table<br/>[schema.ts]")]
end

subgraph group_web["Web application"]
  node_web_db["Web database client<br/>[index.ts]"]
  node_findings_api["Findings API<br/>[route.ts]"]
  node_health_api["Health API<br/>[route.ts]"]
  node_landing["Landing page<br/>[page.tsx]"]
  node_dashboard["Dashboard page<br/>[page.tsx]"]
end

node_operator(("Operator"))
node_repository["Target repository"]
node_checkov_tool["Checkov"]
node_trivy_tool["Trivy"]
node_semgrep_tool["Semgrep"]
node_postgres[("PostgreSQL")]

node_operator -->|"runs scan"| node_pipeline
node_repository -->|"scan target"| node_pipeline
node_pipeline -->|"calls scan"| node_checkov
node_pipeline -->|"calls scan"| node_trivy
node_pipeline -->|"calls scan"| node_semgrep
node_checkov -->|"runs"| node_checkov_tool
node_trivy -->|"runs"| node_trivy_tool
node_semgrep -->|"runs"| node_semgrep_tool
node_checkov -->|"returns findings"| node_pipeline
node_trivy -->|"returns findings"| node_pipeline
node_semgrep -->|"returns findings"| node_pipeline
node_pipeline -->|"normalizes results"| node_normalizer
node_normalizer -->|"creates findings"| node_finding_model
node_pipeline -->|"writes findings"| node_json_output
node_pipeline -->|"starts upload"| node_ingestion
node_ingestion -->|"reads findings"| node_json_output
node_ingestion -->|"inserts rows"| node_postgres
node_findings_api -->|"queries"| node_web_db
node_findings_api -->|"selects rows"| node_findings_table
node_web_db -->|"connects"| node_postgres
node_health_api -->|"checks connection"| node_web_db
node_health_api -->|"tests query"| node_postgres

click node_pipeline "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/main.py"
click node_checkov "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/checkov_scanner.py"
click node_trivy "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/trivy_scanner.py"
click node_semgrep "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/semgrep_scanner.py"
click node_normalizer "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/normalizer/normalize.py"
click node_finding_model "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/models/finding.py"
click node_ingestion "https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/ingest_findings.py"
click node_web_db "https://github.com/machindra7/trustlens-pipeline/blob/main/src/db/index.ts"
click node_findings_table "https://github.com/machindra7/trustlens-pipeline/blob/main/src/db/schema.ts"
click node_findings_api "https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/api/findings/route.ts"
click node_health_api "https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/api/health/route.ts"
click node_landing "https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/page.tsx"
click node_dashboard "https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/dashboard/page.tsx"

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_pipeline,node_checkov,node_trivy,node_semgrep,node_normalizer,node_finding_model toneBlue
class node_json_output,node_ingestion,node_findings_table,node_postgres toneAmber
class node_web_db,node_findings_api,node_health_api,node_landing,node_dashboard toneMint
class node_operator,node_repository,node_checkov_tool,node_trivy_tool,node_semgrep_tool toneIndigo
```

## Components

### Scanning and normalization

- [CLI pipeline](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/main.py): `trustlens/main.py`
- [Checkov scanner](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/checkov_scanner.py): `trustlens/scanners/checkov_scanner.py`
- [Trivy scanner](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/trivy_scanner.py): `trustlens/scanners/trivy_scanner.py`
- [Semgrep scanner](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/scanners/semgrep_scanner.py): `trustlens/scanners/semgrep_scanner.py`
- [Finding normalizer](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/normalizer/normalize.py): `trustlens/normalizer/normalize.py`
- [Unified finding model](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/models/finding.py): `trustlens/models/finding.py`

### Ingestion and storage

- **Findings JSON**
- [Database ingestion](https://github.com/machindra7/trustlens-pipeline/blob/main/trustlens/ingest_findings.py): `trustlens/ingest_findings.py`
- [Findings table](https://github.com/machindra7/trustlens-pipeline/blob/main/src/db/schema.ts): `src/db/schema.ts`

### Web application

- [Web database client](https://github.com/machindra7/trustlens-pipeline/blob/main/src/db/index.ts): `src/db/index.ts`
- [Findings API](https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/api/findings/route.ts): `src/app/api/findings/route.ts`
- [Health API](https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/api/health/route.ts): `src/app/api/health/route.ts`
- [Landing page](https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Dashboard page](https://github.com/machindra7/trustlens-pipeline/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`

### Other components

- **Operator**
- **Target repository**
- **Checkov**
- **Trivy**
- **Semgrep**
- **PostgreSQL**

## Connections

- Operator → CLI pipeline: runs scan (evidence: `trustlens/main.py`)
- Target repository → CLI pipeline: scan target (evidence: `trustlens/main.py`)
- CLI pipeline → Checkov scanner: calls scan (evidence: `trustlens/main.py`)
- CLI pipeline → Trivy scanner: calls scan (evidence: `trustlens/main.py`)
- CLI pipeline → Semgrep scanner: calls scan (evidence: `trustlens/main.py`)
- Checkov scanner → Checkov: runs (evidence: `trustlens/scanners/checkov_scanner.py`)
- Trivy scanner → Trivy: runs (evidence: `trustlens/scanners/trivy_scanner.py`)
- Semgrep scanner → Semgrep: runs (evidence: `trustlens/scanners/semgrep_scanner.py`)
- Checkov scanner → CLI pipeline: returns findings (evidence: `trustlens/main.py`)
- Trivy scanner → CLI pipeline: returns findings (evidence: `trustlens/main.py`)
- Semgrep scanner → CLI pipeline: returns findings (evidence: `trustlens/main.py`)
- CLI pipeline → Finding normalizer: normalizes results (evidence: `trustlens/main.py`)
- Finding normalizer → Unified finding model: creates findings (evidence: `trustlens/normalizer/normalize.py`)
- CLI pipeline → Findings JSON: writes findings (evidence: `trustlens/main.py`)
- CLI pipeline → Database ingestion: starts upload (evidence: `trustlens/main.py`)
- Database ingestion → Findings JSON: reads findings (evidence: `trustlens/ingest_findings.py`)
- Database ingestion → PostgreSQL: inserts rows (evidence: `trustlens/ingest_findings.py`)
- Findings API → Web database client: queries (evidence: `src/app/api/findings/route.ts`)
- Findings API → Findings table: selects rows (evidence: `src/app/api/findings/route.ts`)
- Web database client → PostgreSQL: connects (evidence: `src/db/index.ts`)
- Health API → Web database client: checks connection (evidence: `src/app/api/health/route.ts`)
- Health API → PostgreSQL: tests query (evidence: `src/app/api/health/route.ts`)
