# ironmanfpv/question-visualizer-for-monocle architecture

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

- Interactive diagram: https://gitdiagram.com/ironmanfpv/question-visualizer-for-monocle
- Repository: https://github.com/ironmanfpv/question-visualizer-for-monocle

## Overview

##### Project Overview & Purpose
- The project is essentially a full-stack web application with a hardware integration twist. Its primary purpose is to collate questions from a Google Sheet (used as a Q&A input mechanism) via Google Sheets API, then format and transmit these questions to a “Monocle” device.
- The application serves two scenarios: a presentation/briefing and a classroom lecture for collecting and displaying questions.
- The README explains a manual and semi-automated flow where, after fetching data, the web interface helps you download a formatted data file (“data.json”) which is later uploaded to the Monocle via the Brilliant AR Studio using a Python script (main.py) on the device.

##### Analyzing the File Structure for Architecture Insights
- Frontend Layer:
- The “public” folder contains index.html and a “src” subfolder with JavaScript files (connect.js, download.js, upload.js, script.js) that manage user interactions, Google API authentication, and data exchange.
- These scripts likely handle OAuth flow, API key configurations, and trigger actions (connect, download, upload) that facilitate the question flow.
- Backend / Server Component:
- server.js along with Node’s package.json, package-lock.json, and node_modules indicate that a Node.js environment is used to host the web interface and perhaps serve as an API proxy for Google Sheets.
- The existence of a “credentials.json” file further implies that secured credential management might be in place.
- Device/Hardware Integration:
- The project also includes a Python file (main.py) which is intended to run on the Monocle device. This, together with a “data.json” file (generated when you click “Download”), suggests that the device expects a specific data format for displaying the questions.
- There is also a “.brilliant” directory with device-related JSON files, backing up the integration with Brilliant AR Studio for device programming.
- Development & Configuration:
- The inclusion of folders like “.vscode” and an “Archive” for previous data files indicates a supportive development environment.
- README instructions describe manual steps to test data fetching and device uploading.

##### Essential Elements
- Clear labels for each major component.
– Request/Response between the browser and Google Sheets API.
– Data push from browser to Monocle device.
– Interaction between Node server and browser.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Node.js Server"
        NS1("server.js"):::server
        NS2("package.json"):::server
        NS3("package-lock.json"):::server
        NS4("node_modules"):::server
    end

    subgraph "Web Client (HTML/JS)"
        WC1("index.html"):::frontend
        WC2("connect.js"):::frontend
        WC3("download.js"):::frontend
        WC4("script.js"):::frontend
        WC5("upload.js"):::frontend
    end

    C("Google Sheets API (OAuth)"):::external
    D("Data Formatter (data.json)"):::external
    E("Bluetooth Communication"):::communication

    subgraph "Monocle Device (Python)"
        MD1("main.py"):::device
        MD2(".brilliant"):::device
    end

    G("Developer Tools (VS Code & AR Studio)"):::devtools

    %% Connections
    NS1 -->|"ServeStaticFiles"| WC1
    WC1 -->|"OAuth&Fetch"| C
    WC1 -->|"DownloadData"| D
    WC1 -->|"BluetoothConnect"| E
    E -->|"SendQuestions"| MD1
    G -->|"ManualUpload"| MD1

    %% Click Events for Web Client files
    click WC1 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/public/index.html"
    click WC2 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/public/src/connect.js"
    click WC3 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/public/src/download.js"
    click WC4 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/public/src/script.js"
    click WC5 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/public/src/upload.js"

    %% Click Events for Node.js Server files
    click NS1 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/server.js"
    click NS2 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/package.json"
    click NS3 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/package-lock.json"
    click NS4 "https://github.com/ironmanfpv/question-visualizer-for-monocle/tree/main/node_modules"

    %% Click Event for Google Sheets API credential
    click C "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/credentials.json"

    %% Click Event for Data Formatter file
    click D "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/Archive/data.json"

    %% Click Events for Monocle Device files
    click MD1 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/main.py"
    click MD2 "https://github.com/ironmanfpv/question-visualizer-for-monocle/blob/main/.brilliant"

    %% Styles
    classDef server fill:#c2f0c2, stroke:#333, stroke-width:2px;
    classDef frontend fill:#cce5ff, stroke:#333, stroke-width:2px;
    classDef external fill:#ffcccc, stroke:#333, stroke-width:2px;
    classDef device fill:#ffe0b3, stroke:#333, stroke-width:2px;
    classDef communication fill:#ffffcc, stroke:#333, stroke-width:2px;
    classDef devtools fill:#e6ccff, stroke:#333, stroke-width:2px;
```
