# tejaswini4119/ndra-pii architecture

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

- Interactive diagram: https://gitdiagram.com/tejaswini4119/ndra-pii
- Repository: https://github.com/tejaswini4119/ndra-pii

## Overview

NDRA-PII accepts documents through its API or interactive CLI, then extracts text, detects PII, fuses overlapping detections, applies governance policy, and redacts according to the resulting action. The API is the packaged server entrypoint; the CLI also has a direct-agent workflow. Audit and shared schemas support the processing stages. The tree also contains a v2 orchestration shell and RFC email parser, shown as internal components; available excerpts do not establish their runtime wiring to the primary flow. Relationships for the main pipeline follow README documentation, supplemented by shown CLI calls.

Main entry points: [`ndrapiicli.py`](https://github.com/tejaswini4119/ndra-pii/blob/main/ndrapiicli.py) (Interactive CLI), [`agents/extractor.py`](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/extractor.py) (Document Extraction), [`agents/classifier.py`](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/classifier.py) (PII Classification), [`agents/fusion_agent.py`](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/fusion_agent.py) (Entity Fusion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Entry"]
  node_api["Packaged API<br/>[api.py]"]
  node_server["API Server<br/>[main.py]"]
  node_cli["Interactive CLI<br/>[ndrapiicli.py]"]
end

subgraph group_processing["PII Processing"]
  node_extractor["Document Extraction<br/>[extractor.py]"]
  node_classifier["PII Classification<br/>[classifier.py]"]
  node_fusion["Entity Fusion<br/>[fusion_agent.py]"]
end

subgraph group_governance["Governance &amp; Output"]
  node_policy["Policy Evaluation<br/>[policy_agent.py]"]
  node_redaction["PII Redaction<br/>[redaction_agent.py]"]
  node_audit["Audit Trail<br/>[audit.py]"]
  node_result["Sanitized Document"]
end

subgraph group_runtime["Runtime Support"]
  node_models["Shared Data Models<br/>[core_models.py]"]
  node_settings["Runtime Settings<br/>[settings.py]"]
  node_v2pipeline["V2 Orchestrator<br/>[pipeline.py]"]
  node_emailparser["RFC Email Parser"]
end

node_user(("Document User"))

node_user -->|"uploads document"| node_api
node_user -->|"selects document"| node_cli
node_api -->|"delegates to"| node_server
node_server -->|"starts processing"| node_extractor
node_extractor -->|"passes chunks"| node_classifier
node_classifier -->|"passes detections"| node_fusion
node_fusion -->|"passes entities"| node_policy
node_policy -->|"passes actions"| node_redaction
node_redaction -->|"produces sanitized output"| node_result
node_cli -->|"calls extraction"| node_extractor
node_cli -->|"calls classification"| node_classifier
node_cli -->|"calls fusion"| node_fusion
node_cli -->|"calls evaluation"| node_policy
node_cli -->|"calls redaction"| node_redaction
node_extractor -->|"reads controls"| node_settings
node_classifier -->|"creates typed results"| node_models
node_fusion -->|"uses entity schemas"| node_models
node_policy -->|"uses decision schemas"| node_models
node_redaction -->|"uses governed chunks"| node_models

click node_api "https://github.com/tejaswini4119/ndra-pii/blob/main/ndra_stack/api.py"
click node_server "https://github.com/tejaswini4119/ndra-pii/blob/main/main.py"
click node_cli "https://github.com/tejaswini4119/ndra-pii/blob/main/ndrapiicli.py"
click node_extractor "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/extractor.py"
click node_classifier "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/classifier.py"
click node_fusion "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/fusion_agent.py"
click node_policy "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/policy_agent.py"
click node_redaction "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/redaction_agent.py"
click node_audit "https://github.com/tejaswini4119/ndra-pii/blob/main/agents/audit.py"
click node_models "https://github.com/tejaswini4119/ndra-pii/blob/main/schemas/core_models.py"
click node_settings "https://github.com/tejaswini4119/ndra-pii/blob/main/config/settings.py"
click node_v2pipeline "https://github.com/tejaswini4119/ndra-pii/blob/main/core/v2/pipeline.py"
click node_emailparser "https://github.com/tejaswini4119/ndra-pii/blob/main/core/v2/parsers/rfc_email_parser.py"

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_api,node_server,node_cli,node_user toneBlue
class node_extractor,node_classifier,node_fusion toneAmber
class node_policy,node_redaction,node_audit,node_result toneMint
class node_models,node_settings,node_v2pipeline,node_emailparser toneRose
```

## Components

### User Entry

- [Packaged API](https://github.com/tejaswini4119/ndra-pii/blob/main/ndra_stack/api.py): `ndra_stack/api.py`
- [API Server](https://github.com/tejaswini4119/ndra-pii/blob/main/main.py): `main.py`
- [Interactive CLI](https://github.com/tejaswini4119/ndra-pii/blob/main/ndrapiicli.py): `ndrapiicli.py`

### PII Processing

- [Document Extraction](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/extractor.py): `agents/extractor.py`
- [PII Classification](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/classifier.py): `agents/classifier.py`
- [Entity Fusion](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/fusion_agent.py): `agents/fusion_agent.py`

### Governance & Output

- [Policy Evaluation](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/policy_agent.py): `agents/policy_agent.py`
- [PII Redaction](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/redaction_agent.py): `agents/redaction_agent.py`
- [Audit Trail](https://github.com/tejaswini4119/ndra-pii/blob/main/agents/audit.py): `agents/audit.py`
- **Sanitized Document**

### Runtime Support

- [Shared Data Models](https://github.com/tejaswini4119/ndra-pii/blob/main/schemas/core_models.py): `schemas/core_models.py`
- [Runtime Settings](https://github.com/tejaswini4119/ndra-pii/blob/main/config/settings.py): `config/settings.py`
- [V2 Orchestrator](https://github.com/tejaswini4119/ndra-pii/blob/main/core/v2/pipeline.py): `core/v2/pipeline.py`
- [RFC Email Parser](https://github.com/tejaswini4119/ndra-pii/blob/main/core/v2/parsers/rfc_email_parser.py): `core/v2/parsers/rfc_email_parser.py`

### Other components

- **Document User**

## Connections

- Document User → Packaged API: uploads document (evidence: `README.md`)
- Document User → Interactive CLI: selects document (evidence: `README.md`)
- Packaged API → API Server: delegates to (evidence: `ndra_stack/api.py`)
- API Server → Document Extraction: starts processing (evidence: `README.md`)
- Document Extraction → PII Classification: passes chunks (evidence: `README.md`)
- PII Classification → Entity Fusion: passes detections (evidence: `README.md`)
- Entity Fusion → Policy Evaluation: passes entities (evidence: `README.md`)
- Policy Evaluation → PII Redaction: passes actions (evidence: `README.md`)
- PII Redaction → Sanitized Document: produces sanitized output (evidence: `README.md`)
- Interactive CLI → Document Extraction: calls extraction (evidence: `ndrapiicli.py`)
- Interactive CLI → PII Classification: calls classification (evidence: `ndrapiicli.py`)
- Interactive CLI → Entity Fusion: calls fusion (evidence: `ndrapiicli.py`)
- Interactive CLI → Policy Evaluation: calls evaluation (evidence: `ndrapiicli.py`)
- Interactive CLI → PII Redaction: calls redaction (evidence: `ndrapiicli.py`)
- Document Extraction → Runtime Settings: reads controls (evidence: `agents/extractor.py`)
- PII Classification → Shared Data Models: creates typed results (evidence: `agents/classifier.py`)
- Entity Fusion → Shared Data Models: uses entity schemas (evidence: `agents/fusion_agent.py`)
- Policy Evaluation → Shared Data Models: uses decision schemas (evidence: `agents/policy_agent.py`)
- PII Redaction → Shared Data Models: uses governed chunks (evidence: `agents/redaction_agent.py`)
