# shonya3/divicards architecture

> Architecture diagram of the GitHub repository shonya3/divicards, 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/shonya3/divicards
- Repository: https://github.com/shonya3/divicards

## Overview

##### Project Components
- Frontend/UI Layer:
- The web client is split into two parts:
▪ The Vue3 application is found under packages/app (with its own src, public assets, and Tauri subfolder for integration).
▪ The Web Components are in packages/wc (built with Lit and enhanced with Storybook support).
- Tauri Integration (Desktop Shell):
- Located in packages/app/src-tauri, where the Rust main process communicates between the UI and native features.
- Contains configuration (tauri.conf.json), build scripts, and a “lib” that exposes commands (such as Google and Poe integrations).
- Backend/Domain Logic (Rust Crates):
- Several smaller Rust crates perform dedicated functions:
▪ card_element – handles core card display logic, error handling, and fetching resources.
▪ divcord & divcord_wasm – handle parsing and conversion of spreadsheet data (e.g., card sets) with a WASM variant for web deployment.
▪ divi – responsible for parsing divination card sets, performing calculations (like card weight estimates), and data normalization.
▪ fs_cache_fetcher – implements file system caching for external resources.
▪ generate_website_files – supports generation of website content (likely for static assets).
▪ googlesheets – provides integration with Google Sheets for exporting and formatting data.
▪ ninja – likely communicates with external services for pricing data (such as poe.ninja).
▪ poe and poe_data – interact with Path of Exile game APIs and data extraction.
- External Services:
- GGG’s API for stash contents (using OAuth rather than legacy credentials).
- Google Sheets for export, and possibly poe.ninja for price rates.

##### Relationships and Data Flow
- The Frontend (Vue3 & Web Components) is the user’s point of interaction.
- The UI sends commands to the Tauri backend (Rust main process) which uses the various Rust crates to:
- Fetch and parse user data (via API calls to GGG).
- Process and merge spreadsheets (via divcord/divi).
- Compute card weights and prices.
- Export results either locally or to Google Sheets.
- External integrations (OAuth, Google Sheets, poe.ninja) are handled by dedicated crates (googlesheets, ninja, poe/poe_data).
- There is also a clear separation between domain logic (parsing, calculations, error handling) and the UI rendering logic.

##### Architectural Patterns and Design Principles
- Modularity: Multiple Rust crates, each dedicated to a specific functionality (parsing, data fetching, transformation) promote separation of concerns.
- Layered Architecture: With the UI layer separated from both the application (Tauri and Rust) logic and the external services.
- Interoperability: The system makes use of WebAssembly (divcord_wasm) to allow similar functionality in a browser or lightweight environment.
- API/Command Pattern: Tauri commands (exposed via packages/app/src-tauri/lib) allow the UI to interact with the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        A["Vue3 App"]:::frontend
        B["Web Components (Lit)"]:::frontend
    end

    %% Desktop Shell (Tauri)
    subgraph "Desktop Shell"
        C["Tauri Main Process"]:::tauri
    end

    %% Domain Logic (Rust Crates)
    subgraph "Domain Logic (Rust Crates)"
        D["card_element: Core Card Display Logic"]:::rust
        E["divcord: Spreadsheet Parsing/Conversion"]:::rust
        F["divcord_wasm: WASM Variant for Web Deployment"]:::rust
        G["divi: Card Data Parsing & Calculations"]:::rust
        H["fs_cache_fetcher: File System Caching"]:::rust
        I["generate_website_files: Website Content Generation"]:::rust
        J["googlesheets: Google Sheets Integration"]:::rust
        K["ninja: External Pricing/poe.ninja Integration"]:::rust
        L["poe: Path of Exile API Interaction"]:::rust
        M["poe_data: Path of Exile Data Extraction"]:::rust
    end

    %% External Services
    subgraph "External Services"
        N["GGG API"]:::external
        O["Google Sheets"]:::external
        P["poe.ninja"]:::external
    end

    %% Relationships
    %% Frontend to Desktop Shell
    A -->|"UICommand"| C
    B -->|"UICommand"| C

    %% Desktop Shell to Domain Logic Modules
    C -->|"UI Rendering"| D
    C -->|"SpreadsheetParsing"| E
    C -->|"WASMProcessing"| F
    C -->|"DataParsing"| G
    C -->|"Caching"| H
    C -->|"GenerateWebsite"| I
    C -->|"ExportSheets"| J
    C -->|"FetchPricing"| K
    C -->|"GameAPICall"| L
    C -->|"DataExtraction"| M

    %% Domain Logic Modules to External Services
    G -->|"FetchStash"| N
    L -->|"GameData"| N
    M -->|"ExtractData"| N

    J -->|"SheetExport"| O
    K -->|"PricingData"| P

    %% Classes for coloring
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef tauri fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef rust fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA500,stroke:#000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/shonya3/divicards/tree/main/packages/app"
    click B "https://github.com/shonya3/divicards/tree/main/packages/wc"
    click C "https://github.com/shonya3/divicards/tree/main/packages/app/src-tauri"
    click D "https://github.com/shonya3/divicards/tree/main/card_element"
    click E "https://github.com/shonya3/divicards/tree/main/divcord"
    click F "https://github.com/shonya3/divicards/tree/main/divcord_wasm"
    click G "https://github.com/shonya3/divicards/tree/main/divi"
    click H "https://github.com/shonya3/divicards/tree/main/fs_cache_fetcher"
    click I "https://github.com/shonya3/divicards/tree/main/generate_website_files"
    click J "https://github.com/shonya3/divicards/tree/main/googlesheets"
    click K "https://github.com/shonya3/divicards/tree/main/ninja"
    click L "https://github.com/shonya3/divicards/tree/main/poe"
    click M "https://github.com/shonya3/divicards/tree/main/poe_data"
```
