# rudraop9/ai-qr-scanner architecture

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

- Interactive diagram: https://gitdiagram.com/rudraop9/ai-qr-scanner
- Repository: https://github.com/rudraop9/ai-qr-scanner

## Overview

##### Project Type and Purpose
- This is a native Android application (“Ai Qr Scanner”) whose sole purpose is to scan and parse QR/bar codes on the device—no external servers or back‑end systems are involved.

##### File Structure
- Top‑level “app” module: contains all code, resources, and Gradle config.
- src/main/java/com/leo/qrscanner:
- MainActivity.java (launch/UI entry)
- showData.kt (secondary UI)
- workers/Helpers.kt, ShowDataFormat.kt, checkModule.java (business‑logic/data‑processing components)
- workers/recycler/ShowDataAdapter.kt (RecyclerView adapter for results)
- src/main/res: XML layouts (activity_main.xml, activity_show_data.xml, custom dialogs), drawables, values (strings, themes), xml rules for data extraction.

##### README
- Lightweight, permission‑free, millisecond response, interactive UI.
- No mention of remote services—purely on‑device scanning.

##### Main Components & Their Interactions
a. Main Components
- Device & Android OS (Camera API, UI framework)
- App UI Layer (MainActivity → showData.kt activity)
- Scanning/Extraction Module (worker classes + data_extraction_rules.xml)
- Data Processing/Formatting (ShowDataFormat, Helpers, checkModule)
- Presentation Layer (ShowDataAdapter + RecyclerView in UI)
- Resource Store (layouts, drawables, strings)
b. Relationships & Data Flow
1. UI (MainActivity) invokes Camera capture
2. Captured image passed to Scanning Module
3. Raw barcode/QR data flows into Processing Module
4. Processed/Formatted data handed to Presentation Layer
5. RecyclerView (via ShowDataAdapter) displays results in ShowDataActivity
6. User actions (copy/share) use Android Intents (future enhancement)
c. Architectural Patterns
- Layered separation: UI vs. business logic vs. data adapters vs. resources
- Single‑activity or multi‑activity flow (MainActivity → ShowDataActivity)
d. Key Technologies & Libraries
- Android Camera/CameraX or ZXing/ML Kit (in dependencies)
- Kotlin + Java interoperability
- RecyclerView for list presentation
- XML for layouts, drawable/vector assets, extraction rules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% App Container
    subgraph "Ai Qr Scanner App"
        direction TB

        %% UI Layer
        subgraph "UI Layer"
            direction TB
            MainActivity["MainActivity"]:::ui
            ShowDataActivity["ShowDataActivity"]:::ui
        end

        %% Scanning Module
        subgraph "Scanning Module"
            direction TB
            CheckModule["checkModule"]:::logic
        end

        %% Processing Module
        subgraph "Processing Module"
            direction TB
            Helpers["Helpers"]:::logic
            ShowDataFormat["ShowDataFormat"]:::logic
        end

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            ShowDataAdapter["ShowDataAdapter"]:::logic
        end

        %% Resource Store
        subgraph "Resource Store"
            direction TB
            Layouts["Layouts"]:::resource
            DrawableAssets["Drawable Assets"]:::resource
            UIStringsThemes["Strings & Themes"]:::resource
            ExtractionRules["data_extraction_rules.xml"]:::resource
            BackupRules["backup_rules.xml"]:::resource
        end
    end

    %% OS Layer
    AndroidOS["Android OS & Hardware\n(Camera API, UI Framework)"]:::os

    %% Data Flows
    MainActivity -->|"image stream"| CheckModule
    CheckModule -->|"raw code data"| ShowDataFormat
    ShowDataFormat -->|"formatted text list"| ShowDataAdapter
    ShowDataAdapter -->|"display via RecyclerView"| ShowDataActivity
    MainActivity -->|"launch ShowDataActivity"| ShowDataActivity

    %% Resource Dependencies
    ExtractionRules -->|"uses rules"| CheckModule
    Layouts -->|"UI definitions"| MainActivity
    Layouts -->|"UI definitions"| ShowDataActivity
    UIStringsThemes -->|"text & themes"| MainActivity
    UIStringsThemes -->|"text & themes"| ShowDataActivity
    DrawableAssets -->|"icons & graphics"| MainActivity
    DrawableAssets -->|"icons & graphics"| ShowDataActivity

    %% OS Interactions
    AndroidOS -->|"provides camera & UI APIs"| MainActivity
    AndroidOS -->|"provides camera & UI APIs"| CheckModule

    %% Click Events
    click MainActivity "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/MainActivity.java"
    click ShowDataActivity "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/showData.kt"
    click CheckModule "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/workers/checkModule.java"
    click ExtractionRules "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/res/xml/data_extraction_rules.xml"
    click Helpers "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/workers/Helpers.kt"
    click ShowDataFormat "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/workers/ShowDataFormat.kt"
    click ShowDataAdapter "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/java/com/leo/qrscanner/workers/recycler/ShowDataAdapter.kt"
    click Layouts "https://github.com/rudraop9/ai-qr-scanner/tree/master/app/src/main/res/layout"
    click DrawableAssets "https://github.com/rudraop9/ai-qr-scanner/tree/master/app/src/main/res/drawable"
    click UIStringsThemes "https://github.com/rudraop9/ai-qr-scanner/tree/master/app/src/main/res/values"
    click BackupRules "https://github.com/rudraop9/ai-qr-scanner/blob/master/app/src/main/res/xml/backup_rules.xml"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef resource fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef os fill:#D3D3D3,stroke:#333,stroke-width:1px
```
