How btelgeuse/greenproductive works
Project type and purpose
• This is a desktop to-do list application built with ElectronJS.
• It has three GUI “pages” (index, dashboard, finishDay), all powered by HTML/CSS/JS, plus an Electron main process to orchestrate windows and data persistence.
File structure
Top-level files
• package.json / package-lock.json – lists dependencies (Electron, forge) and start scripts.
• forge.config.js – controls how the app is packaged.
• main.js – the Electron entry point (“main process”).
• preload.js – the bridge between renderer and main for secure IPC.
Renderer assets
• index.html + dashboard.html + finishDay.html – the three views/UI screens.
• index.js (dashboard.js, finishDay.js) – the per-window UI logic.
• styles.css – shared styling.
Key insights from README
• Real-time updating to-do list, progression bar, checkpoint screens.
• No external servers or databases; state is managed in memory or filesystem via Node APIs.
• Electron handles packaging and distribution.
Main components
a. Electron “Main Process” (main.js)
• Creates and manages BrowserWindow instances (index, dashboard, finishDay).
• Handles IPC requests from the UIs via the preload contextBridge.
• Reads/writes any local file storage (if tasks are persisted to disk).
b. Preload Script (preload.js)
• Exposes a restricted API (via contextBridge) to each renderer.
• Marshals IPC calls (e.g. getTasks(), addTask(), completeTask()).
c. Renderer Processes (3 windows)
• index.html + index.js – initial to-do entry view.
• dashboard.html + dashboard.js – live progress overview.
• finishDay.html + finishDay.js – final achievement summary.
d. User Interface Layer
• HTML/CSS – static assets and UI components.
• JS logic updates the DOM and triggers IPC calls.
e. Operating System / File System
• Where data would be persisted (optional).
• Electron-forge packager interacts here when building installers.
Relationships and data flows
1. User clicks “+” in index window → index.js calls window.api.addTask(task)
2. Preload.js receives addTask IPC → forwards to main.js
3. main.js updates in-memory state (or writes a JSON file) → emits updated task list back via IPC
4. Preload.js catches the response → resolves promise to index.js → UI re-renders the list and updates the progress bar
5. Navigating to dashboard or finishDay windows repeats similar IPC for getProgress() or getSummary()
Architectural patterns & design principles
• Separation of concerns: Main vs Preload vs Renderer
• Single‐page GUI instances for each view, but unified state in the main process
• Secure IPC boundary via preload/contextBridge
• Modular UI scripts per page