# jurjans/m365-graph-rag-samples architecture

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

- Interactive diagram: https://gitdiagram.com/jurjans/m365-graph-rag-samples
- Repository: https://github.com/jurjans/m365-graph-rag-samples

## Overview

This repository is a set of illustrative patterns for a private Microsoft 365 document-answering assistant, not an integrated application. Its intended workflow is to authenticate to Graph, search SharePoint content, prepare retrieval-friendly chunks, and generate a cited answer grounded in supplied sources. The samples show the individual calls to MSAL, Microsoft Graph, and Anthropic; they do not implement the full retrieval-to-answer orchestration. The documented search-to-chunk-to-answer path is therefore shown as unverified.

Main entry points: [`src/graph_search.py`](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/graph_search.py) (SharePoint Search), [`src/rag.py`](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/rag.py) (Grounded Answer), [`src/auth.py`](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/auth.py) (Graph Auth), [`src/chunk.py`](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/chunk.py) (Text Chunking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Graph Access"]
  node_auth["Graph Auth<br/>[auth.py]"]
  node_msal["MSAL"]
end

subgraph group_retrieval["Content Retrieval"]
  node_search["SharePoint Search<br/>[graph_search.py]"]
  node_graph_api["Microsoft Graph"]
  node_chunk["Text Chunking<br/>[chunk.py]"]
end

subgraph group_answering["Grounded Answering"]
  node_rag["Grounded Answer<br/>[rag.py]"]
  node_anthropic["Anthropic Claude"]
end

node_caller(("Questioner"))

node_caller -->|"asks query"| node_search
node_search -->|"gets token"| node_auth
node_auth -->|"acquires token"| node_msal
node_search -->|"searches documents"| node_graph_api
node_search -.->|"prepares hits"| node_chunk
node_chunk -.->|"supplies context"| node_rag
node_rag -->|"requests answer"| node_anthropic
node_rag -->|"returns cited answer"| node_caller

click node_auth "https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/auth.py"
click node_search "https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/graph_search.py"
click node_chunk "https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/chunk.py"
click node_rag "https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/rag.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_auth,node_msal toneBlue
class node_search,node_graph_api,node_chunk toneAmber
class node_rag,node_anthropic toneMint
class node_caller toneIndigo
```

## Components

### Graph Access

- [Graph Auth](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/auth.py): `src/auth.py`
- **MSAL**

### Content Retrieval

- [SharePoint Search](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/graph_search.py): `src/graph_search.py`
- **Microsoft Graph**
- [Text Chunking](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/chunk.py): `src/chunk.py`

### Grounded Answering

- [Grounded Answer](https://github.com/jurjans/m365-graph-rag-samples/blob/main/src/rag.py): `src/rag.py`
- **Anthropic Claude**

### Other components

- **Questioner**

## Connections

- Questioner → SharePoint Search: asks query (evidence: `src/graph_search.py`)
- SharePoint Search → Graph Auth: gets token (evidence: `src/graph_search.py`)
- Graph Auth → MSAL: acquires token (evidence: `src/auth.py`)
- SharePoint Search → Microsoft Graph: searches documents (evidence: `src/graph_search.py`)
- SharePoint Search → Text Chunking: prepares hits
- Text Chunking → Grounded Answer: supplies context
- Grounded Answer → Anthropic Claude: requests answer (evidence: `src/rag.py`)
- Grounded Answer → Questioner: returns cited answer (evidence: `src/rag.py`)
