# chittaranjanp51/govsys architecture

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

- Interactive diagram: https://gitdiagram.com/chittaranjanp51/govsys
- Repository: https://github.com/chittaranjanp51/govsys

## Overview

GovSys is an on-prem AI governance assistant with a Streamlit dashboard and a LangGraph multi-agent request workflow. Staff sign in, submit requests, and receive responses only after governance gates; requests and blocked attempts are audited. The graph preserves the documented identity, policy, model, data, red-team, monitoring, and compliance capabilities. Some subsystem links reflect README documentation or SOURCE INDEX references; unsampled implementation details and dynamic wiring are not inferred.

Main entry points: [`agents/graph.py`](https://github.com/chittaranjanp51/govsys/blob/main/agents/graph.py) (Governed agent graph), [`app/app_pages/monitor.py`](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/monitor.py) (Monitor), [`compliance/report.py`](https://github.com/chittaranjanp51/govsys/blob/main/compliance/report.py) (Compliance report), [`governance/audit.py`](https://github.com/chittaranjanp51/govsys/blob/main/governance/audit.py) (Tamper-evident audit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_shared_ui["Session and sign-in<br/>[common.py]"]
  node_chat_ui["Assistant chat<br/>[chat.py]"]
  node_monitor_ui["Monitor<br/>[monitor.py]"]
  node_models_ui["Model registry UI<br/>[models.py]"]
  node_policies_ui["Policy UI<br/>[policies.py]"]
  node_redteam_ui["Red-team UI<br/>[redteam.py]"]
  node_compliance_ui["Compliance UI<br/>[compliance.py]"]
end

subgraph group_runtime["Governed assistant"]
  node_graph["Governed agent graph<br/>[graph.py]"]
  node_agents["Order, billing, admin agents<br/>[graph.py]"]
  node_agent_tools["Agent database tools<br/>[tools.py]"]
  node_llm["LLM client<br/>[llm.py]"]
end

subgraph group_controls["Governance controls"]
  node_identity["Human and agent identity<br/>[identity.py]"]
  node_checks["Seven-check results<br/>[checks.py]"]
  node_guardrails["Input and output guardrails"]
  node_policy["Authorization policy<br/>[policy.py]"]
  node_model_gate["Model approval gate"]
  node_data_gov["Data access and masking<br/>[data_governance.py]"]
end

subgraph group_evidence["Assurance and reporting"]
  node_audit["Tamper-evident audit<br/>[audit.py]"]
  node_redteam["Adversarial suite<br/>[redteam.py]"]
  node_report["Compliance report<br/>[report.py]"]
end

subgraph group_services["External services and data"]
  node_keycloak["Keycloak IdP"]
  node_opa["OPA policy engine"]
  node_mlflow["MLflow registry"]
  node_postgres[("Postgres")]
  node_ollama["Ollama"]
  node_langfuse["Langfuse tracing"]
end

node_staff(("Staff user"))

node_staff -->|"uses"| node_dashboard
node_dashboard -->|"initializes"| node_shared_ui
node_shared_ui -->|"verifies login"| node_identity
node_chat_ui -->|"submits request"| node_graph
node_graph -->|"authenticates"| node_identity
node_graph -->|"checks input/output"| node_guardrails
node_graph -->|"checks approval"| node_model_gate
node_graph -->|"routes and governs"| node_agents
node_agents -.->|"invokes tools"| node_agent_tools
node_agents -.->|"requests generation"| node_llm
node_graph -->|"authorizes handoffs"| node_policy
node_graph -->|"checks data access"| node_data_gov
node_graph -->|"records outcome"| node_audit
node_identity -.->|"authenticates optionally"| node_keycloak
node_policy -->|"requests decisions"| node_opa
node_model_gate -->|"checks registry"| node_mlflow
node_llm -.->|"serves model"| node_ollama
node_agent_tools -->|"uses connections"| node_data_gov
node_data_gov -->|"reads catalog and data"| node_postgres
node_audit -->|"writes audit rows"| node_postgres
node_audit -.->|"sends traces optionally"| node_langfuse
node_monitor_ui -->|"reads and verifies"| node_audit
node_monitor_ui -->|"checks data health"| node_data_gov
node_monitor_ui -->|"checks identity health"| node_identity
node_monitor_ui -->|"checks registry health"| node_model_gate
node_monitor_ui -->|"checks policy health"| node_policy
node_models_ui -->|"manages approvals"| node_model_gate
node_policies_ui -->|"inspects policy"| node_policy
node_redteam_ui -->|"runs suite"| node_redteam
node_redteam -->|"exercises pipeline"| node_graph
node_redteam -->|"probes permissions"| node_postgres
node_compliance_ui -->|"generates report"| node_report
node_report -->|"verifies audit evidence"| node_audit
node_report -->|"collects registry evidence"| node_model_gate
node_report -->|"collects data evidence"| node_data_gov
node_report -->|"collects run evidence"| node_redteam

click node_dashboard "https://github.com/chittaranjanp51/govsys/blob/main/app/streamlit_app.py"
click node_shared_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/common.py"
click node_chat_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/chat.py"
click node_monitor_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/monitor.py"
click node_models_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/models.py"
click node_policies_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/policies.py"
click node_redteam_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/redteam.py"
click node_compliance_ui "https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/compliance.py"
click node_graph "https://github.com/chittaranjanp51/govsys/blob/main/agents/graph.py"
click node_agents "https://github.com/chittaranjanp51/govsys/blob/main/agents/graph.py"
click node_agent_tools "https://github.com/chittaranjanp51/govsys/blob/main/agents/tools.py"
click node_llm "https://github.com/chittaranjanp51/govsys/blob/main/agents/llm.py"
click node_identity "https://github.com/chittaranjanp51/govsys/blob/main/governance/identity.py"
click node_checks "https://github.com/chittaranjanp51/govsys/blob/main/governance/checks.py"
click node_guardrails "https://github.com/chittaranjanp51/govsys/blob/main/governance/guardrails_layer.py"
click node_policy "https://github.com/chittaranjanp51/govsys/blob/main/governance/policy.py"
click node_model_gate "https://github.com/chittaranjanp51/govsys/blob/main/governance/model_governance.py"
click node_data_gov "https://github.com/chittaranjanp51/govsys/blob/main/governance/data_governance.py"
click node_audit "https://github.com/chittaranjanp51/govsys/blob/main/governance/audit.py"
click node_redteam "https://github.com/chittaranjanp51/govsys/blob/main/governance/redteam.py"
click node_report "https://github.com/chittaranjanp51/govsys/blob/main/compliance/report.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_dashboard,node_shared_ui,node_chat_ui,node_monitor_ui,node_models_ui,node_policies_ui,node_redteam_ui,node_compliance_ui,node_staff toneBlue
class node_graph,node_agents,node_agent_tools,node_llm toneAmber
class node_identity,node_checks,node_guardrails,node_policy,node_model_gate,node_data_gov toneMint
class node_audit,node_redteam,node_report toneRose
class node_keycloak,node_opa,node_mlflow,node_postgres,node_ollama,node_langfuse toneIndigo
```

## Components

### User experience

- [Streamlit dashboard](https://github.com/chittaranjanp51/govsys/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Session and sign-in](https://github.com/chittaranjanp51/govsys/blob/main/app/common.py): `app/common.py`
- [Assistant chat](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/chat.py): `app/app_pages/chat.py`
- [Monitor](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/monitor.py): `app/app_pages/monitor.py`
- [Model registry UI](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/models.py): `app/app_pages/models.py`
- [Policy UI](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/policies.py): `app/app_pages/policies.py`
- [Red-team UI](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/redteam.py): `app/app_pages/redteam.py`
- [Compliance UI](https://github.com/chittaranjanp51/govsys/blob/main/app/app_pages/compliance.py): `app/app_pages/compliance.py`

### Governed assistant

- [Governed agent graph](https://github.com/chittaranjanp51/govsys/blob/main/agents/graph.py): `agents/graph.py`
- [Order, billing, admin agents](https://github.com/chittaranjanp51/govsys/blob/main/agents/graph.py): `agents/graph.py`
- [Agent database tools](https://github.com/chittaranjanp51/govsys/blob/main/agents/tools.py): `agents/tools.py`
- [LLM client](https://github.com/chittaranjanp51/govsys/blob/main/agents/llm.py): `agents/llm.py`

### Governance controls

- [Human and agent identity](https://github.com/chittaranjanp51/govsys/blob/main/governance/identity.py): `governance/identity.py`
- [Seven-check results](https://github.com/chittaranjanp51/govsys/blob/main/governance/checks.py): `governance/checks.py`
- [Input and output guardrails](https://github.com/chittaranjanp51/govsys/blob/main/governance/guardrails_layer.py): `governance/guardrails_layer.py`
- [Authorization policy](https://github.com/chittaranjanp51/govsys/blob/main/governance/policy.py): `governance/policy.py`
- [Model approval gate](https://github.com/chittaranjanp51/govsys/blob/main/governance/model_governance.py): `governance/model_governance.py`
- [Data access and masking](https://github.com/chittaranjanp51/govsys/blob/main/governance/data_governance.py): `governance/data_governance.py`

### Assurance and reporting

- [Tamper-evident audit](https://github.com/chittaranjanp51/govsys/blob/main/governance/audit.py): `governance/audit.py`
- [Adversarial suite](https://github.com/chittaranjanp51/govsys/blob/main/governance/redteam.py): `governance/redteam.py`
- [Compliance report](https://github.com/chittaranjanp51/govsys/blob/main/compliance/report.py): `compliance/report.py`

### External services and data

- **Keycloak IdP**
- **OPA policy engine**
- **MLflow registry**
- **Postgres**
- **Ollama**
- **Langfuse tracing**

### Other components

- **Staff user**

## Connections

- Staff user → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Session and sign-in: initializes (evidence: `app/streamlit_app.py`)
- Session and sign-in → Human and agent identity: verifies login (evidence: `app/common.py`)
- Assistant chat → Governed agent graph: submits request (evidence: `app/app_pages/chat.py`)
- Governed agent graph → Human and agent identity: authenticates (evidence: `agents/graph.py`)
- Governed agent graph → Input and output guardrails: checks input/output (evidence: `agents/graph.py`)
- Governed agent graph → Model approval gate: checks approval (evidence: `agents/graph.py`)
- Governed agent graph → Order, billing, admin agents: routes and governs (evidence: `README.md`)
- Order, billing, admin agents → Agent database tools: invokes tools (evidence: `agents/graph.py`)
- Order, billing, admin agents → LLM client: requests generation (evidence: `agents/graph.py`)
- Governed agent graph → Authorization policy: authorizes handoffs (evidence: `agents/graph.py`)
- Governed agent graph → Data access and masking: checks data access (evidence: `agents/graph.py`)
- Governed agent graph → Tamper-evident audit: records outcome (evidence: `README.md`)
- Human and agent identity → Keycloak IdP: authenticates optionally (evidence: `governance/identity.py`)
- Authorization policy → OPA policy engine: requests decisions (evidence: `governance/policy.py`)
- Model approval gate → MLflow registry: checks registry (evidence: `governance/model_governance.py`)
- LLM client → Ollama: serves model (evidence: `README.md`)
- Agent database tools → Data access and masking: uses connections (evidence: `agents/tools.py`)
- Data access and masking → Postgres: reads catalog and data (evidence: `governance/data_governance.py`)
- Tamper-evident audit → Postgres: writes audit rows (evidence: `governance/audit.py`)
- Tamper-evident audit → Langfuse tracing: sends traces optionally (evidence: `governance/audit.py`)
- Monitor → Tamper-evident audit: reads and verifies (evidence: `app/app_pages/monitor.py`)
- Monitor → Data access and masking: checks data health (evidence: `app/app_pages/monitor.py`)
- Monitor → Human and agent identity: checks identity health (evidence: `app/app_pages/monitor.py`)
- Monitor → Model approval gate: checks registry health (evidence: `app/app_pages/monitor.py`)
- Monitor → Authorization policy: checks policy health (evidence: `app/app_pages/monitor.py`)
- Model registry UI → Model approval gate: manages approvals (evidence: `app/app_pages/models.py`)
- Policy UI → Authorization policy: inspects policy (evidence: `app/app_pages/policies.py`)
- Red-team UI → Adversarial suite: runs suite (evidence: `app/app_pages/redteam.py`)
- Adversarial suite → Governed agent graph: exercises pipeline (evidence: `governance/redteam.py`)
- Adversarial suite → Postgres: probes permissions (evidence: `governance/redteam.py`)
- Compliance UI → Compliance report: generates report (evidence: `app/app_pages/compliance.py`)
- Compliance report → Tamper-evident audit: verifies audit evidence (evidence: `compliance/report.py`)
- Compliance report → Model approval gate: collects registry evidence (evidence: `compliance/report.py`)
- Compliance report → Data access and masking: collects data evidence (evidence: `compliance/report.py`)
- Compliance report → Adversarial suite: collects run evidence (evidence: `compliance/report.py`)
