# leoxramadani/ragapidotnetollama architecture

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

- Interactive diagram: https://gitdiagram.com/leoxramadani/ragapidotnetollama
- Repository: https://github.com/leoxramadani/ragapidotnetollama

## Overview

This is an ASP.NET RAG API for indexing PDF, text, and Excel documents, answering questions from retrieved document chunks, and evaluating retrieval and answer faithfulness. The main workflows are document upload through extraction, chunking, embedding, and Qdrant storage; and question submission through retrieval, prompt construction, and OpenAI generation. Document listing and deletion, plus evaluation, are separate capabilities. Evaluation and controller behavior are based on the source index references where their implementations were not excerpted.

Main entry points: [`Services/RagService.cs`](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RagService.cs) (RAG workflow), [`Services/IngestionService.cs`](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/IngestionService.cs) (Ingestion), [`Services/EvaluationService.cs`](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/EvaluationService.cs) (Evaluation), [`Services/VectorStoreService.cs`](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/VectorStoreService.cs) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API endpoints"]
  node_documents["Documents API"]
  node_questions["Questions API"]
  node_evaluation_api["Evaluation API"]
end

subgraph group_ingest["Document ingestion"]
  node_ingestion["Ingestion"]
  node_extractor["Text extraction"]
  node_splitter["Text splitting"]
end

subgraph group_rag["Question answering"]
  node_rag_service["RAG workflow<br/>[RagService.cs]"]
  node_prompts["RAG prompts<br/>[RagPrompts.cs]"]
end

subgraph group_eval["Evaluation"]
  node_evaluation["Evaluation"]
end

subgraph group_infra["Models and integrations"]
  node_embedding["Embeddings"]
  node_vector_store["Vector store"]
  node_qdrant[("Qdrant")]
  node_openai["OpenAI"]
  node_models["Request and result models<br/>[Models.cs]"]
  node_options["Service options<br/>[Options.cs]"]
end

node_user(("API client"))

node_user -->|"uploads or manages"| node_documents
node_user -.->|"asks question"| node_questions
node_user -.->|"requests evaluation"| node_evaluation_api
node_documents -->|"ingests upload"| node_ingestion
node_documents -->|"lists or deletes"| node_vector_store
node_ingestion -->|"extracts text"| node_extractor
node_ingestion -->|"splits text"| node_splitter
node_ingestion -->|"embeds chunks"| node_embedding
node_ingestion -->|"stores chunks"| node_vector_store
node_extractor -->|"returns extracted document"| node_models
node_embedding -->|"requests embeddings"| node_openai
node_vector_store -->|"reads and writes"| node_qdrant
node_questions -->|"answers question"| node_rag_service
node_rag_service -->|"checks and searches"| node_vector_store
node_rag_service -->|"embeds question"| node_embedding
node_rag_service -->|"builds prompt"| node_prompts
node_rag_service -->|"generates answer"| node_openai
node_rag_service -->|"returns answer and sources"| node_models
node_evaluation_api -->|"runs evaluation"| node_evaluation
node_evaluation -->|"retrieves and generates"| node_rag_service
node_evaluation -->|"builds context and checks fallback"| node_prompts
node_evaluation -->|"judges faithfulness"| node_openai
node_evaluation -->|"returns report"| node_models

click node_documents "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/DocumentsController.cs"
click node_questions "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/QuestionsController.cs"
click node_evaluation_api "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/EvaluationController.cs"
click node_ingestion "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/IngestionService.cs"
click node_extractor "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/DocumentTextExtractor.cs"
click node_splitter "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RecursiveTextSplitter.cs"
click node_embedding "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/EmbeddingService.cs"
click node_vector_store "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/VectorStoreService.cs"
click node_rag_service "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RagService.cs"
click node_prompts "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RagPrompts.cs"
click node_evaluation "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/EvaluationService.cs"
click node_models "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Models/Models.cs"
click node_options "https://github.com/leoxramadani/ragapidotnetollama/blob/main/Options/Options.cs"

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_documents,node_questions,node_evaluation_api,node_user toneBlue
class node_ingestion,node_extractor,node_splitter toneAmber
class node_rag_service,node_prompts toneMint
class node_evaluation toneRose
class node_embedding,node_vector_store,node_qdrant,node_openai,node_models,node_options toneIndigo
```

## Components

### API endpoints

- [Documents API](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/DocumentsController.cs): `Controllers/DocumentsController.cs`
- [Questions API](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/QuestionsController.cs): `Controllers/QuestionsController.cs`
- [Evaluation API](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Controllers/EvaluationController.cs): `Controllers/EvaluationController.cs`

### Document ingestion

- [Ingestion](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/IngestionService.cs): `Services/IngestionService.cs`
- [Text extraction](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/DocumentTextExtractor.cs): `Services/DocumentTextExtractor.cs`
- [Text splitting](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RecursiveTextSplitter.cs): `Services/RecursiveTextSplitter.cs`

### Question answering

- [RAG workflow](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RagService.cs): `Services/RagService.cs`
- [RAG prompts](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/RagPrompts.cs): `Services/RagPrompts.cs`

### Evaluation

- [Evaluation](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/EvaluationService.cs): `Services/EvaluationService.cs`

### Models and integrations

- [Embeddings](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/EmbeddingService.cs): `Services/EmbeddingService.cs`
- [Vector store](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Services/VectorStoreService.cs): `Services/VectorStoreService.cs`
- **Qdrant**
- **OpenAI**
- [Request and result models](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Models/Models.cs): `Models/Models.cs`
- [Service options](https://github.com/leoxramadani/ragapidotnetollama/blob/main/Options/Options.cs): `Options/Options.cs`

### Other components

- **API client**

## Connections

- API client → Documents API: uploads or manages (evidence: `Controllers/DocumentsController.cs`)
- API client → Questions API: asks question
- API client → Evaluation API: requests evaluation
- Documents API → Ingestion: ingests upload (evidence: `Controllers/DocumentsController.cs`)
- Documents API → Vector store: lists or deletes (evidence: `Controllers/DocumentsController.cs`)
- Ingestion → Text extraction: extracts text (evidence: `Services/IngestionService.cs`)
- Ingestion → Text splitting: splits text (evidence: `Services/IngestionService.cs`)
- Ingestion → Embeddings: embeds chunks (evidence: `Services/IngestionService.cs`)
- Ingestion → Vector store: stores chunks (evidence: `Services/IngestionService.cs`)
- Text extraction → Request and result models: returns extracted document (evidence: `Services/DocumentTextExtractor.cs`)
- Embeddings → OpenAI: requests embeddings (evidence: `Services/EmbeddingService.cs`)
- Vector store → Qdrant: reads and writes (evidence: `Services/VectorStoreService.cs`)
- Questions API → RAG workflow: answers question (evidence: `Controllers/QuestionsController.cs`)
- RAG workflow → Vector store: checks and searches (evidence: `Services/RagService.cs`)
- RAG workflow → Embeddings: embeds question (evidence: `Services/RagService.cs`)
- RAG workflow → RAG prompts: builds prompt (evidence: `Services/RagService.cs`)
- RAG workflow → OpenAI: generates answer (evidence: `Services/RagService.cs`)
- RAG workflow → Request and result models: returns answer and sources (evidence: `Services/RagService.cs`)
- Evaluation API → Evaluation: runs evaluation (evidence: `Controllers/EvaluationController.cs`)
- Evaluation → RAG workflow: retrieves and generates (evidence: `Services/EvaluationService.cs`)
- Evaluation → RAG prompts: builds context and checks fallback (evidence: `Services/EvaluationService.cs`)
- Evaluation → OpenAI: judges faithfulness (evidence: `Services/EvaluationService.cs`)
- Evaluation → Request and result models: returns report (evidence: `Services/EvaluationService.cs`)
