# sxxdgaf/doc_scanner architecture

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

- Interactive diagram: https://gitdiagram.com/sxxdgaf/doc_scanner
- Repository: https://github.com/sxxdgaf/doc_scanner

## Overview

DocScanner is an offline Flutter document-scanning and PDF-creation app. Its principal workflow is to capture one or more pages, correct and enhance them, then organize the saved scans or create a PDF; users can also extract text with local OCR. The README documents these capabilities and the Clean Architecture layers, while the supplied source excerpts cover only native launch scaffolding. Feature-to-layer connections below therefore cite the README rather than implying Dart calls were inspected.

Main entry points: [`lib/features/scanner/presentation/screens/camera_screen.dart`](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/screens/camera_screen.dart) (Camera Capture), [`lib/features/home/presentation/screens/home_screen.dart`](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/screens/home_screen.dart) (Document Home), [`lib/features/editor/presentation/screens/editor_screen.dart`](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/editor/presentation/screens/editor_screen.dart) (Page Editor), [`lib/data/repositories/document_repository_impl.dart`](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/document_repository_impl.dart) (Document Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Scanning"]
  node_camera["Camera Capture<br/>[camera_screen.dart]"]
  node_detection["Edge Detection"]
  node_controls["Capture Controls"]
end

subgraph group_editing["Image Editing"]
  node_editor["Page Editor<br/>[editor_screen.dart]"]
  node_filters["Image Filters<br/>[filter_screen.dart]"]
end

subgraph group_library["Document Library"]
  node_home["Document Home<br/>[home_screen.dart]"]
  node_document_card["Document Cards<br/>[document_card.dart]"]
  node_empty_state["Empty Library<br/>[empty_state.dart]"]
  node_folders["Folder Storage"]
  node_document_repo["Document Storage"]
  node_database[("Local SQLite")]
end

subgraph group_output["Export and OCR"]
  node_pdf["PDF Preview"]
  node_pdf_repo["PDF Generation"]
  node_ocr_screen["OCR Screen<br/>[ocr_screen.dart]"]
  node_ocr_repo["Local OCR"]
end

subgraph group_architecture["Application Layers"]
  node_image_usecases["Image Use Cases"]
  node_image_repo["Image Processing"]
  node_document_usecases["Document Use Cases"]
end

node_user(("Scanner User"))

node_user -->|"starts scan"| node_camera
node_camera -->|"detects edges"| node_detection
node_camera -.->|"offers capture"| node_controls
node_camera -.->|"sends scans"| node_editor
node_editor -->|"adjusts pages"| node_filters
node_editor -.->|"requests processing"| node_image_usecases
node_image_usecases -.->|"delegates processing"| node_image_repo
node_user -->|"opens library"| node_home
node_home -.->|"shows documents"| node_document_card
node_home -.->|"shows empty state"| node_empty_state
node_home -.->|"requests documents"| node_document_usecases
node_document_usecases -.->|"delegates storage"| node_document_repo
node_document_repo -.->|"stores documents"| node_database
node_folders -.->|"stores folders"| node_database
node_user -->|"previews PDF"| node_pdf
node_pdf -.->|"creates PDF"| node_pdf_repo
node_user -->|"requests text"| node_ocr_screen
node_ocr_screen -.->|"recognizes text"| node_ocr_repo

click node_camera "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/screens/camera_screen.dart"
click node_detection "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/widgets/document_detector_overlay.dart"
click node_controls "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/widgets/camera_controls.dart"
click node_editor "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/editor/presentation/screens/editor_screen.dart"
click node_filters "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/editor/presentation/screens/filter_screen.dart"
click node_image_usecases "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/domain/usecases/image_processing_usecases.dart"
click node_image_repo "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/image_processing_repository_impl.dart"
click node_home "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/screens/home_screen.dart"
click node_document_card "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/widgets/document_card.dart"
click node_empty_state "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/widgets/empty_state.dart"
click node_folders "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/folder_repository_impl.dart"
click node_document_repo "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/document_repository_impl.dart"
click node_database "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/local_db/database_helper.dart"
click node_document_usecases "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/domain/usecases/document_usecases.dart"
click node_pdf "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/pdf_viewer/presentation/screens/pdf_preview_screen.dart"
click node_pdf_repo "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/pdf_repository_impl.dart"
click node_ocr_screen "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/ocr/presentation/screens/ocr_screen.dart"
click node_ocr_repo "https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/ocr_repository_impl.dart"

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_camera,node_detection,node_controls,node_user toneBlue
class node_editor,node_filters toneAmber
class node_home,node_document_card,node_empty_state,node_folders,node_document_repo,node_database toneMint
class node_pdf,node_pdf_repo,node_ocr_screen,node_ocr_repo toneRose
class node_image_usecases,node_image_repo,node_document_usecases toneIndigo
```

## Components

### Scanning

- [Camera Capture](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/screens/camera_screen.dart): `lib/features/scanner/presentation/screens/camera_screen.dart`
- [Edge Detection](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/widgets/document_detector_overlay.dart): `lib/features/scanner/presentation/widgets/document_detector_overlay.dart`
- [Capture Controls](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/scanner/presentation/widgets/camera_controls.dart): `lib/features/scanner/presentation/widgets/camera_controls.dart`

### Image Editing

- [Page Editor](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/editor/presentation/screens/editor_screen.dart): `lib/features/editor/presentation/screens/editor_screen.dart`
- [Image Filters](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/editor/presentation/screens/filter_screen.dart): `lib/features/editor/presentation/screens/filter_screen.dart`

### Document Library

- [Document Home](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/screens/home_screen.dart): `lib/features/home/presentation/screens/home_screen.dart`
- [Document Cards](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/widgets/document_card.dart): `lib/features/home/presentation/widgets/document_card.dart`
- [Empty Library](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/home/presentation/widgets/empty_state.dart): `lib/features/home/presentation/widgets/empty_state.dart`
- [Folder Storage](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/folder_repository_impl.dart): `lib/data/repositories/folder_repository_impl.dart`
- [Document Storage](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/document_repository_impl.dart): `lib/data/repositories/document_repository_impl.dart`
- [Local SQLite](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/local_db/database_helper.dart): `lib/data/local_db/database_helper.dart`

### Export and OCR

- [PDF Preview](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/pdf_viewer/presentation/screens/pdf_preview_screen.dart): `lib/features/pdf_viewer/presentation/screens/pdf_preview_screen.dart`
- [PDF Generation](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/pdf_repository_impl.dart): `lib/data/repositories/pdf_repository_impl.dart`
- [OCR Screen](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/features/ocr/presentation/screens/ocr_screen.dart): `lib/features/ocr/presentation/screens/ocr_screen.dart`
- [Local OCR](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/ocr_repository_impl.dart): `lib/data/repositories/ocr_repository_impl.dart`

### Application Layers

- [Image Use Cases](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/domain/usecases/image_processing_usecases.dart): `lib/domain/usecases/image_processing_usecases.dart`
- [Image Processing](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/data/repositories/image_processing_repository_impl.dart): `lib/data/repositories/image_processing_repository_impl.dart`
- [Document Use Cases](https://github.com/sxxdgaf/doc_scanner/blob/master/lib/domain/usecases/document_usecases.dart): `lib/domain/usecases/document_usecases.dart`

### Other components

- **Scanner User**

## Connections

- Scanner User → Camera Capture: starts scan (evidence: `README.md`)
- Camera Capture → Edge Detection: detects edges (evidence: `README.md`)
- Camera Capture → Capture Controls: offers capture
- Camera Capture → Page Editor: sends scans
- Page Editor → Image Filters: adjusts pages (evidence: `README.md`)
- Page Editor → Image Use Cases: requests processing
- Image Use Cases → Image Processing: delegates processing
- Scanner User → Document Home: opens library (evidence: `README.md`)
- Document Home → Document Cards: shows documents
- Document Home → Empty Library: shows empty state
- Document Home → Document Use Cases: requests documents
- Document Use Cases → Document Storage: delegates storage
- Document Storage → Local SQLite: stores documents
- Folder Storage → Local SQLite: stores folders
- Scanner User → PDF Preview: previews PDF (evidence: `README.md`)
- PDF Preview → PDF Generation: creates PDF
- Scanner User → OCR Screen: requests text (evidence: `README.md`)
- OCR Screen → Local OCR: recognizes text
