# binishmatheww/scanner architecture

> Architecture diagram of the GitHub repository binishmatheww/scanner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/binishmatheww/scanner
- Repository: https://github.com/binishmatheww/scanner

## Overview

##### Main Components

a. User Interface Layer:
- Compose UI Components (under views/composables)
- Traditional XML Layouts (under res/layout)
- Fragments for different screens
- Activity as the main container (LauncherActivity)

b. Business Logic Layer:
- ViewModels (CameraViewModel, HomeViewModel, PdfEditorViewModel)
- PDF Processing Components (PdfEditor, Scanner)
- Utility Components (ExifReader, FileExtensions)

c. Data/Model Layer:
- Models (PdfFile)
- File System Integration
- Camera Integration

##### Key Architectural Elements

**┌─ UI Layer ─────────────────┐**
- ┌─ Fragments ────────────┐ │
- HomeFragment          │ │
- CameraFragment        │ │
- PdfEditorFragment     │ │
- OcrFragment           │ │
- PerspectiveCorrection │ │
- ┘ │
- ┌─ Composables ─────────┐ │
- PdfPageLayout        │ │
- Dialogs             │ │
- ┘ │
- ┬──────────┘

**┌──────────────▼──────────┐**
- ViewModel Layer       │
- CameraViewModel        │
- HomeViewModel          │
- PdfEditorViewModel     │
- ┬──────────┘

**┌──────────────▼──────────┐**
- Business Logic       │
- PdfEditor             │
- Scanner               │
- Utilities             │
- ┬──────────┘

**┌──────────────▼──────────┐**
- Data Layer          │
- PdfFile Model         │
- File System Access    │
- Camera Integration    │
- ┘

##### Important Relationships to Highlight

- Navigation flow between fragments (using navigation_graph.xml)
- Data flow from Camera to PDF processing
- PDF manipulation operations
- File system interactions

##### External Dependencies

- iText Library integration
- Android Camera API
- File System API
- OCR functionality

##### Additional Elements

- Permission handling
- File storage locations
- Error handling flow
- User interaction paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef viewmodel fill:#2ecc71,stroke:#27ae60,color:white
    classDef business fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    
    %% UI Layer
    subgraph UI
        LA["LauncherActivity"]
        
        subgraph Fragments
            HF["HomeFragment"]
            CF["CameraFragment"]
            PEF["PdfEditorFragment"]
            OF["OcrFragment"]
            PCF["PerspectiveCorrectionFragment"]
        end
        
        subgraph Composables
            PPL["PdfPageLayout"]
            DLG["Dialogs"]
        end
    end
    
    %% ViewModel Layer
    subgraph ViewModels
        CVM["CameraViewModel"]
        HVM["HomeViewModel"]
        PEVM["PdfEditorViewModel"]
    end
    
    %% Business Logic Layer
    subgraph BusinessLogic
        PE["PdfEditor"]
        SC["Scanner"]
        UT["Utilities"]
    end
    
    %% Data Layer
    subgraph Data
        PFM["PdfFile Model"]
        FSA["File System Access"]
        CI["Camera Integration"]
    end
    
    %% Relationships
    LA --> HF
    LA --> CF
    LA --> PEF
    LA --> OF
    LA --> PCF
    
    HF --> HVM
    CF --> CVM
    PEF --> PEVM
    
    CVM --> SC
    CVM --> CI
    
    PEVM --> PE
    PEVM --> FSA
    
    HVM --> PFM
    HVM --> FSA
    
    PE --> PFM
    SC --> PFM
    
    %% Click Events
    click LA "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/LauncherActivity.kt"
    click HF "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/fragments/HomeFragment.kt"
    click CF "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/fragments/CameraFragment.kt"
    click PEF "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/fragments/PdfEditorFragment.kt"
    click OF "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/fragments/OcrFragment.kt"
    click PCF "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/fragments/PerspectiveCorrectionFragment.kt"
    click PPL "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/views/composables/PdfPageLayout.kt"
    click DLG "https://github.com/binishmatheww/scanner/tree/main/app/src/main/java/com/binishmatheww/scanner/views/composables/dialogs/"
    click CVM "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/viewmodels/CameraViewModel.kt"
    click HVM "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/viewmodels/HomeViewModel.kt"
    click PEVM "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/viewmodels/PdfEditorViewModel.kt"
    click PE "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/common/PdfEditor.kt"
    click SC "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/common/Scanner.kt"
    click UT "https://github.com/binishmatheww/scanner/tree/main/app/src/main/java/com/binishmatheww/scanner/common/utils/"
    click PFM "https://github.com/binishmatheww/scanner/blob/main/app/src/main/java/com/binishmatheww/scanner/models/PdfFile.kt"
    
    %% Apply styles
    class LA,HF,CF,PEF,OF,PCF,PPL,DLG ui
    class CVM,HVM,PEVM viewmodel
    class PE,SC,UT business
    class PFM,FSA,CI data
```
