# suvajit324/policy-pilot architecture

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

- Interactive diagram: https://gitdiagram.com/suvajit324/policy-pilot
- Repository: https://github.com/suvajit324/policy-pilot

## Overview

PolicyPilot is an HR-policy assistant: employees ask questions through a chat UI and receive a guarded, intent-specific answer. The README describes retrieval followed by intent detection and curated responses; the sampled app code also shows an optional OpenAI answer path, feedback and usage statistics, and serving the frontend. The retrieval details and most intermediate implementation are documented but not present in the excerpts, so those links cite the README rather than implying they were verified in source.

Main entry points: [`app.py`](https://github.com/suvajit324/policy-pilot/blob/main/app.py) (Question API), [`index.html`](https://github.com/suvajit324/policy-pilot/blob/main/index.html) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Employee experience"]
  node_chat_ui["Chat interface<br/>[index.html]"]
end

subgraph group_answering["Policy answering"]
  node_ask_api["Question API<br/>[app.py]"]
  node_safety["Query guardrails<br/>[app.py]"]
  node_retrieval["TF-IDF retrieval<br/>[app.py]"]
  node_intent["Intent detection<br/>[app.py]"]
  node_policy_answers["Curated HR answers<br/>[app.py]"]
end

subgraph group_operations["Usage and feedback"]
  node_feedback_api["Feedback API<br/>[app.py]"]
  node_stats_api["Stats and traction<br/>[app.py]"]
end

node_employee(("Employee"))
node_openai["OpenAI service"]

node_employee -->|"asks through"| node_chat_ui
node_chat_ui -.->|"submits question"| node_ask_api
node_ask_api -->|"checks query"| node_safety
node_safety -->|"passes query"| node_retrieval
node_retrieval -->|"informs intent"| node_intent
node_intent -->|"selects answer"| node_policy_answers
node_ask_api -->|"requests answer"| node_openai
node_employee -.->|"submits feedback"| node_feedback_api
node_employee -.->|"views dashboard"| node_stats_api

click node_chat_ui "https://github.com/suvajit324/policy-pilot/blob/main/index.html"
click node_ask_api "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_safety "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_retrieval "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_intent "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_policy_answers "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_feedback_api "https://github.com/suvajit324/policy-pilot/blob/main/app.py"
click node_stats_api "https://github.com/suvajit324/policy-pilot/blob/main/app.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_chat_ui toneBlue
class node_ask_api,node_safety,node_retrieval,node_intent,node_policy_answers toneAmber
class node_feedback_api,node_stats_api toneMint
class node_employee,node_openai toneIndigo
```

## Components

### Employee experience

- [Chat interface](https://github.com/suvajit324/policy-pilot/blob/main/index.html): `index.html`

### Policy answering

- [Question API](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`
- [Query guardrails](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`
- [TF-IDF retrieval](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`
- [Intent detection](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`
- [Curated HR answers](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`

### Usage and feedback

- [Feedback API](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`
- [Stats and traction](https://github.com/suvajit324/policy-pilot/blob/main/app.py): `app.py`

### Other components

- **Employee**
- **OpenAI service**

## Connections

- Employee → Chat interface: asks through (evidence: `README.md`)
- Chat interface → Question API: submits question
- Question API → Query guardrails: checks query (evidence: `README.md`)
- Query guardrails → TF-IDF retrieval: passes query (evidence: `README.md`)
- TF-IDF retrieval → Intent detection: informs intent (evidence: `README.md`)
- Intent detection → Curated HR answers: selects answer (evidence: `README.md`)
- Question API → OpenAI service: requests answer (evidence: `app.py`)
- Employee → Feedback API: submits feedback
- Employee → Stats and traction: views dashboard
