# arpitteli/quali architecture

> Architecture diagram of the GitHub repository arpitteli/quali, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arpitteli/quali
- Repository: https://github.com/arpitteli/quali

## Overview

1. **Overall shape**
   - This repo is an **Electron desktop app** with a **three-process/UI split**: the Electron **main process**, a primary **React renderer window**, and a separate **floating mini-player window**.
   - The app is built and bundled with **Vite** on the frontend side, and packaged with **electron-builder**.

2. **Main process boundary**
   - `src/main/index.js` is the central orchestration point for desktop concerns: creating windows, wiring IPC, managing app lifecycle, and integrating auto-update behavior.
   - This is the boundary where browser-like UI is turned into native desktop behavior, including frameless/always-on-top window management implied by the README.

3. **Preload bridge**
   - `src/preload.js` is the security and communication layer between Electron internals and React UI.
   - It exposes a controlled IPC API via `contextBridge`, so the renderer can request native actions without direct Node/Electron access.

4. **Primary renderer app**
   - `src/renderer/` contains the main React application for the lead-review workflow.
   - `src/renderer/src/App.jsx` is the top-level UI state container, while `src/renderer/src/components/` holds feature-specific screens such as login, setup/import, modal dialogs, tab navigation, toasts, and right-side panels.

5. **Workflow-oriented UI composition**
   - The renderer is organized around the lead-review lifecycle:
     - `LoginView` for authentication/session entry
     - `SetupView` and `FilePicker` for importing Excel leads
     - `AddLeadModal` for manual lead entry
     - `TabStrip` for switching app sections
     - `Toast` for transient feedback
   - The `right-panel/` widgets (`ActivitiesCard`, `CompetitionWidget`, `MasterCard`, `TodoList`) suggest a dashboard-like secondary area for stats, progress, and tasks rather than a single flat form.

6. **Mini-player subsystem**
   - `src/mini-player/` is a separate React app/window dedicated to fast triage actions.
   - The README describes it as a **floating, always-on-top, frameless window** used during batch review to tag leads as Good / Maybe / Bad.
   - Architecturally, this is a distinct UI surface optimized for quick decisions while the browser stays open to Google Search tabs.

7. **Data ingestion and local persistence**
   - The app’s core input is an **Excel file** loaded by the user.
   - SheetJS (`xlsx`) is the key data layer technology for reading/writing spreadsheets, enabling:
     - column detection
     - importing lead rows
     - generating a local master Excel file
     - exporting tagged leads
   - The local master lives outside the app bundle at `Documents/quali_master.xlsx`, making it a user-scoped working database rather than an embedded app resource.

8. **Cloud-backed lead state**
   - The README describes several external Google Apps Script web apps: **Auth**, **Cloud Master**, **Push**, and **Per-User Master**.
   - These are the remote service boundary for login, per-user state, deduplication across users, and shared-sheet pushes.
   - The app therefore combines **local spreadsheet state** with **remote spreadsheet-backed services**, rather than a traditional database server.

9. **Lead review data flow**
   - The main path is: **Excel import → setup/import UI → batch review → tag action → master synchronization**.
   - Batch Google Search tabs are opened from the imported leads, and the mini-player is used to assign status.
   - Tagged results then flow to:
     - the **cloud master** for cross-user dedup
     - the **per-user master sheet** for personal tracking
     - the **local Excel master** for offline persistence and color-coded status

10. **Master management and outbound sharing**
   - The “Master Viewer” mentioned in the README is a secondary management surface for reviewing accumulated leads.
   - Actions like **Discard**, **Push**, **Comments**, and **Export** indicate the app supports both curation and publishing workflows.
   - “Push” is a distinct outbound integration to a shared Google Sheet via Apps Script, separate from personal master storage.

11. **Operational concerns**
   - Configuration and recovery are stored in the user profile: `%APPDATA%/Quali/config.json` and `%APPDATA%/Quali/recovery.json`.
   - This suggests the app is designed for long-running desktop usage with session recovery and local preferences, not stateless browsing.

12. **Packaging and release pipeline**
   - `electron-builder` produces platform installers, with explicit Windows and Mac build targets.
   - GitHub Actions in `.github/workflows/release.yml` automates Mac release builds on version tags.
   - `electron-updater` connects the runtime app to GitHub Releases for update delivery.

13. **Repository boundary note**
   - The README references a separate `quali-web/` source tree for the Apps Script code, but that code is not present in this repo tree.
   - So the architecture here is the **desktop client plus build/release automation**, while the spreadsheet-backed cloud endpoints live outside this repository.

14. **How to draw the architecture**
   - A good diagram would show:
     - **Electron main process** at the center of native/window/update control
     - **Renderer UI** as the primary user-facing app
     - **Mini-player UI** as a separate always-on-top companion window
     - **Preload/IPC bridge** between renderer and main
     - **Local Excel/config files** as persistent storage on disk
     - **Google Apps Script / Google Sheets** as the remote service layer
     - **GitHub Releases / Actions** as the distribution and auto-update path

Main entry points: [`src/renderer/src/App.jsx`](https://github.com/arpitteli/quali/blob/main/src/renderer/src/App.jsx) (Review app), [`src/main/index.js`](https://github.com/arpitteli/quali/blob/main/src/main/index.js) (Main process), [`src/mini-player/src/App.jsx`](https://github.com/arpitteli/quali/blob/main/src/mini-player/src/App.jsx) (Mini-player app), [`src/renderer/src/components/SetupView.jsx`](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/SetupView.jsx) (Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop runtime"]
  node_main_process["Main process<br/>electron orchestration<br/>[index.js]"]
  node_preload_bridge["Preload bridge<br/>ipc bridge<br/>[preload.js]"]
end

subgraph group_renderer["Primary renderer"]
  node_renderer_app["Review app<br/>react shell<br/>[App.jsx]"]
  node_login_view["Login<br/>renderer screen<br/>[LoginView.jsx]"]
  node_setup_view["Setup<br/>renderer screen<br/>[SetupView.jsx]"]
  node_file_picker["File picker<br/>import widget<br/>[FilePicker.jsx]"]
  node_add_lead_modal["Add lead<br/>modal form<br/>[AddLeadModal.jsx]"]
  node_tab_strip["Tabs<br/>navigation<br/>[TabStrip.jsx]"]
  node_toast_ui["Toast<br/>feedback<br/>[Toast.jsx]"]
  node_right_panel["Right panel<br/>dashboard widgets"]
  node_activities_card["Activities<br/>dashboard widget<br/>[ActivitiesCard.jsx]"]
  node_competition_widget["Competition<br/>dashboard widget"]
  node_master_card["Master card<br/>dashboard widget<br/>[MasterCard.jsx]"]
  node_todo_list["Todo list<br/>dashboard widget<br/>[TodoList.jsx]"]
end

subgraph group_mini["Mini-player"]
  node_mini_app["Mini-player app<br/>react window<br/>[App.jsx]"]
  node_mini_entry["Mini entry<br/>renderer entry<br/>[main.jsx]"]
end

subgraph group_release["Build & release"]
  node_electron_updater["Auto-updater<br/>runtime service"]
  node_vite_build["Vite build<br/>frontend bundler<br/>[vite.config.js]"]
  node_release_workflow["Release workflow<br/>ci pipeline<br/>[release.yml]"]
  node_packaging["Packager<br/>desktop packaging"]
end

node_local_excel[("Local master<br/>spreadsheets")]
node_cloud_apps_script["Apps Script APIs<br/>remote services"]
node_google_sheets[("Google Sheets<br/>shared data store")]
node_xlsx_lib["SheetJS<br/>spreadsheet library"]

node_main_process -->|"loads bridge"| node_preload_bridge
node_main_process -->|"opens main UI"| node_renderer_app
node_main_process -->|"opens mini window"| node_mini_app
node_renderer_app -->|"shows"| node_login_view
node_renderer_app -->|"shows"| node_setup_view
node_renderer_app -->|"navigates"| node_tab_strip
node_renderer_app -->|"notifies"| node_toast_ui
node_renderer_app -->|"contains"| node_right_panel
node_right_panel -->|"includes"| node_activities_card
node_right_panel -->|"includes"| node_competition_widget
node_right_panel -->|"includes"| node_master_card
node_right_panel -->|"includes"| node_todo_list
node_setup_view -->|"uses"| node_file_picker
node_renderer_app -->|"opens"| node_add_lead_modal
node_renderer_app -->|"calls IPC"| node_preload_bridge
node_mini_entry -->|"mounts"| node_mini_app
node_mini_app -->|"calls IPC"| node_preload_bridge
node_setup_view -->|"imports to"| node_local_excel
node_master_card -->|"updates"| node_local_excel
node_renderer_app -->|"syncs"| node_cloud_apps_script
node_mini_app -->|"tags"| node_cloud_apps_script
node_cloud_apps_script -->|"backed by"| node_google_sheets
node_setup_view -->|"parses"| node_xlsx_lib
node_master_card -->|"exports"| node_xlsx_lib
node_main_process -->|"checks updates"| node_electron_updater
node_electron_updater -->|"delivers"| node_release_workflow
node_vite_build -->|"builds"| node_renderer_app
node_vite_build -->|"builds"| node_mini_app
node_release_workflow -->|"invokes"| node_packaging
node_packaging -->|"packages"| node_main_process

click node_main_process "https://github.com/arpitteli/quali/blob/main/src/main/index.js"
click node_preload_bridge "https://github.com/arpitteli/quali/blob/main/src/preload.js"
click node_renderer_app "https://github.com/arpitteli/quali/blob/main/src/renderer/src/App.jsx"
click node_login_view "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/LoginView.jsx"
click node_setup_view "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/SetupView.jsx"
click node_file_picker "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/FilePicker.jsx"
click node_add_lead_modal "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/AddLeadModal.jsx"
click node_tab_strip "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/TabStrip.jsx"
click node_toast_ui "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/Toast.jsx"
click node_activities_card "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/ActivitiesCard.jsx"
click node_competition_widget "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/CompetitionWidget.jsx"
click node_master_card "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/MasterCard.jsx"
click node_todo_list "https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/TodoList.jsx"
click node_mini_app "https://github.com/arpitteli/quali/blob/main/src/mini-player/src/App.jsx"
click node_mini_entry "https://github.com/arpitteli/quali/blob/main/src/mini-player/src/main.jsx"
click node_vite_build "https://github.com/arpitteli/quali/blob/main/vite.config.js"
click node_release_workflow "https://github.com/arpitteli/quali/blob/main/.github/workflows/release.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_process,node_preload_bridge toneBlue
class node_renderer_app,node_login_view,node_setup_view,node_file_picker,node_add_lead_modal,node_tab_strip,node_toast_ui,node_right_panel,node_activities_card,node_competition_widget,node_master_card,node_todo_list toneAmber
class node_mini_app,node_mini_entry toneMint
class node_electron_updater,node_vite_build,node_release_workflow,node_packaging toneRose
class node_local_excel,node_cloud_apps_script,node_google_sheets,node_xlsx_lib toneNeutral
```

## Components

### Desktop runtime

Electron main process and native window orchestration

- [Main process](https://github.com/arpitteli/quali/blob/main/src/main/index.js): electron orchestration · Creates windows, wires IPC, manages lifecycle, and coordinates updates · `src/main/index.js`
- [Preload bridge](https://github.com/arpitteli/quali/blob/main/src/preload.js): ipc bridge · Context-isolated API surface between renderer and Electron internals · `src/preload.js`

### Primary renderer

Main React application for lead review

- [Review app](https://github.com/arpitteli/quali/blob/main/src/renderer/src/App.jsx): react shell · Top-level state container for the lead-review workflow · `src/renderer/src/App.jsx`
- [Login](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/LoginView.jsx): renderer screen · Authentication and session entry UI · `src/renderer/src/components/LoginView.jsx`
- [Setup](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/SetupView.jsx): renderer screen · Import and onboarding flow for lead files · `src/renderer/src/components/SetupView.jsx`
- [File picker](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/FilePicker.jsx): import widget · Spreadsheet selection and file import control · `src/renderer/src/components/FilePicker.jsx`
- [Add lead](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/AddLeadModal.jsx): modal form · Manual lead entry dialog · `src/renderer/src/components/AddLeadModal.jsx`
- [Tabs](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/TabStrip.jsx): navigation · Section switching within the main renderer · `src/renderer/src/components/TabStrip.jsx`
- [Toast](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/Toast.jsx): feedback · Transient status and error messages · `src/renderer/src/components/Toast.jsx`
- **Right panel**: dashboard widgets · Secondary workspace for stats, tasks, and progress
- [Activities](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/ActivitiesCard.jsx): dashboard widget · Activity and progress summary · `src/renderer/src/components/right-panel/ActivitiesCard.jsx`
- [Competition](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/CompetitionWidget.jsx): dashboard widget · Comparative or scoring panel · `src/renderer/src/components/right-panel/CompetitionWidget.jsx`
- [Master card](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/MasterCard.jsx): dashboard widget · Master lead status and management entrypoint · `src/renderer/src/components/right-panel/MasterCard.jsx`
- [Todo list](https://github.com/arpitteli/quali/blob/main/src/renderer/src/components/right-panel/TodoList.jsx): dashboard widget · Task list and follow-up actions · `src/renderer/src/components/right-panel/TodoList.jsx`

### Mini-player

Floating companion window for fast triage

- [Mini-player app](https://github.com/arpitteli/quali/blob/main/src/mini-player/src/App.jsx): react window · Floating always-on-top companion window for rapid lead tagging · `src/mini-player/src/App.jsx`
- [Mini entry](https://github.com/arpitteli/quali/blob/main/src/mini-player/src/main.jsx): renderer entry · Mini-player bootstrap and mounting code · `src/mini-player/src/main.jsx`

### Build & release

Frontend bundling and packaged distribution

- **Auto-updater**: runtime service · Update delivery from release channel
- [Vite build](https://github.com/arpitteli/quali/blob/main/vite.config.js): frontend bundler · Frontend development and production bundling setup · `vite.config.js`
- [Release workflow](https://github.com/arpitteli/quali/blob/main/.github/workflows/release.yml): ci pipeline · GitHub Actions release automation for tagged builds · `.github/workflows/release.yml`
- **Packager**: desktop packaging · Electron packaging and installer generation

### Other components

- **Local master**: spreadsheets · User-scoped Excel persistence for imported and tagged leads
- **Apps Script APIs**: remote services · Auth, cloud master, push, and per-user master endpoints
- **Google Sheets**: shared data store · External spreadsheet-backed system of record
- **SheetJS**: spreadsheet library · Excel import/export and sheet manipulation support

## Connections

- Main process → Preload bridge: loads bridge · Main process attaches preload script to renderer windows
- Main process → Review app: opens main UI · Main process creates the primary renderer window
- Main process → Mini-player app: opens mini window · Main process creates the floating mini-player window
- Review app → Login: shows · Primary app includes authentication surface
- Review app → Setup: shows · Primary app includes import/setup flow
- Review app → Tabs: navigates · Top-level sections are switched through tabs
- Review app → Toast: notifies · App surfaces transient feedback to the user
- Review app → Right panel: contains · Secondary dashboard area within the main renderer
- Right panel → Activities: includes · Dashboard content area
- Right panel → Competition: includes · Dashboard content area
- Right panel → Master card: includes · Dashboard content area
- Right panel → Todo list: includes · Dashboard content area
- Setup → File picker: uses · Import flow relies on spreadsheet selection
- Review app → Add lead: opens · Manual lead creation dialog is launched from the app
- Review app → Preload bridge: calls IPC · Renderer uses controlled native actions through the preload API
- Mini entry → Mini-player app: mounts · Mini-player entry bootstraps the floating UI
- Mini-player app → Preload bridge: calls IPC · Mini-player communicates through the same controlled bridge
- Setup → Local master: imports to · Imported leads are stored in the local master workbook
- Master card → Local master: updates · Master management actions persist to local spreadsheet state
- Review app → Apps Script APIs: syncs · Login, push, and per-user state go through remote endpoints
- Mini-player app → Apps Script APIs: tags · Rapid triage actions sync lead status to remote services
- Apps Script APIs → Google Sheets: backed by · Remote services store and coordinate data in spreadsheets
- Setup → SheetJS: parses · Spreadsheet import and column detection use SheetJS
- Master card → SheetJS: exports · Master and tagged lead exports are spreadsheet-based
- Main process → Auto-updater: checks updates · Main process integrates runtime update behavior
- Auto-updater → Release workflow: delivers · GitHub release pipeline publishes update artifacts
- Vite build → Review app: builds · Vite bundles the primary renderer application
- Vite build → Mini-player app: builds · Vite bundles the mini-player window
- Release workflow → Packager: invokes · CI automates packaged desktop releases
- Packager → Main process: packages · Electron packaging turns the app into native installers
