# andrewthe13th/inventory_kamera architecture

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

- Interactive diagram: https://gitdiagram.com/andrewthe13th/inventory_kamera
- Repository: https://github.com/andrewthe13th/inventory_kamera

## Overview

##### Project Type and Purpose
- This is a desktop Windows application built with C# (using Visual Studio) that performs OCR-based scanning of the Genshin Impact inventory. Its purpose is to capture screenshots of in-game inventory, parse various game items (characters, weapons, artifacts, etc.), and export the results in a JSON-based format (.GOOD) for use with other Genshin Impact tools.
- The README emphasizes its role as a “Genshin Data Scanner” that uses trained OCR models (see the tessdata folder) and integrates with external resources for updating lookup tables.

##### Main Components
a. User Interface (UI):
- WinForms UI components found in the “ui” folder.
- Main forms (MainForm, MainUI, ExecutablesForm) that handle user interactions, trigger scanning, and display results.
b. Data Processing / Scraping Module:
- This relates directly to the “scraping” directory. It contains specialized classes (e.g. ArtifactScraper, CharacterScraper, GenshinProcesor) that process screenshots and extract data using OCR.
- That these components interact with the OCR engine (indicated by the tessdata folder containing Tesseract training files).
c. Game Data and Business Logic:
- Encapsulated in the “data” and “game” directories. The “data” folder includes classes for managing database interactions (DatabaseManager, Inventory) as well as utility classes (OCRImageCollection, Rect).
- The “game” directory models in-game entities (Artifact, Character, Navigation, Weapon).
d. OCR Engine and Tessdata:
- Although not a separate code module, the “tessdata” folder contains the trained data used by the OCR routines in the scraping components. Indicate a dependency here, showing that the scraping module uses these resources to extract text.

##### Relationships and Interactions
- The UI layer acts as the entry point, providing controls for initiating scans. It then calls into the scraping module.
- The scraping module processes screenshots using the OCR engine (with tessdata as its resource) and extracts structured game data.
- Extracted information is passed to the data layer and business logic modules (“data”, “game”) that organize the results and prepare JSON exports.
- An “Export” component/function (triggered from the UI) takes the processed data and writes it to a file in the GOOD format.

##### Architectural Patterns and Design Principles
- The system is modular, with a clear separation between UI (presentation), data processing (scraping/OCR), and business logic (models and data management). This resembles an MVC-like separation even if loosely implemented.
- Components such as the scraping module and lookup table updater (as described in the README) hint at both loosely coupled modules and external integration with resources like the Anime Game Data Repo.

##### Key Points
- This approach will provide an accurate visual representation of how the Inventory Kamera application functions as a scanner that captures, processes, and exports Genshin Impact inventory data.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI_Main["MainForm"]:::ui
        UI_UI["MainUI"]:::ui
        UI_Exec["ExecutablesForm"]:::ui
    end

    %% Scraping / OCR Module
    subgraph "Scraping / OCR Module"
        SC1["ArtifactScraper"]:::processing
        SC2["CharacterScraper"]:::processing
        SC3["GenshinProcesor"]:::processing
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        subgraph "Data Management"
            DM1["DatabaseManager"]:::business
            DM2["Inventory"]:::business
            DM3["OCRImageCollection"]:::business
            DM4["Rect"]:::business
        end
        subgraph "Game Models"
            GM1["Artifact"]:::business
            GM2["Character"]:::business
            GM3["Navigation"]:::business
            GM4["Weapon"]:::business
        end
    end

    %% External Resources
    subgraph "External Resources"
        OCR["OCR Engine (tessdata)"]:::external
    end

    %% JSON Export Module
    JSONExport["JSON Export (.GOOD)"]:::export

    %% Installer/Deployment Module
    Installer["Installer/Deployment"]:::external

    %% Connections
    UI_Main -->|"initiateScan"| SC1
    SC1 -->|"OCRprocessing"| OCR
    SC1 -->|"populateModels"| DM1
    DM1 -->|"exportData"| JSONExport
    UI_UI -->|"triggerExport"| JSONExport
    UI_Exec -->|"displayResults"| JSONExport

    %% Class Definitions for Styling
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef processing fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef business fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef export fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events
    click UI_Main "https://github.com/andrewthe13th/inventory_kamera/tree/master/InventoryKamera/ui/main"
    click UI_UI "https://github.com/andrewthe13th/inventory_kamera/tree/master/InventoryKamera/ui/main"
    click UI_Exec "https://github.com/andrewthe13th/inventory_kamera/tree/master/InventoryKamera/ui/main"
    click SC1 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/scraping/ArtifactScraper.cs"
    click SC2 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/scraping/CharacterScraper.cs"
    click SC3 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/scraping/GenshinProcesor.cs"
    click DM1 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/data/DatabaseManager.cs"
    click DM2 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/data/Inventory.cs"
    click DM3 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/data/OCRImageCollection.cs"
    click DM4 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/data/Rect.cs"
    click GM1 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/game/Artifact.cs"
    click GM2 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/game/Character.cs"
    click GM3 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/game/Navigation.cs"
    click GM4 "https://github.com/andrewthe13th/inventory_kamera/blob/master/InventoryKamera/game/Weapon.cs"
    click OCR "https://github.com/andrewthe13th/inventory_kamera/tree/master/InventoryKamera/tessdata"
    click Installer "https://github.com/andrewthe13th/inventory_kamera/blob/master/Inventory Kamera Installer/Inventory Kamera Installer.vdproj"
```
