# mayank953/meridian-ai-learner architecture

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

- Interactive diagram: https://gitdiagram.com/mayank953/meridian-ai-learner
- Repository: https://github.com/mayank953/meridian-ai-learner

## Overview

Meridian AI is a web app for document-grounded Q&A and AI-assisted purchase audits. The browser UI calls a FastAPI backend: uploads are retained and indexed, while questions retrieve relevant document chunks for an answer; audit requests run risk, tax, and financial-control reviews followed by CFO synthesis. The graph includes the documented local/cloud storage and vector-search options. Some frontend component internals and backend storage implementations were not excerpted, so uncertain connections are omitted; README-documented flows and visible source calls are shown.

Main entry points: [`backend/agent/agents.py`](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py) (Audit supervisor), [`backend/api/endpoints.py`](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/endpoints.py) (API routes), [`frontend/src/App.tsx`](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/App.tsx) (React app), [`frontend/src/lib/api.ts`](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["React app<br/>[App.tsx]"]
  node_qa_ui["Document Q&amp;A tab<br/>[RagQATab.tsx]"]
  node_upload_ui["Document upload tab"]
  node_audit_ui["Audit tab<br/>[AuditTab.tsx]"]
  node_status_ui["System status tab"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["API routes<br/>[endpoints.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_rag["Document Q&amp;A"]
  node_ingestion["PDF ingestion and chunking<br/>[data_ingestion.py]"]
  node_document_store[("Original document storage<br/>[document_store.py]")]
  node_retrieval["Retrieval and answer chain<br/>[retrieval.py]"]
  node_vector_store[("Vector search store<br/>[vector_store.py]")]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
end

subgraph group_audit["Purchase audit"]
  node_audit_supervisor["Audit supervisor<br/>[agents.py]"]
  node_risk_review["Risk and compliance review<br/>[agents.py]"]
  node_tax_review["Tax and treasury review<br/>[agents.py]"]
  node_control_review["Financial control review<br/>[agents.py]"]
  node_cfo_synthesis["CFO memo synthesis<br/>[agents.py]"]
  node_audit_tools["Audit tools<br/>[tools.py]"]
  node_audit_prompts["Audit prompts<br/>[prompts.py]"]
  node_middleware["Agent middleware<br/>[middleware.py]"]
end

subgraph group_shared["Shared services"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_llm["Gemini chat model<br/>[llm.py]"]
end

node_user(("Browser user"))
node_gemini{{"Google Gemini"}}
node_vector_service[("Vector search service")]
node_cloud_storage[("Cloud Storage")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_qa_ui
node_app -.->|"hosts"| node_upload_ui
node_app -.->|"hosts"| node_audit_ui
node_app -.->|"hosts"| node_status_ui
node_qa_ui -->|"sends queries"| node_api_client
node_upload_ui -->|"sends PDFs"| node_api_client
node_audit_ui -->|"submits request"| node_api_client
node_status_ui -.->|"requests status"| node_api_client
node_api_client -->|"calls API"| node_routes
node_fastapi -->|"registers routes"| node_routes
node_routes -->|"validates and returns"| node_schemas
node_routes -->|"indexes uploads"| node_ingestion
node_routes -->|"saves originals"| node_document_store
node_routes -->|"asks question"| node_retrieval
node_ingestion -->|"reads stored PDFs"| node_document_store
node_ingestion -->|"adds chunks"| node_vector_store
node_retrieval -->|"searches chunks"| node_vector_store
node_retrieval -->|"generates answer"| node_llm
node_vector_store -->|"embeds queries"| node_embeddings
node_vector_store -.->|"uses in cloud mode"| node_vector_service
node_document_store -.->|"uses in cloud mode"| node_cloud_storage
node_routes -->|"runs audit"| node_audit_supervisor
node_audit_supervisor -->|"runs first"| node_risk_review
node_audit_supervisor -->|"runs second"| node_tax_review
node_audit_supervisor -->|"runs third"| node_control_review
node_audit_supervisor -->|"synthesizes reports"| node_cfo_synthesis
node_risk_review -->|"uses tools"| node_audit_tools
node_tax_review -->|"uses tools"| node_audit_tools
node_control_review -->|"uses tools"| node_audit_tools
node_audit_supervisor -->|"configures reviews"| node_audit_prompts
node_audit_supervisor -->|"builds agent stack"| node_middleware
node_audit_supervisor -->|"invokes model"| node_llm
node_audit_tools -->|"uses model"| node_llm
node_llm -->|"calls"| node_gemini
node_settings -->|"configures"| node_llm
node_settings -->|"selects model"| node_embeddings

click node_app "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/App.tsx"
click node_qa_ui "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/RagQATab.tsx"
click node_upload_ui "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/DocumentUploadTab.tsx"
click node_audit_ui "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/AuditTab.tsx"
click node_status_ui "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/SystemStatusTab.tsx"
click node_api_client "https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/lib/api.ts"
click node_fastapi "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/main.py"
click node_routes "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/endpoints.py"
click node_schemas "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/schemas.py"
click node_ingestion "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/data_ingestion.py"
click node_document_store "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/document_store.py"
click node_retrieval "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/retrieval.py"
click node_vector_store "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/vector_store.py"
click node_embeddings "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/embeddings.py"
click node_audit_supervisor "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py"
click node_risk_review "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py"
click node_tax_review "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py"
click node_control_review "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py"
click node_cfo_synthesis "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py"
click node_audit_tools "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/tools.py"
click node_audit_prompts "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/prompts.py"
click node_middleware "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/middleware.py"
click node_settings "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/config/settings.py"
click node_llm "https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/llm.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_app,node_qa_ui,node_upload_ui,node_audit_ui,node_status_ui,node_api_client,node_user toneBlue
class node_fastapi,node_routes,node_schemas,node_vector_service,node_cloud_storage toneAmber
class node_ingestion,node_document_store,node_retrieval,node_vector_store,node_embeddings toneMint
class node_audit_supervisor,node_risk_review,node_tax_review,node_control_review,node_cfo_synthesis,node_audit_tools,node_audit_prompts,node_middleware toneRose
class node_settings,node_llm,node_gemini toneIndigo
```

## Components

### Web interface

- [React app](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Document Q&A tab](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/RagQATab.tsx): `frontend/src/components/RagQATab.tsx`
- [Document upload tab](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/DocumentUploadTab.tsx): `frontend/src/components/DocumentUploadTab.tsx`
- [Audit tab](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/AuditTab.tsx): `frontend/src/components/AuditTab.tsx`
- [System status tab](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/components/SystemStatusTab.tsx): `frontend/src/components/SystemStatusTab.tsx`
- [API client](https://github.com/mayank953/meridian-ai-learner/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Backend API

- [FastAPI app](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/main.py): `backend/api/main.py`
- [API routes](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/endpoints.py): `backend/api/endpoints.py`
- [Request and response schemas](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/api/schemas.py): `backend/api/schemas.py`

### Document Q&A

- [PDF ingestion and chunking](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/data_ingestion.py): `backend/rag/data_ingestion.py`
- [Original document storage](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/document_store.py): `backend/rag/document_store.py`
- [Retrieval and answer chain](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/retrieval.py): `backend/rag/retrieval.py`
- [Vector search store](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/vector_store.py): `backend/rag/vector_store.py`
- [Text embeddings](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/embeddings.py): `backend/rag/embeddings.py`

### Purchase audit

- [Audit supervisor](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py): `backend/agent/agents.py`
- [Risk and compliance review](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py): `backend/agent/agents.py`
- [Tax and treasury review](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py): `backend/agent/agents.py`
- [Financial control review](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py): `backend/agent/agents.py`
- [CFO memo synthesis](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/agents.py): `backend/agent/agents.py`
- [Audit tools](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/tools.py): `backend/agent/tools.py`
- [Audit prompts](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/prompts.py): `backend/agent/prompts.py`
- [Agent middleware](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/agent/middleware.py): `backend/agent/middleware.py`

### Shared services

- [Runtime settings](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/config/settings.py): `backend/config/settings.py`
- [Gemini chat model](https://github.com/mayank953/meridian-ai-learner/blob/main/backend/rag/llm.py): `backend/rag/llm.py`

### Other components

- **Browser user**
- **Google Gemini**
- **Vector search service**
- **Cloud Storage**

## Connections

- Browser user → React app: uses (evidence: `README.md`)
- React app → Document Q&A tab: routes to (evidence: `frontend/src/App.tsx`)
- React app → Document upload tab: hosts
- React app → Audit tab: hosts
- React app → System status tab: hosts
- Document Q&A tab → API client: sends queries (evidence: `README.md`)
- Document upload tab → API client: sends PDFs (evidence: `README.md`)
- Audit tab → API client: submits request (evidence: `README.md`)
- System status tab → API client: requests status
- API client → API routes: calls API (evidence: `README.md`)
- FastAPI app → API routes: registers routes (evidence: `backend/api/main.py`)
- API routes → Request and response schemas: validates and returns (evidence: `backend/api/endpoints.py`)
- API routes → PDF ingestion and chunking: indexes uploads (evidence: `backend/api/endpoints.py`)
- API routes → Original document storage: saves originals (evidence: `backend/api/endpoints.py`)
- API routes → Retrieval and answer chain: asks question (evidence: `backend/api/endpoints.py`)
- PDF ingestion and chunking → Original document storage: reads stored PDFs (evidence: `backend/rag/data_ingestion.py`)
- PDF ingestion and chunking → Vector search store: adds chunks (evidence: `backend/rag/data_ingestion.py`)
- Retrieval and answer chain → Vector search store: searches chunks (evidence: `backend/rag/retrieval.py`)
- Retrieval and answer chain → Gemini chat model: generates answer (evidence: `backend/rag/retrieval.py`)
- Vector search store → Text embeddings: embeds queries (evidence: `backend/rag/vector_store.py`)
- Vector search store → Vector search service: uses in cloud mode
- Original document storage → Cloud Storage: uses in cloud mode
- API routes → Audit supervisor: runs audit (evidence: `backend/api/endpoints.py`)
- Audit supervisor → Risk and compliance review: runs first (evidence: `backend/agent/agents.py`)
- Audit supervisor → Tax and treasury review: runs second (evidence: `backend/agent/agents.py`)
- Audit supervisor → Financial control review: runs third (evidence: `backend/agent/agents.py`)
- Audit supervisor → CFO memo synthesis: synthesizes reports (evidence: `backend/agent/agents.py`)
- Risk and compliance review → Audit tools: uses tools (evidence: `backend/agent/agents.py`)
- Tax and treasury review → Audit tools: uses tools (evidence: `backend/agent/agents.py`)
- Financial control review → Audit tools: uses tools (evidence: `backend/agent/agents.py`)
- Audit supervisor → Audit prompts: configures reviews (evidence: `backend/agent/agents.py`)
- Audit supervisor → Agent middleware: builds agent stack (evidence: `backend/agent/agents.py`)
- Audit supervisor → Gemini chat model: invokes model (evidence: `backend/agent/agents.py`)
- Audit tools → Gemini chat model: uses model (evidence: `backend/agent/tools.py`)
- Gemini chat model → Google Gemini: calls (evidence: `backend/rag/llm.py`)
- Runtime settings → Gemini chat model: configures (evidence: `backend/rag/llm.py`)
- Runtime settings → Text embeddings: selects model (evidence: `backend/rag/embeddings.py`)
