# raziele/creditcardanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/raziele/creditcardanalysis
- Repository: https://github.com/raziele/creditcardanalysis

## Overview

##### Project Type and Purpose
- This project is a Google Apps Script add-on that integrates with Google Sheets. Its primary purpose is to parse files exported from Israeli credit card companies, organize the data into a table, and provide a basic dashboard (using Google Data Studio).
- The README walks through installation, configuration (choosing a folder in Google Drive and copying a template sheet), and usage (triggers via custom menus in the spreadsheet). This indicates a tight integration with Google Drive and Google Sheets.

##### Analyzing the File Structure
- Top-level directories and files:
- The “src” folder holds key JavaScript files:
- CreditCardParsers.js (handles parsing of credit card export files)
- HelperFunctions.js (contains utility functions)
- Main.js (likely coordinates the overall workflow)
- UserInterface.js (manages the UI aspects, such as creating the custom menu in the spreadsheet)
- The “appsscript.json” file in “src” defines the Google Apps Script project’s configuration (e.g., manifest settings, libraries, etc.).
- Other important files:
- .github and its workflows indicate automated deployment scripts (potentially using clasp) for version control and deployment.
- Files like .clasp.json and .claspignore indicate that this project is managed and deployed using the clasp tool which is common with Google Apps Script projects.
- The “imgs” directory contains visual assets used in the README for guiding the user through installation and usage.

##### Key Components
a. Frontend / UI Component:
- The UserInterface.js and the custom menu integrated into the spreadsheet.
- This component is responsible for letting users kick off operations (like “Detect analysis file” or “Configure report folder”) directly via the Google Sheets UI.
b. Backend / Processing Logic:
- Main.js serves as the coordinator that calls functions from CreditCardParsers.js and HelperFunctions.js.
- CreditCardParsers.js parses the exported credit card files, and HelperFunctions.js offers supporting utilities.
c. Google Services Integration:
- The Google Drive integration (for reading files from a designated folder).
- Google Sheets integration (for updating the “DB” and “Categories” sheets).
- The configuration file (appsscript.json) that binds these together with the proper permissions.
d. Deployment & Source Control:
- The .github workflows and clasp configuration show that deployment automation and version control are part of the process.

##### Relationships and Data Flows
- User Interaction: Through the custom menu, users trigger functions that invoke the back-end processing.
- File Intake: The system accesses a specific Google Drive folder (as specified by the folder ID) to retrieve exported credit card report files.
- Data Processing: Using functions in CreditCardParsers.js, the raw credit card data is parsed and processed.
- Data Updating: Processed data is then written into the Google Sheet (updating the “DB” sheet and populating or modifying the “Categories” sheet).
- Reporting/Dashboard: The final structured data feeds into a dashboard (as seen in the Google Data Studio screenshot) for visualization.

##### Architectural Patterns and Design Principles
- Modular structure: The splitting of concerns across separate scripts (UI, main logic, parsing utilities) promotes separation of concerns.
- Event-driven interactions: User actions in the spreadsheet trigger the processing functions.
- Integration with external Google services (Drive and Sheets) with proper configuration via the manifest (appsscript.json).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction Layer
    UI["User Interface (UI)"]:::ui

    %% Processing Engine Layer
    subgraph "Processing Engine"
        Main["Main.js"]:::processing
        Parser["CreditCardParsers.js"]:::processing
        Helper["HelperFunctions.js"]:::processing
    end

    %% Google Services Integration Layer
    subgraph "Google Services Integration"
        Appscript["appsscript.json"]:::integration
        Drive["Google Drive (File Storage)"]:::integration
        Sheets["Google Sheets (DB & Categories)"]:::integration
    end

    %% Dashboard Layer
    Dashboard["Dashboard (Google Data Studio)"]:::dashboard

    %% Deployment & Configuration Layer
    subgraph "Deployment & Configuration"
        Github["GitHub Workflows"]:::deployment
        Clasp["CLASP Config"]:::deployment
        ClaspIgnore["CLASP Ignore"]:::deployment
    end

    %% Data Flow Connections
    UI -->|"triggers"| Main
    Main -->|"calls"| Parser
    Main -->|"calls"| Helper
    Main -->|"retrieves files"| Drive
    Main -->|"updates data"| Sheets
    Sheets -->|"feeds"| Dashboard

    %% Click Events
    click UI "https://github.com/raziele/creditcardanalysis/blob/master/src/UserInterface.js"
    click Main "https://github.com/raziele/creditcardanalysis/blob/master/src/Main.js"
    click Parser "https://github.com/raziele/creditcardanalysis/blob/master/src/CreditCardParsers.js"
    click Helper "https://github.com/raziele/creditcardanalysis/blob/master/src/HelperFunctions.js"
    click Appscript "https://github.com/raziele/creditcardanalysis/blob/master/src/appsscript.json"
    click Github "https://github.com/raziele/creditcardanalysis/blob/master/.github/workflows/deploy-script.yml"
    click Clasp "https://github.com/raziele/creditcardanalysis/blob/master/.clasp.json"
    click ClaspIgnore "https://github.com/raziele/creditcardanalysis/blob/master/.claspignore"

    %% Styling
    classDef ui fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef processing fill:#a9dfbf,stroke:#239b56,stroke-width:2px;
    classDef integration fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef dashboard fill:#d2b4de,stroke:#76448a,stroke-width:2px;
    classDef deployment fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
