# aasrithadevireddy/privacy-budget-autopilot-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/aasrithadevireddy/privacy-budget-autopilot-v2
- Repository: https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2

## Overview

Company GPT is an enterprise AI copilot. A browser request reaches FastAPI and the chat service, which classifies the task, optionally retrieves role- and project-filtered knowledge, applies privacy controls, selects an OpenAI or local response, and records conversation/audit state. Separate capabilities include project-ingestable TF-IDF RAG, code/SQL task handling, feedback, history, and budget inspection. Edges reflect the excerpts and README; unsampled frontend/API wiring and training behavior are not inferred beyond documented capabilities.

Main entry points: [`backend/service.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/service.py) (Chat orchestrator), [`backend/database.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/database.py) (Conversation and audit store), [`backend/app.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/app.py) (FastAPI endpoints), [`backend/rag.py`](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/rag.py) (Project-filtered TF-IDF RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_browser["Browser client<br/>[app.js]"]
end

subgraph group_api["API and orchestration"]
  node_web["FastAPI endpoints<br/>[app.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_chat["Chat orchestrator<br/>[service.py]"]
  node_analyzer["Task and language analysis"]
  node_taskpolicy["Task strategy policy<br/>[task_policy.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_knowledge["Knowledge and policy"]
  node_rag["Project-filtered TF-IDF RAG<br/>[rag.py]"]
  node_kb["Project knowledge documents"]
  node_rbac["Role authorization<br/>[rbac.py]"]
  node_privacy["Privacy budget policy<br/>[privacy.py]"]
end

subgraph group_answers["Answer generation"]
  node_llm["OpenAI generation<br/>[llm.py]"]
  node_solver["Deterministic task solver<br/>[task_solver.py]"]
end

subgraph group_state["Persistent state"]
  node_db[("Conversation and audit store<br/>[database.py]")]
  node_sqlite[("SQLite database")]
end

node_user(("Copilot user"))
node_openai(("OpenAI service"))

node_user -->|"sends request"| node_browser
node_browser -.->|"calls API"| node_web
node_web -->|"validates chat"| node_schemas
node_web -->|"dispatches chat"| node_chat
node_chat -->|"analyzes request"| node_analyzer
node_chat -->|"chooses strategy"| node_taskpolicy
node_chat -->|"retrieves context"| node_rag
node_rag -->|"indexes and searches"| node_kb
node_rag -->|"checks document access"| node_rbac
node_chat -->|"gets role level"| node_rbac
node_chat -->|"decides disclosure"| node_privacy
node_chat -->|"requests generation"| node_llm
node_chat -->|"uses local fallback"| node_solver
node_llm -.->|"generates response"| node_openai
node_chat -->|"reads and records history"| node_db
node_privacy -->|"reads and updates budget"| node_db
node_web -->|"records feedback and reads audits"| node_db
node_db -->|"persists records"| node_sqlite
node_rag -->|"loads paths"| node_config
node_db -->|"loads database path"| node_config
node_llm -->|"loads model settings"| node_config
node_privacy -->|"loads budget settings"| node_config

click node_browser "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/frontend/app.js"
click node_web "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/app.py"
click node_schemas "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/schemas.py"
click node_chat "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/service.py"
click node_analyzer "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/request_analyzer.py"
click node_taskpolicy "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/task_policy.py"
click node_rag "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/rag.py"
click node_kb "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/tree/main/knowledge_base"
click node_rbac "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/rbac.py"
click node_privacy "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/privacy.py"
click node_llm "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/llm.py"
click node_solver "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/task_solver.py"
click node_config "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/config.py"
click node_db "https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/database.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_browser,node_user toneBlue
class node_web,node_schemas,node_chat,node_analyzer,node_taskpolicy,node_config toneAmber
class node_rag,node_kb,node_rbac,node_privacy toneMint
class node_llm,node_solver toneRose
class node_db,node_sqlite,node_openai toneIndigo
```

## Components

### User interface

- [Browser client](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/frontend/app.js): `frontend/app.js`

### API and orchestration

- [FastAPI endpoints](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/app.py): `backend/app.py`
- [Request schemas](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/schemas.py): `backend/schemas.py`
- [Chat orchestrator](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/service.py): `backend/service.py`
- [Task and language analysis](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/request_analyzer.py): `backend/request_analyzer.py`
- [Task strategy policy](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/task_policy.py): `backend/task_policy.py`
- [Runtime configuration](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/config.py): `backend/config.py`

### Knowledge and policy

- [Project-filtered TF-IDF RAG](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/rag.py): `backend/rag.py`
- [Project knowledge documents](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/tree/main/knowledge_base): `knowledge_base`
- [Role authorization](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/rbac.py): `backend/rbac.py`
- [Privacy budget policy](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/privacy.py): `backend/privacy.py`

### Answer generation

- [OpenAI generation](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/llm.py): `backend/llm.py`
- [Deterministic task solver](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/task_solver.py): `backend/task_solver.py`

### Persistent state

- [Conversation and audit store](https://github.com/aasrithadevireddy/privacy-budget-autopilot-v2/blob/main/backend/database.py): `backend/database.py`
- **SQLite database**

### Other components

- **Copilot user**
- **OpenAI service**

## Connections

- Copilot user → Browser client: sends request (evidence: `README.md`)
- Browser client → FastAPI endpoints: calls API
- FastAPI endpoints → Request schemas: validates chat (evidence: `backend/app.py`)
- FastAPI endpoints → Chat orchestrator: dispatches chat (evidence: `backend/app.py`)
- Chat orchestrator → Task and language analysis: analyzes request (evidence: `backend/service.py`)
- Chat orchestrator → Task strategy policy: chooses strategy (evidence: `backend/service.py`)
- Chat orchestrator → Project-filtered TF-IDF RAG: retrieves context (evidence: `backend/service.py`)
- Project-filtered TF-IDF RAG → Project knowledge documents: indexes and searches (evidence: `backend/rag.py`)
- Project-filtered TF-IDF RAG → Role authorization: checks document access (evidence: `backend/rag.py`)
- Chat orchestrator → Role authorization: gets role level (evidence: `backend/service.py`)
- Chat orchestrator → Privacy budget policy: decides disclosure (evidence: `backend/service.py`)
- Chat orchestrator → OpenAI generation: requests generation (evidence: `backend/service.py`)
- Chat orchestrator → Deterministic task solver: uses local fallback (evidence: `backend/service.py`)
- OpenAI generation → OpenAI service: generates response (evidence: `README.md`)
- Chat orchestrator → Conversation and audit store: reads and records history (evidence: `backend/service.py`)
- Privacy budget policy → Conversation and audit store: reads and updates budget (evidence: `backend/privacy.py`)
- FastAPI endpoints → Conversation and audit store: records feedback and reads audits (evidence: `backend/app.py`)
- Conversation and audit store → SQLite database: persists records (evidence: `backend/database.py`)
- Project-filtered TF-IDF RAG → Runtime configuration: loads paths (evidence: `backend/rag.py`)
- Conversation and audit store → Runtime configuration: loads database path (evidence: `backend/database.py`)
- OpenAI generation → Runtime configuration: loads model settings (evidence: `backend/llm.py`)
- Privacy budget policy → Runtime configuration: loads budget settings (evidence: `backend/privacy.py`)
