# proyash-saha/ventori architecture

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

- Interactive diagram: https://gitdiagram.com/proyash-saha/ventori
- Repository: https://github.com/proyash-saha/ventori

## Overview

##### Main Components
- App Entry Point: Represented by VentoriApp.swift, which bootstraps the application.
- UI/View Layer: This includes all the user-facing code under the “Ventori/View” directory (HomeView, AddUpdateView, DetailView, etc.) as well as preview content. Also include reusable UI components from “Ventori/Components” (BackButton, CameraButton, BarCodeScanner, etc.).
- Controller/Business Logic Layer: The “Ventori/Controller” directory contains controllers such as BarCodeScannerController, CategoryController, ImagePickerController, ItemController, PersistenceController, and Theme. These manage user interaction logic, control data flow between the UI and the model, and manage state.
- Data/Model Layer: The “Ventori/Model” directory, which includes Ventori.xcdatamodeld with the Core Data model (ItemCoreData), represents the internal data structure and persistence mechanism.
- Assets & Resources: The “Ventori/Assets.xcassets” directory holds images and other static resources, while additional assets (including the logo and screenshots referenced in the README) assist in UI presentation.
- Xcode Project & Build Configurations: These are defined in the Ventori.xcodeproj directory and include project settings and workspace configuration files.

##### Relationships and Interactions
- The UI Layer (views and components) interacts with the Controller Layer when users perform actions (e.g., tapping buttons, scanning barcodes).
- The Controller Layer processes these actions, updating the state, fetching data, or triggering persistence operations by interfacing with the Model Layer.
- The PersistenceController in the Controller Layer interacts directly with the Core Data model in the Model directory, ensuring data is loaded and saved.

##### Architectural Patterns/Design Principles
- MVC Pattern: Clearly separate presentation (View), business logic (Controller), and persistence/data (Model).
- Reusability: The Components directory hints at the creation of reusable UI elements (e.g., custom buttons and scanners) that can be utilized across various views.
- Local Persistence: Use of Core Data encapsulated in the PersistenceController shows adherence to Apple’s recommended practices for local data storage.

##### Elements
- Use clear labels to denote each part such as “App Entry (VentoriApp.swift)”, “UI/View Components”, “Business Logic (Controllers)”, and “Data Model (Core Data Entities)”.
- Special areas or note service dependencies, even if it’s only local persistence.

- Expand the UI layer with individual screens (Home, Add Item, Detail, Settings, etc.) and common components.
- Detail the Controller layer to show each controller (by naming key ones like ItemController, BarCodeScannerController, etc.).
- Model layer with the Core Data model, optionally detailing entities if known from the model file.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Xcode["Xcode Project (Ventori.xcodeproj)"]:::project
    AppEntry["App Entry (VentoriApp.swift)"]:::entry
    Assets["Assets & Resources"]:::assets

    subgraph "UI/View Layer"
        UI["UI/View Layer"]:::ui
        Home["Home View"]:::ui
        AddUpdate["Add/Update View"]:::ui
        Detail["Detail View"]:::ui
        Components["Reusable Components"]:::ui
    end

    subgraph "Controller/Business Logic Layer"
        Controller["Controller/Business Logic Layer"]:::controller
        BarcodeCtrl["BarCodeScannerController"]:::controller
        ItemCtrl["ItemController"]:::controller
        PersistenceCtrl["PersistenceController"]:::controller
        CategoryCtrl["CategoryController"]:::controller
        ImagePickerCtrl["ImagePickerController"]:::controller
        ThemeCtrl["Theme"]:::controller
    end

    subgraph "Data/Model Layer"
        DataModel["Data/Model (Core Data Model)"]:::model
        CoreData["Core Data Model (ItemCoreData)"]:::model
    end

    %% Global Flow
    Xcode --> AppEntry
    AppEntry --> UI
    AppEntry --> Controller
    UI -->|"userInteracts" | Controller
    Controller -->|"dataOperation" | DataModel
    DataModel -->|"providesData" | UI
    UI -->|"rendersAssets" | Assets

    %% Internal Connections within Controller layer
    BarcodeCtrl -->|"handlesComponents" | Components
    ItemCtrl -->|"delegatesPersistence" | PersistenceCtrl
    PersistenceCtrl -->|"savesTo" | CoreData

    %% Click Events
    click Xcode "https://github.com/proyash-saha/ventori/tree/main/Ventori/xcodeproj"
    click AppEntry "https://github.com/proyash-saha/ventori/blob/main/Ventori/VentoriApp.swift"
    click UI "https://github.com/proyash-saha/ventori/tree/main/Ventori/View"
    click Components "https://github.com/proyash-saha/ventori/tree/main/Ventori/Components"
    click Controller "https://github.com/proyash-saha/ventori/tree/main/Ventori/Controller"
    click CoreData "https://github.com/proyash-saha/ventori/blob/main/Ventori/Model/Ventori.xcdatamodeld"
    click Assets "https://github.com/proyash-saha/ventori/blob/main/Ventori/Assets.xcassets"

    %% Styles
    classDef entry fill:#F9E79F,stroke:#F5B041,stroke-width:2px;
    classDef ui fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef controller fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef model fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef project fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef assets fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
```
