# patelakshar/lt2 architecture

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

- Interactive diagram: https://gitdiagram.com/patelakshar/lt2
- Repository: https://github.com/patelakshar/lt2

## Overview

PdfSolverMvc is an ASP.NET Core application for uploading engineering PDFs, extracting digital or scanned tables and datasheets, preserving strikethrough revisions and embedded images, then reviewing, correcting, and exporting results. The main flow runs from browser upload through controller-managed extraction and persistence to a details grid or CSV/XLSX output. The README documents four extraction modes and optional Gemini/Ollama paths; sampled code confirms key extraction, OCR, correction, and storage relationships. Some controller and extraction excerpts are incomplete, so unshown wiring is omitted.

Main entry points: [`PdfSolverMvc/Controllers/PdfController.cs`](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Controllers/PdfController.cs) (PDF controller), [`PdfSolverMvc/Services/PdfExtractionService.cs`](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfExtractionService.cs) (Extraction orchestrator), [`PdfSolverMvc/Services/ExportService.cs`](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExportService.cs) (Export service), [`PdfSolverMvc/Data/AppDbContext.cs`](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Data/AppDbContext.cs) (SQLite context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflow"]
  node_controller["PDF controller<br/>[PdfController.cs]"]
  node_uploadui["Upload page<br/>[Upload.cshtml]"]
  node_detailsui["Details grid<br/>[Details.cshtml]"]
  node_registryui["Registry list<br/>[Index.cshtml]"]
end

subgraph group_extract["Extraction engines"]
  node_extractor["Extraction orchestrator"]
  node_pdfpiggrid["PDF grid reader"]
  node_datasheet["Datasheet reader"]
  node_gridselect["Grid selection"]
  node_strikes["Strike detection"]
  node_paddle["Local OCR"]
  node_opencv["Scan verification"]
  node_gemini["Gemini extraction<br/>[GeminiService.cs]"]
  node_ollama["Local vision model"]
end

subgraph group_quality["Review and correction"]
  node_correction["Correction memory"]
  node_progress["Extraction progress"]
end

subgraph group_data["Persistence and exports"]
  node_records["PDF records"]
  node_database[("SQLite context<br/>[AppDbContext.cs]")]
  node_export["Export service<br/>[ExportService.cs]"]
  node_csv["CSV exporter"]
  node_excel["Excel exporter"]
end

node_user(("Browser user"))

node_user -->|"opens upload"| node_uploadui
node_uploadui -->|"submits PDF"| node_controller
node_controller -->|"starts extraction"| node_extractor
node_extractor -->|"selects grid reader"| node_gridselect
node_gridselect -->|"delegates grids"| node_pdfpiggrid
node_pdfpiggrid -->|"uses datasheet logic"| node_datasheet
node_extractor -->|"detects revisions"| node_strikes
node_extractor -->|"runs scanned OCR"| node_paddle
node_paddle -->|"analyzes scans"| node_opencv
node_extractor -->|"requests AI fallback"| node_gemini
node_extractor -->|"requests local AI"| node_ollama
node_controller -->|"updates job status"| node_progress
node_extractor -.->|"reports progress"| node_progress
node_controller -->|"loads and saves"| node_database
node_database -->|"stores records"| node_records
node_controller -->|"applies corrections"| node_correction
node_correction -->|"reads rules"| node_database
node_controller -->|"renders details"| node_detailsui
node_controller -->|"renders registry"| node_registryui
node_controller -->|"requests exports"| node_export
node_export -->|"delegates CSV"| node_csv
node_controller -->|"creates XLSX"| node_excel
node_export -.->|"provides workbook logic"| node_excel

click node_controller "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Controllers/PdfController.cs"
click node_uploadui "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Upload.cshtml"
click node_detailsui "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Details.cshtml"
click node_registryui "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Index.cshtml"
click node_extractor "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfExtractionService.cs"
click node_pdfpiggrid "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfPigGridExtractor.cs"
click node_datasheet "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfDatasheetExtractor.cs"
click node_gridselect "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfGridExtractor.cs"
click node_strikes "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfPigStrikethroughService.cs"
click node_paddle "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PaddleLocalService.cs"
click node_opencv "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/OpenCvVerificationService.cs"
click node_gemini "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/GeminiService.cs"
click node_ollama "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/LocalLlmVlmService.cs"
click node_correction "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/CorrectionMemoryService.cs"
click node_progress "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExtractionProgressTracker.cs"
click node_records "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Models/PdfDocumentRecord.cs"
click node_database "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Data/AppDbContext.cs"
click node_export "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExportService.cs"
click node_csv "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/CsvExportService.cs"
click node_excel "https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExcelExportService.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_controller,node_uploadui,node_detailsui,node_registryui,node_user toneBlue
class node_extractor,node_pdfpiggrid,node_datasheet,node_gridselect,node_strikes,node_paddle,node_opencv,node_gemini,node_ollama toneAmber
class node_correction,node_progress toneMint
class node_records,node_database,node_export,node_csv,node_excel toneRose
```

## Components

### Web workflow

- [PDF controller](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Controllers/PdfController.cs): `PdfSolverMvc/Controllers/PdfController.cs`
- [Upload page](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Upload.cshtml): `PdfSolverMvc/Views/Pdf/Upload.cshtml`
- [Details grid](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Details.cshtml): `PdfSolverMvc/Views/Pdf/Details.cshtml`
- [Registry list](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Views/Pdf/Index.cshtml): `PdfSolverMvc/Views/Pdf/Index.cshtml`

### Extraction engines

- [Extraction orchestrator](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfExtractionService.cs): `PdfSolverMvc/Services/PdfExtractionService.cs`
- [PDF grid reader](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfPigGridExtractor.cs): `PdfSolverMvc/Services/PdfPigGridExtractor.cs`
- [Datasheet reader](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfDatasheetExtractor.cs): `PdfSolverMvc/Services/PdfDatasheetExtractor.cs`
- [Grid selection](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfGridExtractor.cs): `PdfSolverMvc/Services/PdfGridExtractor.cs`
- [Strike detection](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PdfPigStrikethroughService.cs): `PdfSolverMvc/Services/PdfPigStrikethroughService.cs`
- [Local OCR](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/PaddleLocalService.cs): `PdfSolverMvc/Services/PaddleLocalService.cs`
- [Scan verification](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/OpenCvVerificationService.cs): `PdfSolverMvc/Services/OpenCvVerificationService.cs`
- [Gemini extraction](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/GeminiService.cs): `PdfSolverMvc/Services/GeminiService.cs`
- [Local vision model](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/LocalLlmVlmService.cs): `PdfSolverMvc/Services/LocalLlmVlmService.cs`

### Review and correction

- [Correction memory](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/CorrectionMemoryService.cs): `PdfSolverMvc/Services/CorrectionMemoryService.cs`
- [Extraction progress](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExtractionProgressTracker.cs): `PdfSolverMvc/Services/ExtractionProgressTracker.cs`

### Persistence and exports

- [PDF records](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Models/PdfDocumentRecord.cs): `PdfSolverMvc/Models/PdfDocumentRecord.cs`
- [SQLite context](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Data/AppDbContext.cs): `PdfSolverMvc/Data/AppDbContext.cs`
- [Export service](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExportService.cs): `PdfSolverMvc/Services/ExportService.cs`
- [CSV exporter](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/CsvExportService.cs): `PdfSolverMvc/Services/CsvExportService.cs`
- [Excel exporter](https://github.com/patelakshar/lt2/blob/main/PdfSolverMvc/Services/ExcelExportService.cs): `PdfSolverMvc/Services/ExcelExportService.cs`

### Other components

- **Browser user**

## Connections

- Browser user → Upload page: opens upload (evidence: `README.md`)
- Upload page → PDF controller: submits PDF (evidence: `README.md`)
- PDF controller → Extraction orchestrator: starts extraction (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- Extraction orchestrator → Grid selection: selects grid reader (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- Grid selection → PDF grid reader: delegates grids (evidence: `PdfSolverMvc/Services/PdfGridExtractor.cs`)
- PDF grid reader → Datasheet reader: uses datasheet logic (evidence: `PdfSolverMvc/Services/PdfPigGridExtractor.cs`)
- Extraction orchestrator → Strike detection: detects revisions (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- Extraction orchestrator → Local OCR: runs scanned OCR (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- Local OCR → Scan verification: analyzes scans (evidence: `PdfSolverMvc/Services/PaddleLocalService.cs`)
- Extraction orchestrator → Gemini extraction: requests AI fallback (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- Extraction orchestrator → Local vision model: requests local AI (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- PDF controller → Extraction progress: updates job status (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- Extraction orchestrator → Extraction progress: reports progress (evidence: `PdfSolverMvc/Services/PdfExtractionService.cs`)
- PDF controller → SQLite context: loads and saves (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- SQLite context → PDF records: stores records (evidence: `PdfSolverMvc/Data/AppDbContext.cs`)
- PDF controller → Correction memory: applies corrections (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- Correction memory → SQLite context: reads rules (evidence: `PdfSolverMvc/Services/CorrectionMemoryService.cs`)
- PDF controller → Details grid: renders details (evidence: `README.md`)
- PDF controller → Registry list: renders registry (evidence: `README.md`)
- PDF controller → Export service: requests exports (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- Export service → CSV exporter: delegates CSV (evidence: `PdfSolverMvc/Services/ExportService.cs`)
- PDF controller → Excel exporter: creates XLSX (evidence: `PdfSolverMvc/Controllers/PdfController.cs`)
- Export service → Excel exporter: provides workbook logic (evidence: `PdfSolverMvc/Services/ExcelExportService.cs`)
