# vannguyen799/cryptoportfolioapp architecture

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

- Interactive diagram: https://gitdiagram.com/vannguyen799/cryptoportfolioapp
- Repository: https://github.com/vannguyen799/cryptoportfolioapp

## Overview

##### Main Components

A. Google Apps Script Runtime Environment (Top Level)
- This as the containing environment where the application runs

B. Core Application Layer
- App.js as the main application controller
- Menu.js as the user interface controller
- Trigger.js as the automation/scheduling component

C. Sheet Management Layer
- Six sheet classes:
- ConfigSheet
- PNLHistorySheet
- PortfolioInfoSheet
- PortfolioSheet
- StatusSheet
- TradeHistorySheet

D. Utility Layer
- Utility.js as a support component
- Test.js for testing infrastructure

##### Additional Elements

- Google Sheets API interaction points
- Event triggers and scheduling points
- Configuration flow from ConfigSheet to other components
- Data flow between trading-related sheets (PNL, Portfolio, TradeHistory)

##### Important Notes

- Separation between UI, core logic, and data management
- How trigger.js integrates with Google Apps Script's time-based triggers
- Configuration dependencies from ConfigSheet to other components
- Demonstrate the relationship between trading-related sheets

##### Technical Details to Highlight

- Google Apps Script specific integrations
- Sheet data flow patterns
- Event handling mechanisms
- Configuration management approach

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph GAS["Google Apps Script Runtime Environment"]
        subgraph UI["User Interface Layer"]
            Menu["Menu Controller"]:::ui
        end

        subgraph Core["Core Application Layer"]
            App["App Controller"]:::core
            Trigger["Trigger Handler"]:::core
        end

        subgraph Sheets["Sheet Management Layer"]
            Config["Config Sheet"]:::sheet
            PNL["PNL History Sheet"]:::sheet
            PortInfo["Portfolio Info Sheet"]:::sheet
            Port["Portfolio Sheet"]:::sheet
            Status["Status Sheet"]:::sheet
            Trade["Trade History Sheet"]:::sheet
        end

        subgraph Utils["Utility Layer"]
            Utility["Utility Functions"]:::util
            Test["Test Infrastructure"]:::util
        end
    end

    %% Relationships
    Menu --> App
    App --> Trigger
    
    %% App to Sheets
    App --> Config
    App --> PNL
    App --> PortInfo
    App --> Port
    App --> Status
    App --> Trade
    
    %% Sheet Interactions
    Config -.-> PNL
    Config -.-> PortInfo
    Config -.-> Port
    Config -.-> Status
    Config -.-> Trade
    
    %% Utility Usage
    Utility --> App
    Utility --> Menu
    Utility --> Sheets
    Test -.-> App
    
    %% Click Events
    click Menu "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/menu.js"
    click App "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/App.js"
    click Trigger "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/trigger.js"
    click Config "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/ConfigSheet.js"
    click PNL "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/PNLHistorySheet.js"
    click PortInfo "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/PortfolioInfoSheet.js"
    click Port "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/PortfolioSheet.js"
    click Status "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/StatusSheet.js"
    click Trade "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/sheet/TradeHistorySheet.js"
    click Utility "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/.utility.js"
    click Test "https://github.com/vannguyen799/CryptoPortfolioApp/blob/main/src/.test.js"
    
    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#FF9800,stroke:#F57C00,color:white
    classDef sheet fill:#4CAF50,stroke:#388E3C,color:white
    classDef util fill:#9E9E9E,stroke:#616161,color:white
    
    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["UI Components"]:::ui
        L3["Sheet Components"]:::sheet
        L4["Utility Components"]:::util
        L5[" "] --->|"Direct Dependency"| L6[" "]
        L7[" "] -.->|"Event/Config Flow"| L8[" "]
    end
```
