# vasi-vijay/document-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/vasi-vijay/document-analyzer
- Repository: https://github.com/vasi-vijay/document-analyzer

## Overview

Document Analyzer is a personal-first, authenticated document Q&A application. Its main workflow accepts an upload, extracts and chunks text for persistence, then retrieves relevant chunks from the caller’s ready documents to ground a model-generated answer with source excerpts. It also exposes document listing and inspection, plus a minimal web UI. The README documents these relationships and the lexical retrieval baseline; source excerpts were not provided, so the graph does not assert finer-grained implementation details.

Main entry points: [`src/main/java/com/example/docanalyzer/question/QuestionService.java`](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionService.java) (Question service), [`src/main/java/com/example/docanalyzer/document/DocumentUploadService.java`](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentUploadService.java) (Upload handling), [`src/main/java/com/example/docanalyzer/document/DocumentController.java`](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentController.java) (Document API), [`src/main/java/com/example/docanalyzer/question/QuestionController.java`](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionController.java) (Question API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and UI"]
  node_security["Authentication"]
  node_web["Web UI"]
end

subgraph group_documents["Document handling"]
  node_document_api["Document API"]
  node_upload["Upload handling"]
  node_storage["File storage"]
  node_ingestion["Text ingestion"]
end

subgraph group_questions["Question answering"]
  node_question_api["Question API"]
  node_question_service["Question service"]
  node_citations["Answer and citations"]
  node_model_service["Model integration"]
end

subgraph group_persistence["Persistence and models"]
  node_document_record["Document records"]
  node_document_repository["Document repository"]
  node_chunks["Chunk records<br/>[DocumentChunk.java]"]
  node_chunk_repository["Chunk repository"]
  node_postgres[("PostgreSQL")]
end

node_user(("Authenticated user"))
node_model_provider{{"Configured AI model"}}

node_user -->|"uploads and lists"| node_document_api
node_user -->|"asks questions"| node_question_api
node_user -->|"authenticates"| node_security
node_security -->|"protects access"| node_document_api
node_security -->|"protects access"| node_question_api
node_user -.->|"opens interface"| node_web
node_document_api -->|"handles uploads"| node_upload
node_upload -->|"extracts and chunks"| node_ingestion
node_ingestion -->|"persists chunks"| node_chunk_repository
node_upload -->|"records status"| node_document_repository
node_upload -.->|"stores file"| node_storage
node_document_repository -->|"reads and writes"| node_postgres
node_chunk_repository -->|"reads and writes"| node_postgres
node_document_api -->|"lists and inspects"| node_document_repository
node_question_api -->|"dispatches question"| node_question_service
node_question_service -->|"scopes ready documents"| node_document_repository
node_question_service -->|"ranks lexical matches"| node_chunk_repository
node_question_service -->|"sends grounded context"| node_model_service
node_model_service -->|"calls configured model"| node_model_provider
node_question_service -->|"returns source excerpts"| node_citations
node_question_service -->|"returns answer"| node_question_api

click node_security "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/security/SecurityConfig.java"
click node_web "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/web/HomeController.java"
click node_document_api "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentController.java"
click node_upload "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentUploadService.java"
click node_storage "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentStorageService.java"
click node_ingestion "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentIngestionService.java"
click node_document_record "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentRecord.java"
click node_document_repository "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentRepository.java"
click node_chunks "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentChunk.java"
click node_chunk_repository "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentChunkRepository.java"
click node_question_api "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionController.java"
click node_question_service "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionService.java"
click node_citations "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/SourceCitation.java"
click node_model_service "https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/AiModelService.java"

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_security,node_web,node_user toneBlue
class node_document_api,node_upload,node_storage,node_ingestion toneAmber
class node_question_api,node_question_service,node_citations,node_model_service toneMint
class node_document_record,node_document_repository,node_chunks,node_chunk_repository,node_postgres toneRose
class node_model_provider toneIndigo
```

## Components

### Access and UI

- [Authentication](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/security/SecurityConfig.java): `src/main/java/com/example/docanalyzer/security/SecurityConfig.java`
- [Web UI](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/web/HomeController.java): `src/main/java/com/example/docanalyzer/web/HomeController.java`

### Document handling

- [Document API](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentController.java): `src/main/java/com/example/docanalyzer/document/DocumentController.java`
- [Upload handling](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentUploadService.java): `src/main/java/com/example/docanalyzer/document/DocumentUploadService.java`
- [File storage](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentStorageService.java): `src/main/java/com/example/docanalyzer/document/DocumentStorageService.java`
- [Text ingestion](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentIngestionService.java): `src/main/java/com/example/docanalyzer/ingestion/DocumentIngestionService.java`

### Question answering

- [Question API](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionController.java): `src/main/java/com/example/docanalyzer/question/QuestionController.java`
- [Question service](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/QuestionService.java): `src/main/java/com/example/docanalyzer/question/QuestionService.java`
- [Answer and citations](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/SourceCitation.java): `src/main/java/com/example/docanalyzer/question/SourceCitation.java`
- [Model integration](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/question/AiModelService.java): `src/main/java/com/example/docanalyzer/question/AiModelService.java`

### Persistence and models

- [Document records](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentRecord.java): `src/main/java/com/example/docanalyzer/document/DocumentRecord.java`
- [Document repository](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/document/DocumentRepository.java): `src/main/java/com/example/docanalyzer/document/DocumentRepository.java`
- [Chunk records](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentChunk.java): `src/main/java/com/example/docanalyzer/ingestion/DocumentChunk.java`
- [Chunk repository](https://github.com/vasi-vijay/document-analyzer/blob/main/src/main/java/com/example/docanalyzer/ingestion/DocumentChunkRepository.java): `src/main/java/com/example/docanalyzer/ingestion/DocumentChunkRepository.java`
- **PostgreSQL**

### Other components

- **Authenticated user**
- **Configured AI model**

## Connections

- Authenticated user → Document API: uploads and lists (evidence: `README.md`)
- Authenticated user → Question API: asks questions (evidence: `README.md`)
- Authenticated user → Authentication: authenticates (evidence: `README.md`)
- Authentication → Document API: protects access (evidence: `README.md`)
- Authentication → Question API: protects access (evidence: `README.md`)
- Authenticated user → Web UI: opens interface (evidence: `README.md`)
- Document API → Upload handling: handles uploads (evidence: `README.md`)
- Upload handling → Text ingestion: extracts and chunks (evidence: `README.md`)
- Text ingestion → Chunk repository: persists chunks (evidence: `README.md`)
- Upload handling → Document repository: records status (evidence: `README.md`)
- Upload handling → File storage: stores file (evidence: `README.md`)
- Document repository → PostgreSQL: reads and writes (evidence: `README.md`)
- Chunk repository → PostgreSQL: reads and writes (evidence: `README.md`)
- Document API → Document repository: lists and inspects (evidence: `README.md`)
- Question API → Question service: dispatches question (evidence: `README.md`)
- Question service → Document repository: scopes ready documents (evidence: `README.md`)
- Question service → Chunk repository: ranks lexical matches (evidence: `README.md`)
- Question service → Model integration: sends grounded context (evidence: `README.md`)
- Model integration → Configured AI model: calls configured model (evidence: `README.md`)
- Question service → Answer and citations: returns source excerpts (evidence: `README.md`)
- Question service → Question API: returns answer (evidence: `README.md`)
