How andrewderango/heartflow works
Main Components
• Firmware Component – Represent the FRDM-K64F-based pacemaker firmware developed in Embedded C (compiled from Simulink models). This component handles low-level hardware control such as pulse generation and capacitor management.
• Desktop Application – Split this into two main parts:
• Backend (Electron main process and other Node.js/Python services): This layer includes Electron’s main process files (e.g., the “main” folder in dcm/src/main, which includes index.ts, index.cpp.ts, userService.ts, websockets.ts) and serial communication services (found in dcm/src/serial with both C++ and Python code).
• Frontend (Electron renderer process): Built with React and TypeScript, with its source files located under dcm/src/renderer and organized into components, pages (Dashboard, Login, Register), store, and context.
• Serial Communication Layer – This is the glue between the firmware and the desktop application. It uses a custom UART protocol (with handshake, polling, and data confirmation processes) to ensure bidirectional data transfer.
Relationships and Interactions
• That the backend also contains additional serial modules implemented in both C++ (e.g., websocket server code) and Python (asynchronous webserver processes) that help manage real-time telemetry data.
• A connection from the backend (or a dedicated serial module) to external hardware (the pacemaker firmware) representing the bidirectional data exchange.
• Optionally, show “Documentation” as an external resource that provides further details (e.g., refer to the docs/dcm_docs.pdf, pacemaker_docs.pdf, and serial_protocol_docs.pdf).
Architectural Patterns and Design Principles
• Separation of Concerns: The design clearly distinguishes between firmware (hardware-level operations) and the desktop application’s UI/backend.
• Multi-layered Architecture: Within the desktop application, note the separation between Electron’s main process (Node.js/Python handling operations/communication) and the renderer process (React-based UI).
• IPC and Asynchronous Processing: Emphasize that communication happens asynchronously using Electron’s IPC, web sockets in the backend (dcm/src/main/websockets.ts), and Python’s webserver for serial data processing.
• Modular Design: The serial communication logic is encapsulated in separate directories (dcm/src/serial/cpp and dcm/src/serial/python), underscoring a modular and extensible approach.
Relevant Technologies and Tools
• Frontend: React, TypeScript, PostCSS, Vite configuration (dcm/electron.vite.config.ts).
• Backend: Electron, Node.js, Electron Builder (electron-builder.yml), and Python.
• Firmware: Embedded C generated from Simulink models for the FRDM-K64F microcontroller.
• Serial Communication: Custom UART protocol with supporting modules in C++ and Python.
• Development Tools: ESLint, Prettier, and VSCode configuration tools (visible in the file tree).
Instructing the Principal Software Engineer – Essential Elements
• Architectural Layers: Separate concerns by illustrating how the desktop application is divided into at least three major layers – UI, application logic (backend), and communication subsystems.
• The Firmware running on the FRDM-K64F microcontroller (including pulse generation and heart emulation).
• The Desktop Application divided into the Electron backend (handling Node.js processes, serial communication, and Python-based webserver processes) and a React-based renderer.
• The Serial Communication module that bridges the desktop app and the firmware with a custom UART protocol.
• Supporting components and configuration/build resources that help manage the application development and deployment.