# vojtechgero/bakalrkaapi architecture

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

- Interactive diagram: https://gitdiagram.com/vojtechgero/bakalrkaapi
- Repository: https://github.com/vojtechgero/bakalrkaapi

## Overview

This repository is the backend API for a desktop PDF-management application. The main workflows are browsing and modifying documents, requesting OCR for a PDF, and searching OCR text across documents. FileService owns filesystem operations and coordinates OCR; OcrService calls Azure Document Intelligence and caches mapped results as JSON. SearchService scans those JSON caches and returns document-level or match-level results. The README documents the desktop client and Azure configuration; some FileService implementation is excerpted only partially, so uncertain internal wiring is omitted.

Main entry points: [`BakalrkaApi/Services/FileService.cs`](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/FileService.cs) (File operations), [`BakalrkaApi/Services/OcrService.cs`](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/OcrService.cs) (OCR processing), [`BakalrkaApi/Services/SearchService.cs`](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/SearchService.cs) (OCR text search), [`BakalrkaApi/Models/Pdf.cs`](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/Pdf.cs) (PDF document)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_fileapi["File endpoints<br/>[FileController.cs]"]
  node_searchapi["Search endpoints"]
end

subgraph group_files["Document management"]
  node_fileservice["File operations<br/>[FileService.cs]"]
  node_localfiles[("PDF and JSON files<br/>[FileService.cs]")]
end

subgraph group_ocrsearch["OCR and search"]
  node_ocrservice["OCR processing<br/>[OcrService.cs]"]
  node_searchservice["OCR text search<br/>[SearchService.cs]"]
  node_settings["Azure API settings<br/>[ApiSettings.cs]"]
end

subgraph group_models["Domain models"]
  node_pdfmodel["PDF document<br/>[Pdf.cs]"]
  node_pagemodel["OCR page<br/>[OcrPage.cs]"]
  node_boxmodel["OCR text box<br/>[OcrBox.cs]"]
  node_fileitem["File listing item<br/>[FileItem.cs]"]
  node_searchresult["Search match<br/>[SearchResult.cs]"]
  node_fileresults["Grouped results<br/>[FileResults.cs]"]
end

node_desktop(("Desktop client"))
node_azure["Azure Document Intelligence"]

node_desktop -->|"requests files"| node_fileapi
node_desktop -->|"submits searches"| node_searchapi
node_fileapi -->|"calls operations"| node_fileservice
node_fileservice -->|"reads and writes"| node_localfiles
node_fileservice -->|"requests OCR"| node_ocrservice
node_fileservice -->|"returns listings"| node_fileitem
node_fileservice -->|"returns PDF data"| node_pdfmodel
node_ocrservice -->|"reads or caches"| node_localfiles
node_ocrservice -->|"analyzes document"| node_azure
node_ocrservice -->|"uses credentials"| node_settings
node_ocrservice -->|"maps OCR result"| node_pdfmodel
node_pdfmodel -->|"contains pages"| node_pagemodel
node_pagemodel -->|"contains boxes"| node_boxmodel
node_searchapi -->|"calls search"| node_searchservice
node_searchservice -->|"scans JSON caches"| node_localfiles
node_searchservice -->|"deserializes documents"| node_pdfmodel
node_searchservice -->|"builds matches"| node_searchresult
node_searchservice -->|"groups matches"| node_fileresults

click node_fileapi "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Controllers/FileController.cs"
click node_searchapi "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Controllers/SearchController.cs"
click node_fileservice "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/FileService.cs"
click node_localfiles "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/FileService.cs"
click node_ocrservice "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/OcrService.cs"
click node_searchservice "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/SearchService.cs"
click node_pdfmodel "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/Pdf.cs"
click node_pagemodel "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/OcrPage.cs"
click node_boxmodel "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/OcrBox.cs"
click node_fileitem "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/FileItem.cs"
click node_searchresult "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/SearchResult.cs"
click node_fileresults "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/FileResults.cs"
click node_settings "https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/ApiSettings.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_fileapi,node_searchapi,node_desktop toneBlue
class node_fileservice,node_localfiles toneAmber
class node_ocrservice,node_searchservice,node_settings toneMint
class node_pdfmodel,node_pagemodel,node_boxmodel,node_fileitem,node_searchresult,node_fileresults toneRose
class node_azure toneIndigo
```

## Components

### API workflows

- [File endpoints](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Controllers/FileController.cs): `BakalrkaApi/Controllers/FileController.cs`
- [Search endpoints](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Controllers/SearchController.cs): `BakalrkaApi/Controllers/SearchController.cs`

### Document management

- [File operations](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/FileService.cs): `BakalrkaApi/Services/FileService.cs`
- [PDF and JSON files](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/FileService.cs): `BakalrkaApi/Services/FileService.cs`

### OCR and search

- [OCR processing](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/OcrService.cs): `BakalrkaApi/Services/OcrService.cs`
- [OCR text search](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/SearchService.cs): `BakalrkaApi/Services/SearchService.cs`
- [Azure API settings](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Services/ApiSettings.cs): `BakalrkaApi/Services/ApiSettings.cs`

### Domain models

- [PDF document](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/Pdf.cs): `BakalrkaApi/Models/Pdf.cs`
- [OCR page](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/OcrPage.cs): `BakalrkaApi/Models/OcrPage.cs`
- [OCR text box](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/OcrBox.cs): `BakalrkaApi/Models/OcrBox.cs`
- [File listing item](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/FileItem.cs): `BakalrkaApi/Models/FileItem.cs`
- [Search match](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/SearchResult.cs): `BakalrkaApi/Models/SearchResult.cs`
- [Grouped results](https://github.com/vojtechgero/bakalrkaapi/blob/master/BakalrkaApi/Models/FileResults.cs): `BakalrkaApi/Models/FileResults.cs`

### Other components

- **Desktop client**
- **Azure Document Intelligence**

## Connections

- Desktop client → File endpoints: requests files
- Desktop client → Search endpoints: submits searches
- File endpoints → File operations: calls operations
- File operations → PDF and JSON files: reads and writes
- File operations → OCR processing: requests OCR
- File operations → File listing item: returns listings
- File operations → PDF document: returns PDF data
- OCR processing → PDF and JSON files: reads or caches
- OCR processing → Azure Document Intelligence: analyzes document
- OCR processing → Azure API settings: uses credentials
- OCR processing → PDF document: maps OCR result
- PDF document → OCR page: contains pages
- OCR page → OCR text box: contains boxes
- Search endpoints → OCR text search: calls search
- OCR text search → PDF and JSON files: scans JSON caches
- OCR text search → PDF document: deserializes documents
- OCR text search → Search match: builds matches
- OCR text search → Grouped results: groups matches
