# aasrithadevireddy/privacy-budget-autopilot-for-company-copilot architecture

> Architecture diagram of the GitHub repository aasrithadevireddy/privacy-budget-autopilot-for-company-copilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot
- Repository: https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot

## Overview

Privacy Budget Autopilot is an employee-facing company assistant with role-filtered document answers, coding help, privacy-budget enforcement, and administrator oversight. Employees activate or log in through the web UI, submit a chat request, and receive an answer or a refusal/escalation; chat decisions also update persistent budget and audit records. The repository additionally includes synthetic-data generation and a PPO training/evaluation path whose model recommendations remain subject to backend policy checks. Source excerpts do not expose all API internals, so unsampled subsystem links are included only where documented.

Main entry points: [`backend/app/main.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py) (Assistant API), [`backend/app/db.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/db.py) (Application database), [`backend/app/seed.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/seed.py) (Synthetic data seeding), [`backend/app/security.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/security.py) (Identity and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Employee experience"]
  node_webapp["Web application<br/>[App.tsx]"]
end

subgraph group_service["Assistant service"]
  node_api["Assistant API<br/>[main.py]"]
  node_retrieval["Authorized retrieval<br/>[main.py]"]
  node_answering["Answer generation<br/>[main.py]"]
end

subgraph group_governance["Privacy governance"]
  node_identity["Identity and sessions<br/>[security.py]"]
  node_policy["Policy enforcement<br/>[policy.py]"]
  node_ppo["PPO inference<br/>[ppo.py]"]
  node_budget_audit["Budget and audit<br/>[main.py]"]
end

subgraph group_data["Data and learning"]
  node_orm["Domain records<br/>[models.py]"]
  node_database[("Application database<br/>[db.py]")]
  node_seeding["Synthetic data seeding<br/>[seed.py]"]
  node_employee_exports["Employee exports<br/>[employees.csv]"]
  node_knowledge_export["Knowledge export"]
  node_training["PPO training<br/>[train.py]"]
  node_checkpoint["PPO checkpoint<br/>[privacy_ppo.pt]"]
end

node_employee(("Employee"))
node_llm["OpenAI provider"]

node_employee -->|"uses"| node_webapp
node_webapp -->|"calls API"| node_api
node_api -->|"authenticates"| node_identity
node_api -->|"routes requests"| node_retrieval
node_api -->|"handles chat"| node_answering
node_retrieval -->|"reads authorized docs"| node_database
node_answering -.->|"optionally calls"| node_llm
node_api -->|"checks decisions"| node_policy
node_api -->|"gets recommendation"| node_ppo
node_api -->|"records outcome"| node_budget_audit
node_budget_audit -->|"writes transactions"| node_database
node_identity -->|"reads sessions"| node_database
node_identity -->|"uses employee records"| node_orm
node_orm -->|"maps records"| node_database
node_seeding -->|"populates records"| node_database
node_seeding -->|"exports registry"| node_employee_exports
node_seeding -.->|"exports documents"| node_knowledge_export
node_training -->|"writes checkpoint"| node_checkpoint
node_ppo -->|"loads model"| node_checkpoint

click node_webapp "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/frontend/src/App.tsx"
click node_api "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py"
click node_identity "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/security.py"
click node_retrieval "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py"
click node_answering "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py"
click node_policy "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/policy.py"
click node_ppo "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/ppo.py"
click node_budget_audit "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py"
click node_orm "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/models.py"
click node_database "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/db.py"
click node_seeding "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/seed.py"
click node_employee_exports "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/data/employees/employees.csv"
click node_knowledge_export "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/data/generated/company_knowledge_base.csv"
click node_training "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/train.py"
click node_checkpoint "https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/models/privacy_ppo.pt"

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_webapp toneBlue
class node_api,node_retrieval,node_answering toneAmber
class node_identity,node_policy,node_ppo,node_budget_audit toneMint
class node_orm,node_database,node_seeding,node_employee_exports,node_knowledge_export,node_training,node_checkpoint toneRose
class node_employee,node_llm toneIndigo
```

## Components

### Employee experience

- [Web application](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### Assistant service

- [Assistant API](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authorized retrieval](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Answer generation](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py): `backend/app/main.py`

### Privacy governance

- [Identity and sessions](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/security.py): `backend/app/security.py`
- [Policy enforcement](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/policy.py): `backend/app/policy.py`
- [PPO inference](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/ppo.py): `backend/app/ppo.py`
- [Budget and audit](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/main.py): `backend/app/main.py`

### Data and learning

- [Domain records](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/models.py): `backend/app/models.py`
- [Application database](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/db.py): `backend/app/db.py`
- [Synthetic data seeding](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/seed.py): `backend/app/seed.py`
- [Employee exports](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/data/employees/employees.csv): `data/employees/employees.csv`
- [Knowledge export](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/data/generated/company_knowledge_base.csv): `data/generated/company_knowledge_base.csv`
- [PPO training](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/backend/app/train.py): `backend/app/train.py`
- [PPO checkpoint](https://github.com/aasrithadevireddy/privacy-budget-autopilot-for-company-copilot/blob/main/models/privacy_ppo.pt): `models/privacy_ppo.pt`

### Other components

- **Employee**
- **OpenAI provider**

## Connections

- Employee → Web application: uses (evidence: `README.md`)
- Web application → Assistant API: calls API (evidence: `frontend/src/App.tsx`)
- Assistant API → Identity and sessions: authenticates (evidence: `backend/app/main.py`)
- Assistant API → Authorized retrieval: routes requests (evidence: `README.md`)
- Assistant API → Answer generation: handles chat (evidence: `README.md`)
- Authorized retrieval → Application database: reads authorized docs (evidence: `README.md`)
- Answer generation → OpenAI provider: optionally calls (evidence: `README.md`)
- Assistant API → Policy enforcement: checks decisions (evidence: `backend/app/main.py`)
- Assistant API → PPO inference: gets recommendation (evidence: `backend/app/main.py`)
- Assistant API → Budget and audit: records outcome (evidence: `backend/app/main.py`)
- Budget and audit → Application database: writes transactions (evidence: `backend/app/main.py`)
- Identity and sessions → Application database: reads sessions (evidence: `backend/app/security.py`)
- Identity and sessions → Domain records: uses employee records (evidence: `backend/app/security.py`)
- Domain records → Application database: maps records (evidence: `backend/app/models.py`)
- Synthetic data seeding → Application database: populates records (evidence: `backend/app/seed.py`)
- Synthetic data seeding → Employee exports: exports registry (evidence: `backend/app/seed.py`)
- Synthetic data seeding → Knowledge export: exports documents (evidence: `README.md`)
- PPO training → PPO checkpoint: writes checkpoint (evidence: `README.md`)
- PPO inference → PPO checkpoint: loads model (evidence: `backend/app/ppo.py`)
