# antxnyxsajan/ai-powered-information-security-policy-advisor architecture

> Architecture diagram of the GitHub repository antxnyxsajan/ai-powered-information-security-policy-advisor, 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/antxnyxsajan/ai-powered-information-security-policy-advisor
- Repository: https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor

## Overview

This repository implements an AI Security Advisor: employees ask policy questions in a React chat, the FastAPI service refines the query, searches company policies first and standards as a fallback, then returns a grounded answer. Separate scripts prepare and index the two document collections and maintain Pinecone metadata; another script evaluates RAG answers against a question set. The main chat flow is visible in excerpts, but some backend setup and internal calls were omitted, so uncertain relationships are not asserted.

Main entry points: [`backend/main.py`](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py) (Chat API), [`backend/indextext_company.py`](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_company.py) (Company indexing), [`backend/indextext_standards.py`](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_standards.py) (Standards indexing), [`frontend/chatbot-frontend/src/App.jsx`](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/frontend/chatbot-frontend/src/App.jsx) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat experience"]
  node_chat_ui["Chat interface<br/>[App.jsx]"]
  node_app_mount["App mount<br/>[main.jsx]"]
end

subgraph group_answer["Answer service"]
  node_chat_api["Chat API<br/>[main.py]"]
  node_query_refinement["Query refinement<br/>[main.py]"]
  node_company_search["Company retrieval<br/>[main.py]"]
  node_standards_search["Standards fallback<br/>[main.py]"]
  node_answer_generation["Answer generation<br/>[main.py]"]
  node_request_metrics["Request metrics<br/>[main.py]"]
end

subgraph group_knowledge["Knowledge management"]
  node_company_indexing["Company indexing"]
  node_standards_indexing["Standards indexing"]
  node_company_documents["Company policies"]
  node_standards_documents["External standards"]
  node_vector_store[("Pinecone index")]
end

subgraph group_operations["Maintenance and evaluation"]
  node_policy_splitter["Policy separation"]
  node_metadata_update["Metadata updater<br/>[update_metadata.py]"]
  node_rag_evaluation["RAG evaluation<br/>[measure_metrics.py]"]
end

node_employee(("Employee"))
node_cohere["Cohere services"]

node_employee -->|"asks question"| node_chat_ui
node_app_mount -->|"renders"| node_chat_ui
node_chat_ui -->|"posts question"| node_chat_api
node_chat_api -->|"refines query"| node_query_refinement
node_chat_api -->|"searches first"| node_company_search
node_chat_api -->|"falls back"| node_standards_search
node_chat_api -->|"generates answer"| node_answer_generation
node_chat_api -->|"records metrics"| node_request_metrics
node_company_search -->|"searches namespace"| node_vector_store
node_standards_search -->|"searches namespace"| node_vector_store
node_answer_generation -->|"invokes model"| node_cohere
node_company_indexing -->|"loads files"| node_company_documents
node_standards_indexing -->|"loads files"| node_standards_documents
node_company_indexing -->|"embeds text"| node_cohere
node_standards_indexing -->|"embeds text"| node_cohere
node_company_indexing -->|"indexes chunks"| node_vector_store
node_standards_indexing -->|"indexes chunks"| node_vector_store
node_metadata_update -->|"updates metadata"| node_vector_store
node_rag_evaluation -->|"retrieves context"| node_vector_store
node_rag_evaluation -->|"compares answers"| node_cohere

click node_chat_ui "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/frontend/chatbot-frontend/src/App.jsx"
click node_app_mount "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/frontend/chatbot-frontend/src/main.jsx"
click node_chat_api "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_query_refinement "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_company_search "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_standards_search "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_answer_generation "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_request_metrics "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py"
click node_company_indexing "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_company.py"
click node_standards_indexing "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_standards.py"
click node_company_documents "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/tree/main/documents/Company"
click node_standards_documents "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/tree/main/documents/standards"
click node_policy_splitter "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/process_company_policies.py"
click node_metadata_update "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/update_metadata.py"
click node_rag_evaluation "https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/measure_metrics.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,node_app_mount toneBlue
class node_chat_api,node_query_refinement,node_company_search,node_standards_search,node_answer_generation,node_request_metrics toneAmber
class node_company_indexing,node_standards_indexing,node_company_documents,node_standards_documents,node_vector_store toneMint
class node_policy_splitter,node_metadata_update,node_rag_evaluation toneRose
class node_employee,node_cohere toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/frontend/chatbot-frontend/src/App.jsx): `frontend/chatbot-frontend/src/App.jsx`
- [App mount](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/frontend/chatbot-frontend/src/main.jsx): `frontend/chatbot-frontend/src/main.jsx`

### Answer service

- [Chat API](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`
- [Query refinement](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`
- [Company retrieval](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`
- [Standards fallback](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`
- [Answer generation](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`
- [Request metrics](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/main.py): `backend/main.py`

### Knowledge management

- [Company indexing](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_company.py): `backend/indextext_company.py`
- [Standards indexing](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/indextext_standards.py): `backend/indextext_standards.py`
- [Company policies](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/tree/main/documents/Company): `documents/Company`
- [External standards](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/tree/main/documents/standards): `documents/standards`
- **Pinecone index**

### Maintenance and evaluation

- [Policy separation](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/process_company_policies.py): `backend/process_company_policies.py`
- [Metadata updater](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/update_metadata.py): `backend/update_metadata.py`
- [RAG evaluation](https://github.com/antxnyxsajan/ai-powered-information-security-policy-advisor/blob/main/backend/measure_metrics.py): `backend/measure_metrics.py`

### Other components

- **Employee**
- **Cohere services**

## Connections

- Employee → Chat interface: asks question (evidence: `frontend/chatbot-frontend/src/App.jsx`)
- App mount → Chat interface: renders (evidence: `frontend/chatbot-frontend/src/main.jsx`)
- Chat interface → Chat API: posts question (evidence: `frontend/chatbot-frontend/src/App.jsx`)
- Chat API → Query refinement: refines query (evidence: `backend/main.py`)
- Chat API → Company retrieval: searches first (evidence: `backend/main.py`)
- Chat API → Standards fallback: falls back (evidence: `backend/main.py`)
- Chat API → Answer generation: generates answer (evidence: `backend/main.py`)
- Chat API → Request metrics: records metrics (evidence: `backend/main.py`)
- Company retrieval → Pinecone index: searches namespace (evidence: `backend/main.py`)
- Standards fallback → Pinecone index: searches namespace (evidence: `backend/main.py`)
- Answer generation → Cohere services: invokes model (evidence: `backend/main.py`)
- Company indexing → Company policies: loads files (evidence: `backend/indextext_company.py`)
- Standards indexing → External standards: loads files (evidence: `backend/indextext_standards.py`)
- Company indexing → Cohere services: embeds text (evidence: `backend/indextext_company.py`)
- Standards indexing → Cohere services: embeds text (evidence: `backend/indextext_standards.py`)
- Company indexing → Pinecone index: indexes chunks (evidence: `backend/indextext_company.py`)
- Standards indexing → Pinecone index: indexes chunks (evidence: `backend/indextext_standards.py`)
- Metadata updater → Pinecone index: updates metadata (evidence: `backend/update_metadata.py`)
- RAG evaluation → Pinecone index: retrieves context (evidence: `backend/measure_metrics.py`)
- RAG evaluation → Cohere services: compares answers (evidence: `backend/measure_metrics.py`)
