# deeptensor-3070/hr-policy-bot architecture

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

- Interactive diagram: https://gitdiagram.com/deeptensor-3070/hr-policy-bot
- Repository: https://github.com/deeptensor-3070/hr-policy-bot

## Overview

This is a Streamlit HR policy assistant. Users configure Groq models and a key, ask a question in the chat tab, and receive either a guardrail response or an answer grounded in retrieved policy excerpts; the chat also displays sources and execution diagnostics. A separate tab browses the policy corpus. The pipeline’s orchestration and safety branches are visible in the sampled source; model-provider behavior is represented at the API boundary.

Main entry points: [`app.py`](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/app.py) (App entry), [`src/pipeline.py`](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/pipeline.py) (Request pipeline), [`src/rag.py`](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/rag.py) (Policy retrieval), [`src/ui/tab_chat.py`](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/tab_chat.py) (Chat tab)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Streamlit interface"]
  node_app["App entry<br/>[app.py]"]
  node_sidebar["Model settings<br/>[sidebar.py]"]
  node_landing["Landing page<br/>[landing.py]"]
  node_chat["Chat tab<br/>[tab_chat.py]"]
  node_browser["Policy browser<br/>[tab_docs.py]"]
end

subgraph group_workflow["Answer workflow"]
  node_pipeline["Request pipeline<br/>[pipeline.py]"]
end

subgraph group_knowledge["Policy knowledge"]
  node_retrieval["Policy retrieval<br/>[rag.py]"]
  node_index[("FAISS index<br/>[rag.py]")]
  node_policies["HR policy corpus<br/>[hr_docs.py]"]
end

subgraph group_safety["Safety and configuration"]
  node_guardrails["NeMo rails<br/>[guards.py]"]
  node_pii["PII action<br/>[guards.py]"]
  node_promptchecks["Prompt and output rules<br/>[config.py]"]
end

node_employee(("Employee"))
node_groq["Groq API"]

node_employee -->|"uses"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"renders"| node_landing
node_app -->|"renders"| node_chat
node_app -->|"renders"| node_browser
node_app -->|"builds index"| node_retrieval
node_chat -->|"submits question"| node_pipeline
node_pipeline -->|"returns answer and trace"| node_chat
node_pipeline -->|"runs safety check"| node_guardrails
node_pipeline -->|"retrieves excerpts"| node_retrieval
node_pipeline -->|"uses prompt and patterns"| node_promptchecks
node_pipeline -->|"calls models"| node_groq
node_guardrails -->|"registers action"| node_pii
node_retrieval -->|"chunks documents"| node_policies
node_retrieval -->|"builds and searches"| node_index
node_browser -->|"displays documents"| node_policies

click node_app "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/app.py"
click node_sidebar "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/sidebar.py"
click node_landing "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/landing.py"
click node_chat "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/tab_chat.py"
click node_browser "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/tab_docs.py"
click node_pipeline "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/pipeline.py"
click node_guardrails "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/guards.py"
click node_pii "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/guards.py"
click node_promptchecks "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/config.py"
click node_retrieval "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/rag.py"
click node_index "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/rag.py"
click node_policies "https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/hr_docs.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_app,node_sidebar,node_landing,node_chat,node_browser toneBlue
class node_pipeline toneAmber
class node_retrieval,node_index,node_policies,node_groq toneMint
class node_guardrails,node_pii,node_promptchecks toneRose
class node_employee toneIndigo
```

## Components

### Streamlit interface

- [App entry](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/app.py): `app.py`
- [Model settings](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/sidebar.py): `src/ui/sidebar.py`
- [Landing page](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/landing.py): `src/ui/landing.py`
- [Chat tab](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/tab_chat.py): `src/ui/tab_chat.py`
- [Policy browser](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/ui/tab_docs.py): `src/ui/tab_docs.py`

### Answer workflow

- [Request pipeline](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/pipeline.py): `src/pipeline.py`

### Policy knowledge

- [Policy retrieval](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/rag.py): `src/rag.py`
- [FAISS index](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/rag.py): `src/rag.py`
- [HR policy corpus](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/hr_docs.py): `src/hr_docs.py`

### Safety and configuration

- [NeMo rails](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/guards.py): `src/guards.py`
- [PII action](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/guards.py): `src/guards.py`
- [Prompt and output rules](https://github.com/deeptensor-3070/hr-policy-bot/blob/main/src/config.py): `src/config.py`

### Other components

- **Employee**
- **Groq API**

## Connections

- Employee → App entry: uses (evidence: `README.md`)
- App entry → Model settings: renders (evidence: `app.py`)
- App entry → Landing page: renders (evidence: `app.py`)
- App entry → Chat tab: renders (evidence: `app.py`)
- App entry → Policy browser: renders (evidence: `app.py`)
- App entry → Policy retrieval: builds index (evidence: `app.py`)
- Chat tab → Request pipeline: submits question (evidence: `src/ui/tab_chat.py`)
- Request pipeline → Chat tab: returns answer and trace (evidence: `src/ui/tab_chat.py`)
- Request pipeline → NeMo rails: runs safety check (evidence: `src/pipeline.py`)
- Request pipeline → Policy retrieval: retrieves excerpts (evidence: `src/pipeline.py`)
- Request pipeline → Prompt and output rules: uses prompt and patterns (evidence: `src/pipeline.py`)
- Request pipeline → Groq API: calls models (evidence: `src/pipeline.py`)
- NeMo rails → PII action: registers action (evidence: `src/guards.py`)
- Policy retrieval → HR policy corpus: chunks documents (evidence: `src/rag.py`)
- Policy retrieval → FAISS index: builds and searches (evidence: `src/rag.py`)
- Policy browser → HR policy corpus: displays documents (evidence: `src/ui/tab_docs.py`)
