# danish-2323/triage architecture

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

- Interactive diagram: https://gitdiagram.com/danish-2323/triage
- Repository: https://github.com/danish-2323/triage

## Overview

#### Purpose and entry points
Personalised Vulnerability Triage ranks vulnerability records for a specific organisation rather than globally by CVSS. It supports a Streamlit operator UI in `app.py` and a FastAPI integration endpoint in `api.py` (`POST /triage`). Both drive the same matching, scoring, and explanation pipeline.

#### Data and profile boundary
Bundled operation is offline-first: vulnerability rows come from `data/vulnerabilities.csv`; organisation profiles and their risk weights come from `data/profiles.json`. `src/loader.py` normalizes loading and schema handling. Profiles may provide simple critical-product lists or vendor/product/version technology records, separating organisation context from public vulnerability data.

#### Matching and applicability
`src/matcher.py` determines whether each vulnerability applies to a profile: `include`, `needs_verification`, or `exclude`, retaining reasons rather than silently dropping uncertainty. `src/aliases.py` provides canonical product-name matching. `src/version_match.py` refines matches when installed versions and vulnerability ranges exist; unparseable or incomplete version evidence becomes verification-required instead of a guessed result.

#### Risk ranking
`src/ranker.py` converts applicable records into organisation-specific scores using CVSS, CISA KEV membership, EPSS probability, profile weight modifiers, and optional exposure/importance context. It penalizes uncertain matches and assigns priority bands. `src/compare.py` supports the “negative test”/comparison behavior that demonstrates why high-severity but irrelevant or lower-priority items were not selected.

#### Explainability and presentation
`src/explainer.py` turns ranked records into deterministic, sourced findings: priority, affected context, impact, next action, confidence, score factors, and source-row provenance. `app.py` renders these results and allows custom profiles, CSV replacement, live-data toggling, and optional AI wording. `src/report.py` is the report-oriented output boundary used by presentation/integration flows.

#### Optional external enrichment and AI
`src/live_sources.py` fetches and merges NVD, CISA KEV, and FIRST EPSS public feeds, with rate-limit pacing and a six-hour disk cache; failure falls back to cached or bundled data. `src/llm_phraser.py` is strictly cosmetic: it can restyle already-grounded explanations through Featherless or Groq, selected via API-key environment variables, and falls back to templates on failure.

#### Service, evaluation, and deployment
`api.py` exposes the pipeline as JSON for schedulers, ticketing, or chat integrations; `app.py` is the interactive runtime. `src/evaluate.py` evaluates profile scoring against practitioner rankings in `data/gold_set.csv`. Runtime dependencies are Python, Streamlit, and Uvicorn/FastAPI (`requirements.txt`); container deployment runs UI and API via `Dockerfile` and `docker-compose.yml`, including persisted live-data cache and health checks.

Main entry points: [`src/ranker.py`](https://github.com/danish-2323/triage/blob/main/src/ranker.py) (Organisation Ranker), [`src/loader.py`](https://github.com/danish-2323/triage/blob/main/src/loader.py) (Data Loader), [`src/matcher.py`](https://github.com/danish-2323/triage/blob/main/src/matcher.py) (Applicability Matcher), [`src/report.py`](https://github.com/danish-2323/triage/blob/main/src/report.py) (Report Boundary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Bundled Data"]
  node_vulns[("Vulnerability CSV<br/>vulnerability data")]
  node_profiles[("Organisation Profiles<br/>profile data<br/>[profiles.json]")]
  node_goldset[("Practitioner Gold Set<br/>evaluation data<br/>[gold_set.csv]")]
end

subgraph group_pipeline["Triage Pipeline"]
  node_loader["Data Loader<br/>normalization<br/>[loader.py]"]
  node_aliases["Product Aliases<br/>canonicalization<br/>[aliases.py]"]
  node_versions["Version Matcher<br/>applicability refinement<br/>[version_match.py]"]
  node_matcher["Applicability Matcher<br/>matching<br/>[matcher.py]"]
  node_ranker["Organisation Ranker<br/>risk scoring<br/>[ranker.py]"]
  node_compare["Selection Comparison<br/>negative testing<br/>[compare.py]"]
  node_explainer["Grounded Explainer<br/>finding generation<br/>[explainer.py]"]
  node_report["Report Boundary<br/>output formatting<br/>[report.py]"]
  node_evaluation["Scoring Evaluation<br/>[evaluate.py]"]
end

subgraph group_runtime["Runtimes"]
  node_streamlit["Operator UI<br/>Streamlit app<br/>[app.py]"]
  node_api["Triage API<br/>FastAPI endpoint<br/>[api.py]"]
  node_container{{"Container Deployment"}}
  node_compose["Service Composition<br/>deployment configuration<br/>[docker-compose.yml]"]
end

subgraph group_optional["Optional Enrichment"]
  node_live["Live Public Feeds<br/>external enrichment<br/>[live_sources.py]"]
  node_llm["AI Phraser<br/>cosmetic wording<br/>[llm_phraser.py]"]
end

node_vulns -->|"load"| node_loader
node_profiles -->|"load"| node_loader
node_live -.->|"merge or fallback"| node_loader
node_loader -->|"normalized records and profiles"| node_matcher
node_aliases -->|"canonical names"| node_matcher
node_versions -->|"version evidence"| node_matcher
node_matcher -->|"applicable records and confidence"| node_ranker
node_ranker -->|"ranked candidates"| node_compare
node_ranker -->|"scores and priority bands"| node_explainer
node_compare -->|"non-selection rationale"| node_explainer
node_explainer -->|"grounded findings"| node_report
node_report -->|"render"| node_streamlit
node_report -->|"JSON response"| node_api
node_llm -.->|"optional restyling"| node_streamlit
node_goldset -->|"practitioner rankings"| node_evaluation
node_ranker -->|"scored results"| node_evaluation
node_container -->|"runs"| node_streamlit
node_container -->|"runs"| node_api
node_compose -->|"orchestrates"| node_container

click node_vulns "https://github.com/danish-2323/triage/blob/main/data/vulnerabilities.csv"
click node_profiles "https://github.com/danish-2323/triage/blob/main/data/profiles.json"
click node_goldset "https://github.com/danish-2323/triage/blob/main/data/gold_set.csv"
click node_loader "https://github.com/danish-2323/triage/blob/main/src/loader.py"
click node_aliases "https://github.com/danish-2323/triage/blob/main/src/aliases.py"
click node_versions "https://github.com/danish-2323/triage/blob/main/src/version_match.py"
click node_matcher "https://github.com/danish-2323/triage/blob/main/src/matcher.py"
click node_ranker "https://github.com/danish-2323/triage/blob/main/src/ranker.py"
click node_compare "https://github.com/danish-2323/triage/blob/main/src/compare.py"
click node_explainer "https://github.com/danish-2323/triage/blob/main/src/explainer.py"
click node_report "https://github.com/danish-2323/triage/blob/main/src/report.py"
click node_live "https://github.com/danish-2323/triage/blob/main/src/live_sources.py"
click node_llm "https://github.com/danish-2323/triage/blob/main/src/llm_phraser.py"
click node_streamlit "https://github.com/danish-2323/triage/blob/main/app.py"
click node_api "https://github.com/danish-2323/triage/blob/main/api.py"
click node_evaluation "https://github.com/danish-2323/triage/blob/main/src/evaluate.py"
click node_container "https://github.com/danish-2323/triage/blob/main/Dockerfile"
click node_compose "https://github.com/danish-2323/triage/blob/main/docker-compose.yml"

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_vulns,node_profiles,node_goldset toneBlue
class node_loader,node_aliases,node_versions,node_matcher,node_ranker,node_compare,node_explainer,node_report,node_evaluation toneAmber
class node_streamlit,node_api,node_container,node_compose toneMint
class node_live,node_llm toneRose
```

## Components

### Bundled Data

Offline-first vulnerability and organisation inputs.

- [Vulnerability CSV](https://github.com/danish-2323/triage/blob/main/data/vulnerabilities.csv): vulnerability data · `data/vulnerabilities.csv`
- [Organisation Profiles](https://github.com/danish-2323/triage/blob/main/data/profiles.json): profile data · Risk weights plus product or vendor/product/version context. · `data/profiles.json`
- [Practitioner Gold Set](https://github.com/danish-2323/triage/blob/main/data/gold_set.csv): evaluation data · `data/gold_set.csv`

### Triage Pipeline

Shared matching, ranking, comparison, and explanation flow.

- [Data Loader](https://github.com/danish-2323/triage/blob/main/src/loader.py): normalization · Loads and normalizes data schemas. · `src/loader.py`
- [Product Aliases](https://github.com/danish-2323/triage/blob/main/src/aliases.py): canonicalization · `src/aliases.py`
- [Version Matcher](https://github.com/danish-2323/triage/blob/main/src/version_match.py): applicability refinement · Incomplete or unparseable evidence requires verification. · `src/version_match.py`
- [Applicability Matcher](https://github.com/danish-2323/triage/blob/main/src/matcher.py): matching · Classifies records as include, needs verification, or exclude with reasons. · `src/matcher.py`
- [Organisation Ranker](https://github.com/danish-2323/triage/blob/main/src/ranker.py): risk scoring · Scores applicable records using CVSS, KEV, EPSS, profile weights, and context. · `src/ranker.py`
- [Selection Comparison](https://github.com/danish-2323/triage/blob/main/src/compare.py): negative testing · Explains why relevant alternatives were not selected. · `src/compare.py`
- [Grounded Explainer](https://github.com/danish-2323/triage/blob/main/src/explainer.py): finding generation · Produces deterministic sourced findings and provenance. · `src/explainer.py`
- [Report Boundary](https://github.com/danish-2323/triage/blob/main/src/report.py): output formatting · `src/report.py`
- [Scoring Evaluation](https://github.com/danish-2323/triage/blob/main/src/evaluate.py): evaluation · Compares profile scoring with practitioner rankings. · `src/evaluate.py`

### Runtimes

Interactive and integration entry points.

- [Operator UI](https://github.com/danish-2323/triage/blob/main/app.py): Streamlit app · Supports custom profiles, CSV replacement, live data, and optional AI wording. · `app.py`
- [Triage API](https://github.com/danish-2323/triage/blob/main/api.py): FastAPI endpoint · POST /triage for scheduler, ticketing, and chat integrations. · `api.py`
- [Container Deployment](https://github.com/danish-2323/triage/blob/main/Dockerfile): deployment · Runs UI and API with persisted cache and health checks. · `Dockerfile`
- [Service Composition](https://github.com/danish-2323/triage/blob/main/docker-compose.yml): deployment configuration · `docker-compose.yml`

### Optional Enrichment

Network and cosmetic AI enhancements with safe fallbacks.

- [Live Public Feeds](https://github.com/danish-2323/triage/blob/main/src/live_sources.py): external enrichment · Merges NVD, CISA KEV, and FIRST EPSS with six-hour disk caching. · `src/live_sources.py`
- [AI Phraser](https://github.com/danish-2323/triage/blob/main/src/llm_phraser.py): cosmetic wording · Restyles only grounded explanations; templates remain the fallback. · `src/llm_phraser.py`

## Connections

- Vulnerability CSV → Data Loader: load
- Organisation Profiles → Data Loader: load
- Live Public Feeds → Data Loader: merge or fallback
- Data Loader → Applicability Matcher: normalized records and profiles
- Product Aliases → Applicability Matcher: canonical names
- Version Matcher → Applicability Matcher: version evidence
- Applicability Matcher → Organisation Ranker: applicable records and confidence
- Organisation Ranker → Selection Comparison: ranked candidates
- Organisation Ranker → Grounded Explainer: scores and priority bands
- Selection Comparison → Grounded Explainer: non-selection rationale
- Grounded Explainer → Report Boundary: grounded findings
- Report Boundary → Operator UI: render
- Report Boundary → Triage API: JSON response
- AI Phraser → Operator UI: optional restyling
- Practitioner Gold Set → Scoring Evaluation: practitioner rankings
- Organisation Ranker → Scoring Evaluation: scored results
- Container Deployment → Operator UI: runs
- Container Deployment → Triage API: runs
- Service Composition → Container Deployment: orchestrates
