# yash9614/project_oo1 architecture

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

- Interactive diagram: https://gitdiagram.com/yash9614/project_oo1
- Repository: https://github.com/yash9614/project_oo1

## Overview

This is a secure enterprise RAG assistant. Users ask questions through the API, where the Assistant identifies the user, searches only authorized content, retries with a rewritten query when needed, generates a quote-verified answer, and records an audit event. Documents enter through upload, are parsed, deduplicated/versioned, chunked and embedded, then stored for hybrid vector and keyword retrieval. The graph preserves documented UI, audit, and containerized-product capabilities; source for the UI and schema was not sampled, so those links rely on README documentation.

Main entry points: [`assistant/pipeline.py`](https://github.com/yash9614/project_oo1/blob/main/assistant/pipeline.py) (Assistant workflow), [`assistant/retrieval.py`](https://github.com/yash9614/project_oo1/blob/main/assistant/retrieval.py) (Retriever), [`assistant/api.py`](https://github.com/yash9614/project_oo1/blob/main/assistant/api.py) (FastAPI), [`assistant/ingestion.py`](https://github.com/yash9614/project_oo1/blob/main/assistant/ingestion.py) (Embed and store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and API"]
  node_webui["Web UI<br/>[index.html]"]
  node_api["FastAPI<br/>[api.py]"]
  node_cli["CLI<br/>[ask.py]"]
end

subgraph group_indexing["Document indexing"]
  node_upload["Upload handling<br/>[api.py]"]
  node_parse["Parse and chunk<br/>[ingestion.py]"]
  node_embedstore["Embed and store<br/>[ingestion.py]"]
end

subgraph group_query["Question answering"]
  node_assistant["Assistant workflow<br/>[pipeline.py]"]
  node_identity["User identity<br/>[repository.py]"]
  node_retriever["Retriever<br/>[retrieval.py]"]
  node_hybrid["Hybrid search<br/>[repository.py]"]
  node_rerank["Reranking<br/>[retrieval.py]"]
  node_corrective["Grade and rewrite<br/>[pipeline.py]"]
  node_generator["Grounded generation<br/>[generation.py]"]
  node_models["Answer models<br/>[models.py]"]
end

subgraph group_storage["Persistence"]
  node_audit["Audit events<br/>[repository.py]"]
  node_database[("PostgreSQL and pgvector<br/>[schema.sql]")]
end

subgraph group_integrations["External services"]
  node_openai["OpenAI models"]
end

node_user(("User"))

node_user -.->|"asks"| node_webui
node_webui -.->|"uses"| node_api
node_user -->|"asks"| node_api
node_user -->|"asks"| node_cli
node_api -->|"invokes"| node_assistant
node_cli -->|"invokes"| node_assistant
node_api -->|"handles"| node_upload
node_upload -->|"stores document"| node_parse
node_parse -->|"chunks document"| node_embedstore
node_embedstore -->|"creates embeddings"| node_openai
node_embedstore -->|"writes documents"| node_database
node_assistant -->|"looks up user"| node_identity
node_assistant -->|"searches"| node_retriever
node_retriever -->|"embeds query"| node_openai
node_retriever -->|"fetches candidates"| node_hybrid
node_hybrid -->|"queries authorized chunks"| node_database
node_retriever -->|"reranks candidates"| node_rerank
node_rerank -->|"rates relevance"| node_openai
node_assistant -->|"grades and rewrites"| node_corrective
node_corrective -->|"uses helper model"| node_openai
node_assistant -->|"generates answer"| node_generator
node_generator -->|"drafts answer"| node_openai
node_generator -->|"builds citations"| node_models
node_assistant -->|"records question"| node_audit
node_audit -->|"writes event"| node_database

click node_webui "https://github.com/yash9614/project_oo1/blob/main/web/index.html"
click node_api "https://github.com/yash9614/project_oo1/blob/main/assistant/api.py"
click node_cli "https://github.com/yash9614/project_oo1/blob/main/ask.py"
click node_upload "https://github.com/yash9614/project_oo1/blob/main/assistant/api.py"
click node_parse "https://github.com/yash9614/project_oo1/blob/main/assistant/ingestion.py"
click node_embedstore "https://github.com/yash9614/project_oo1/blob/main/assistant/ingestion.py"
click node_assistant "https://github.com/yash9614/project_oo1/blob/main/assistant/pipeline.py"
click node_identity "https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py"
click node_retriever "https://github.com/yash9614/project_oo1/blob/main/assistant/retrieval.py"
click node_hybrid "https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py"
click node_rerank "https://github.com/yash9614/project_oo1/blob/main/assistant/retrieval.py"
click node_corrective "https://github.com/yash9614/project_oo1/blob/main/assistant/pipeline.py"
click node_generator "https://github.com/yash9614/project_oo1/blob/main/assistant/generation.py"
click node_models "https://github.com/yash9614/project_oo1/blob/main/assistant/models.py"
click node_audit "https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py"
click node_database "https://github.com/yash9614/project_oo1/blob/main/schema.sql"

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_webui,node_api,node_cli,node_user toneBlue
class node_upload,node_parse,node_embedstore toneAmber
class node_assistant,node_identity,node_retriever,node_hybrid,node_rerank,node_corrective,node_generator,node_models toneMint
class node_audit,node_database toneRose
class node_openai toneIndigo
```

## Components

### Access and API

- [Web UI](https://github.com/yash9614/project_oo1/blob/main/web/index.html): `web/index.html`
- [FastAPI](https://github.com/yash9614/project_oo1/blob/main/assistant/api.py): `assistant/api.py`
- [CLI](https://github.com/yash9614/project_oo1/blob/main/ask.py): `ask.py`

### Document indexing

- [Upload handling](https://github.com/yash9614/project_oo1/blob/main/assistant/api.py): `assistant/api.py`
- [Parse and chunk](https://github.com/yash9614/project_oo1/blob/main/assistant/ingestion.py): `assistant/ingestion.py`
- [Embed and store](https://github.com/yash9614/project_oo1/blob/main/assistant/ingestion.py): `assistant/ingestion.py`

### Question answering

- [Assistant workflow](https://github.com/yash9614/project_oo1/blob/main/assistant/pipeline.py): `assistant/pipeline.py`
- [User identity](https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py): `assistant/repository.py`
- [Retriever](https://github.com/yash9614/project_oo1/blob/main/assistant/retrieval.py): `assistant/retrieval.py`
- [Hybrid search](https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py): `assistant/repository.py`
- [Reranking](https://github.com/yash9614/project_oo1/blob/main/assistant/retrieval.py): `assistant/retrieval.py`
- [Grade and rewrite](https://github.com/yash9614/project_oo1/blob/main/assistant/pipeline.py): `assistant/pipeline.py`
- [Grounded generation](https://github.com/yash9614/project_oo1/blob/main/assistant/generation.py): `assistant/generation.py`
- [Answer models](https://github.com/yash9614/project_oo1/blob/main/assistant/models.py): `assistant/models.py`

### Persistence

- [Audit events](https://github.com/yash9614/project_oo1/blob/main/assistant/repository.py): `assistant/repository.py`
- [PostgreSQL and pgvector](https://github.com/yash9614/project_oo1/blob/main/schema.sql): `schema.sql`

### External services

- **OpenAI models**

### Other components

- **User**

## Connections

- User → Web UI: asks (evidence: `README.md`)
- Web UI → FastAPI: uses (evidence: `README.md`)
- User → FastAPI: asks (evidence: `assistant/api.py`)
- User → CLI: asks (evidence: `ask.py`)
- FastAPI → Assistant workflow: invokes (evidence: `assistant/api.py`)
- CLI → Assistant workflow: invokes (evidence: `ask.py`)
- FastAPI → Upload handling: handles (evidence: `assistant/api.py`)
- Upload handling → Parse and chunk: stores document (evidence: `assistant/api.py`)
- Parse and chunk → Embed and store: chunks document (evidence: `assistant/ingestion.py`)
- Embed and store → OpenAI models: creates embeddings (evidence: `assistant/ingestion.py`)
- Embed and store → PostgreSQL and pgvector: writes documents (evidence: `assistant/ingestion.py`)
- Assistant workflow → User identity: looks up user (evidence: `assistant/pipeline.py`)
- Assistant workflow → Retriever: searches (evidence: `assistant/pipeline.py`)
- Retriever → OpenAI models: embeds query (evidence: `assistant/retrieval.py`)
- Retriever → Hybrid search: fetches candidates (evidence: `assistant/retrieval.py`)
- Hybrid search → PostgreSQL and pgvector: queries authorized chunks (evidence: `assistant/repository.py`)
- Retriever → Reranking: reranks candidates (evidence: `assistant/retrieval.py`)
- Reranking → OpenAI models: rates relevance (evidence: `assistant/retrieval.py`)
- Assistant workflow → Grade and rewrite: grades and rewrites (evidence: `assistant/pipeline.py`)
- Grade and rewrite → OpenAI models: uses helper model (evidence: `assistant/pipeline.py`)
- Assistant workflow → Grounded generation: generates answer (evidence: `assistant/pipeline.py`)
- Grounded generation → OpenAI models: drafts answer (evidence: `assistant/generation.py`)
- Grounded generation → Answer models: builds citations (evidence: `assistant/generation.py`)
- Assistant workflow → Audit events: records question (evidence: `assistant/pipeline.py`)
- Audit events → PostgreSQL and pgvector: writes event (evidence: `assistant/repository.py`)
