# nifras7/verilens architecture

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

- Interactive diagram: https://gitdiagram.com/nifras7/verilens
- Repository: https://github.com/nifras7/verilens

## Overview

#### Purpose and Execution Targets
VeriLens is a local-first forensic verification and metadata-sanitization application for images, PDFs, DOCX, and text. It runs analysis in the browser/device without a backend or cloud APIs. Web startup is `src/main.tsx`; application composition and routing are `src/app/App.tsx` and `src/app/routes.tsx`. The same web bundle is packaged as an Android Capacitor app via `capacitor.config.ts` and `android/app/src/main/java/com/verilens/app/MainActivity.java`.

#### UI Workflow and Route Boundary
Route-level pages orchestrate user workflows: file intake/analysis, results, cleaning, original-vs-copy comparison, and local history. Shared presentation components render reports rather than perform forensic parsing. Key paths: `src/pages/Analyze.tsx`, `src/pages/Results.tsx`, `src/pages/Cleaning.tsx`, `src/pages/Compare.tsx`, `src/components/file/FileDropzone.tsx`.

#### Analysis Orchestrator
The analyzer service is the central dispatch boundary: it selects format-specific analysis and consolidates results into typed forensic reports. The UI consumes this through analysis state/hooks, keeping browser-file handling and report presentation separate. Key paths: `src/services/analyzer/analyzer.ts`, `src/hooks/useFileAnalysis.ts`, `src/types/analysis.ts`, `src/types/file.ts`.

#### Format-Specific Evidence Extraction
File-type analyzers inspect distinct containers and content characteristics: image metadata/artifacts, PDF document structure, DOCX OOXML metadata, and text encoding/invisible-character signals. Metadata extraction is separated by format, enabling evidence to feed a shared report model. Key paths: `src/services/analyzer/imageAnalyzer.ts`, `src/services/analyzer/pdfAnalyzer.ts`, `src/services/analyzer/docxAnalyzer.ts`, `src/services/metadata/imageMetadata.ts`, `src/services/metadata/pdfMetadata.ts`, `src/services/metadata/docxMetadata.ts`.

#### Integrity, Provenance, and Transformation Signals
Independent signals include SHA-256 file identity, C2PA/JUMBF detection and validation, and image transformation/re-encoding indicators. A conclusion engine synthesizes evidence into an honest report; C2PA absence is a provenance-availability result, not a synthetic-content claim. Key paths: `src/services/hashing/sha256.ts`, `src/services/c2pa/detector.ts`, `src/services/c2pa/validator.ts`, `src/services/analyzer/transformationAnalyzer.ts`, `src/services/analyzer/conclusionEngine.ts`.

#### Baselines, Comparison, and Local Persistence
Users can register original-file evidence locally, then compare received copies for hash, dimensions, provenance, metadata, and transformation differences. Scan history and registered originals are browser-local persistence boundaries, with no server synchronization. Key paths: `src/services/analyzer/comparisonEngine.ts`, `src/services/storage/registeredOriginals.ts`, `src/services/storage/localHistory.ts`, `src/hooks/useHistory.ts`.

#### Sanitization and Verified Output
Cleaning services produce a new output rather than overwrite the source: images are re-encoded, while PDF/DOCX/text cleaners remove relevant metadata or content traces. The cleaned buffer can re-enter analysis to verify removal, and download is isolated at the browser output boundary. Key paths: `src/services/cleaning/imageCleaner.ts`, `src/services/cleaning/pdfCleaner.ts`, `src/services/cleaning/docxCleaner.ts`, `src/services/cleaning/textCleaner.ts`, `src/utils/fileDownloader.ts`.

#### Runtime and Infrastructure
Primary runtime: React + TypeScript built by Vite, using browser APIs such as Web Crypto, `ArrayBuffer`, and Canvas for in-memory processing. Deployment can use Netlify (`netlify.toml`, `public/_redirects`). Mobile delivery uses Capacitor and the Android Gradle project (`android/app/build.gradle`, `android/app/src/main/AndroidManifest.xml`). There is intentionally no application backend, database, telemetry, or external forensic service.

Main entry points: [`src/pages/Analyze.tsx`](https://github.com/nifras7/verilens/blob/version-2/src/pages/Analyze.tsx) (Workflow pages), [`src/services/analyzer/analyzer.ts`](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/analyzer.ts) (Analysis orchestrator), [`src/hooks/useFileAnalysis.ts`](https://github.com/nifras7/verilens/blob/version-2/src/hooks/useFileAnalysis.ts) (Analysis state), [`src/services/cleaning/imageCleaner.ts`](https://github.com/nifras7/verilens/blob/version-2/src/services/cleaning/imageCleaner.ts) (Sanitization services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web UI"]
  node_web_startup["Web startup<br/>React entry<br/>[main.tsx]"]
  node_app_routes["App routing<br/>React composition<br/>[App.tsx]"]
  node_workflow_pages["Workflow pages<br/>route pages<br/>[Analyze.tsx]"]
  node_file_intake["File intake<br/>shared component<br/>[FileDropzone.tsx]"]
  node_analysis_hook["Analysis state<br/>React hook<br/>[useFileAnalysis.ts]"]
end

subgraph group_analysis["Forensic analysis"]
  node_analyzer{{"Analysis orchestrator<br/>[analyzer.ts]"}}
  node_report_types["Forensic report model<br/>TypeScript types<br/>[analysis.ts]"]
  node_format_analyzers["Format analyzers<br/>format services<br/>[imageAnalyzer.ts]"]
  node_metadata_extractors["Metadata extractors<br/>format services<br/>[imageMetadata.ts]"]
  node_integrity_signals["Integrity &amp; provenance<br/>evidence services<br/>[sha256.ts]"]
  node_transformation_signals["Transformation signals<br/>image analysis"]
  node_conclusion_engine{{"Conclusion engine<br/>report synthesis"}}
  node_comparison_engine["Comparison engine"]
end

subgraph group_local["Local records &amp; output"]
  node_cleaners["Sanitization services<br/>format cleaners<br/>[imageCleaner.ts]"]
  node_verified_output["Verified download<br/>browser output<br/>[fileDownloader.ts]"]
  node_registered_originals[("Registered originals<br/>browser-local storage")]
  node_local_history[("Local scan history<br/>browser-local storage<br/>[localHistory.ts]")]
end

subgraph group_delivery["Delivery targets"]
  node_vite_bundle["Vite web bundle<br/>browser runtime"]
  node_capacitor_android["Capacitor Android host<br/>mobile runtime"]
end

node_web_startup -->|"mounts"| node_app_routes
node_app_routes -->|"routes to"| node_workflow_pages
node_workflow_pages -->|"accepts files"| node_file_intake
node_workflow_pages -->|"uses"| node_analysis_hook
node_analysis_hook -->|"submits browser files"| node_analyzer
node_analyzer -->|"dispatches by format"| node_format_analyzers
node_format_analyzers -->|"extracts metadata"| node_metadata_extractors
node_analyzer -->|"collects identity/provenance"| node_integrity_signals
node_analyzer -->|"collects image signals"| node_transformation_signals
node_analyzer -->|"sends evidence"| node_conclusion_engine
node_conclusion_engine -->|"produces"| node_report_types
node_analysis_hook -->|"supplies reports"| node_workflow_pages
node_workflow_pages -->|"compares copies"| node_comparison_engine
node_comparison_engine -->|"reads baselines"| node_registered_originals
node_workflow_pages -->|"registers originals"| node_registered_originals
node_analysis_hook -->|"records scans"| node_local_history
node_workflow_pages -->|"requests clean output"| node_cleaners
node_cleaners -.->|"re-enters for verification"| node_analyzer
node_cleaners -->|"emits cleaned buffer"| node_verified_output
node_web_startup -->|"built into"| node_vite_bundle
node_vite_bundle -->|"packaged by"| node_capacitor_android

click node_web_startup "https://github.com/nifras7/verilens/blob/version-2/src/main.tsx"
click node_app_routes "https://github.com/nifras7/verilens/blob/version-2/src/app/App.tsx"
click node_workflow_pages "https://github.com/nifras7/verilens/blob/version-2/src/pages/Analyze.tsx"
click node_file_intake "https://github.com/nifras7/verilens/blob/version-2/src/components/file/FileDropzone.tsx"
click node_analysis_hook "https://github.com/nifras7/verilens/blob/version-2/src/hooks/useFileAnalysis.ts"
click node_analyzer "https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/analyzer.ts"
click node_report_types "https://github.com/nifras7/verilens/blob/version-2/src/types/analysis.ts"
click node_format_analyzers "https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/imageAnalyzer.ts"
click node_metadata_extractors "https://github.com/nifras7/verilens/blob/version-2/src/services/metadata/imageMetadata.ts"
click node_integrity_signals "https://github.com/nifras7/verilens/blob/version-2/src/services/hashing/sha256.ts"
click node_transformation_signals "https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/transformationAnalyzer.ts"
click node_conclusion_engine "https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/conclusionEngine.ts"
click node_comparison_engine "https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/comparisonEngine.ts"
click node_cleaners "https://github.com/nifras7/verilens/blob/version-2/src/services/cleaning/imageCleaner.ts"
click node_verified_output "https://github.com/nifras7/verilens/blob/version-2/src/utils/fileDownloader.ts"
click node_registered_originals "https://github.com/nifras7/verilens/blob/version-2/src/services/storage/registeredOriginals.ts"
click node_local_history "https://github.com/nifras7/verilens/blob/version-2/src/services/storage/localHistory.ts"
click node_capacitor_android "https://github.com/nifras7/verilens/blob/version-2/capacitor.config.ts"

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_web_startup,node_app_routes,node_workflow_pages,node_file_intake,node_analysis_hook toneBlue
class node_analyzer,node_report_types,node_format_analyzers,node_metadata_extractors,node_integrity_signals,node_transformation_signals,node_conclusion_engine,node_comparison_engine toneAmber
class node_cleaners,node_verified_output,node_registered_originals,node_local_history toneMint
class node_vite_bundle,node_capacitor_android toneRose
```

## Components

### Web UI

React workflow and route layer.

- [Web startup](https://github.com/nifras7/verilens/blob/version-2/src/main.tsx): React entry · `src/main.tsx`
- [App routing](https://github.com/nifras7/verilens/blob/version-2/src/app/App.tsx): React composition · `src/app/App.tsx`
- [Workflow pages](https://github.com/nifras7/verilens/blob/version-2/src/pages/Analyze.tsx): route pages · Analysis, results, cleaning, comparison, and history workflows. · `src/pages/Analyze.tsx`
- [File intake](https://github.com/nifras7/verilens/blob/version-2/src/components/file/FileDropzone.tsx): shared component · `src/components/file/FileDropzone.tsx`
- [Analysis state](https://github.com/nifras7/verilens/blob/version-2/src/hooks/useFileAnalysis.ts): React hook · `src/hooks/useFileAnalysis.ts`

### Forensic analysis

In-browser evidence extraction and reporting.

- [Analysis orchestrator](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/analyzer.ts): service · Dispatches format analysis and consolidates typed reports. · `src/services/analyzer/analyzer.ts`
- [Forensic report model](https://github.com/nifras7/verilens/blob/version-2/src/types/analysis.ts): TypeScript types · `src/types/analysis.ts`
- [Format analyzers](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/imageAnalyzer.ts): format services · Image, PDF, DOCX, and text container/content analysis. · `src/services/analyzer/imageAnalyzer.ts`
- [Metadata extractors](https://github.com/nifras7/verilens/blob/version-2/src/services/metadata/imageMetadata.ts): format services · Format-specific metadata evidence extraction. · `src/services/metadata/imageMetadata.ts`
- [Integrity & provenance](https://github.com/nifras7/verilens/blob/version-2/src/services/hashing/sha256.ts): evidence services · SHA-256 identity plus C2PA/JUMBF detection and validation. · `src/services/hashing/sha256.ts`
- [Transformation signals](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/transformationAnalyzer.ts): image analysis · Detects re-encoding and transformation indicators. · `src/services/analyzer/transformationAnalyzer.ts`
- [Conclusion engine](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/conclusionEngine.ts): report synthesis · Synthesizes evidence without treating absent C2PA as a synthetic-content claim. · `src/services/analyzer/conclusionEngine.ts`
- [Comparison engine](https://github.com/nifras7/verilens/blob/version-2/src/services/analyzer/comparisonEngine.ts): service · Compares copies against registered original evidence. · `src/services/analyzer/comparisonEngine.ts`

### Local records & output

Browser-local baselines, history, and files.

- [Sanitization services](https://github.com/nifras7/verilens/blob/version-2/src/services/cleaning/imageCleaner.ts): format cleaners · Creates cleaned image, PDF, DOCX, or text output. · `src/services/cleaning/imageCleaner.ts`
- [Verified download](https://github.com/nifras7/verilens/blob/version-2/src/utils/fileDownloader.ts): browser output · Cleaned buffers can be re-analyzed before download. · `src/utils/fileDownloader.ts`
- [Registered originals](https://github.com/nifras7/verilens/blob/version-2/src/services/storage/registeredOriginals.ts): browser-local storage · `src/services/storage/registeredOriginals.ts`
- [Local scan history](https://github.com/nifras7/verilens/blob/version-2/src/services/storage/localHistory.ts): browser-local storage · No server synchronization. · `src/services/storage/localHistory.ts`

### Delivery targets

Web bundle and Android packaging.

- **Vite web bundle**: browser runtime · Uses browser APIs for in-memory processing.
- [Capacitor Android host](https://github.com/nifras7/verilens/blob/version-2/capacitor.config.ts): mobile runtime · Packages the same web bundle as an Android app. · `capacitor.config.ts`

## Connections

- Web startup → App routing: mounts
- App routing → Workflow pages: routes to
- Workflow pages → File intake: accepts files
- Workflow pages → Analysis state: uses
- Analysis state → Analysis orchestrator: submits browser files
- Analysis orchestrator → Format analyzers: dispatches by format
- Format analyzers → Metadata extractors: extracts metadata
- Analysis orchestrator → Integrity & provenance: collects identity/provenance
- Analysis orchestrator → Transformation signals: collects image signals
- Analysis orchestrator → Conclusion engine: sends evidence
- Conclusion engine → Forensic report model: produces
- Analysis state → Workflow pages: supplies reports
- Workflow pages → Comparison engine: compares copies
- Comparison engine → Registered originals: reads baselines
- Workflow pages → Registered originals: registers originals
- Analysis state → Local scan history: records scans
- Workflow pages → Sanitization services: requests clean output
- Sanitization services → Analysis orchestrator: re-enters for verification
- Sanitization services → Verified download: emits cleaned buffer
- Web startup → Vite web bundle: built into
- Vite web bundle → Capacitor Android host: packaged by
