Bulk Messaging System

An Electron Desktop app for marketing campaign & broadcast management, using either whatsapp, gmail or a SMTP server

Development guidelines

Introduction#

Working on this repo: Electron + React UI, Python contact services, style expectations, tests, and the release workflow.

Project structure#

The repository is organized into distinct areas:

  • Electron application with React UI and Electron main/preload processes
  • Python backend for contact processing and validation
  • GitHub Actions workflows for CI/CD
  • Local development utilities

Core components#

  • React UI and Application Shell
  • App.jsx renders the main application container and mounts BulkMailer.
  • main.jsx initializes the React root and renders App.
  • Electron Main Process
  • main.js sets up the BrowserWindow, configures web preferences, handles IPC channels for Gmail, SMTP, and WhatsApp, and manages lifecycle events.
  • preload.cjs exposes a secure API surface to the renderer via contextBridge.
  • Component Architecture
  • BulkMailer.jsx orchestrates tabs (WhatsApp, Gmail, SMTP), manages state, and coordinates IPC calls.
  • WhatsAppForm.jsx, GmailForm.jsx, and SMTPForm.jsx encapsulate UI and user interactions for each channel.
  • Python Backend
  • app.py provides endpoints for contact upload, manual number parsing, and single number validation using Flask and pandas.

Architecture overview#

Who owns what:

  • Renderer (React) handles UI and user interactions
  • Preload bridges secure IPC calls to the main process
  • Main process executes Electron APIs, manages external integrations, and emits status updates
  • Python backend provides reusable utilities for contact processing and validation

Detailed component analysis#

React component architecture guidelines#

  • Prefer functional components with hooks for state and effects
  • Centralize cross-tab state in BulkMailer.jsx and pass down props to specialized forms
  • Use controlled components for inputs and derive derived state (e.g., recipient counts)
  • Manage IPC subscriptions in useEffect and return cleanup functions to prevent leaks
  • Keep UI components presentation-focused; delegate data fetching and side effects to the main process

Electron main process and IPC#

  • Security-first configuration: context isolation enabled, nodeIntegration disabled, preload script defines safe APIs
  • IPC channels for WhatsApp (client lifecycle, QR, status, send), Gmail (auth, token, send), and SMTP (send)
  • Reliable error handling and cleanup on app close/quit
  • Status updates propagated via ipcRenderer events to the renderer

Python backend services#

  • Flask app with CORS enabled
  • Endpoints for health checks, file uploads, manual number parsing, and single number validation
  • Uses pandas for reliable CSV/Excel parsing and regex-based phone number cleaning
  • Secure file handling with allowed extensions and upload directory management

Dependency analysis#

  • Electron dependencies include React, TailwindCSS, whatsapp-web.js, nodemailer, googleapis, and qrcode libraries
  • Vite is configured with React and Tailwind plugins, serving the React app locally and building to dist-react
  • electron-builder bundles the React and Electron resources into platform-specific distributables

Performance considerations#

  • Electron
  • Headless browser mode for WhatsApp client reduces overhead; ensure sandbox and GPU flags are configured appropriately
  • Minimize heavy DOM rendering; use virtualized lists for large contact/email previews
  • Debounce user input for large text areas to reduce re-renders
  • React
  • Use React.memo for components that render large lists (e.g., contact previews)
  • Split heavy computations into Web Workers or preload-bound tasks
  • Avoid unnecessary re-renders by memoizing derived values and callbacks
  • Python Backend
  • Use pandas vectorized operations for CSV/Excel parsing
  • Stream file reads/writes to avoid loading entire files into memory
  • Cache validated numbers where appropriate to reduce repeated validations
  • IPC
  • Batch status updates to reduce IPC overhead
  • Use throttled progress events for long-running operations

Testing strategies#

  • Unit Testing
  • React: Use a testing library to test pure functions and component logic (e.g., form validation, state transitions)
  • Python: Write pytest tests for app.py endpoints, covering parsing, validation, and error paths
  • Integration Testing
  • Electron: Mock IPC handlers to simulate WhatsApp/Gmail/SMTP flows without external dependencies
  • End-to-end: Use a testing framework to automate UI interactions and verify IPC events
  • End-to-End Testing
  • Electron: Automate user flows (connect to WhatsApp, import contacts, send messages) and assert status updates
  • Python: Validate backend endpoints with realistic payloads and edge cases

Contribution workflow#

  • Fork the repository and create feature branches with descriptive names
  • Follow code style standards enforced by ESLint
  • Add tests for new features and update documentation
  • Ensure cross-platform compatibility and thorough testing before opening a pull request

Development environment setup#

  • Prerequisites
  • Node.js 20.19+ and npm for the Electron app (Vite 8)
  • Python 3.10+ for backend utilities
  • Google Cloud Console credentials for Gmail API
  • WhatsApp account and SMTP server credentials
  • Installation
  • Install Electron dependencies in the electron directory
  • Install Python backend dependencies in python-backend
  • Start the development server from the electron directory
  • Configuration
  • Create a .env file in the electron directory with GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET
  • Configure SMTP settings for email sending

Debugging techniques#

  • Electron
  • Use DevTools in development mode; main process logs are visible in terminal
  • Inspect network requests and IPC traffic in DevTools
  • Validate preload exposure and IPC handler registration
  • React
  • Use React DevTools to inspect component props/state
  • Add console logs for IPC callbacks and status updates
  • Python Backend
  • Enable Flask debug mode for development
  • Validate file uploads and endpoint responses with curl or Postman

Continuous integration and deployment#

  • GitHub Actions workflows
  • Release workflow builds Electron apps for macOS, Linux, and Windows
  • Distributables include platform-specific packages (DMG, AppImage, EXE, MSI, ZIP, TAR.GZ)
  • Release notes are generated automatically
  • Release Process
  • Update version in electron/package.json
  • Push git tags to trigger the workflow
  • Review artifacts and finalize releases

Code review standards#

  • Code Style
  • Adhere to ESLint configuration for JavaScript/React
  • Use functional components with hooks and avoid class components
  • Security
  • Never expose sensitive data in the renderer process
  • Validate and sanitize all user inputs
  • Reliability
  • Add error boundaries and keep the rest of the UI usable when one panel fails
  • Ensure cleanup of external resources (WhatsApp sessions, file handles)
  • Documentation
  • Update README for new features and configuration changes
  • Comment complex logic and trade-offs

Documentation requirements#

  • Keep README updated with installation, configuration, and usage instructions
  • Document new endpoints, configuration options, and breaking changes
  • Provide troubleshooting sections for common issues

Quality assurance procedures#

  • Automated Checks
  • Linting with ESLint
  • Building and packaging verification
  • Manual QA
  • Cross-platform testing (Windows, macOS, Linux)
  • End-to-end user flows for WhatsApp, Gmail, and SMTP
  • Security Review
  • Audit context isolation and IPC exposure
  • Validate OAuth2 and SMTP credential handling

Troubleshooting guide#

  • Common Issues
  • WhatsApp QR code not loading: check internet connection and restart the app
  • Gmail authentication failure: verify OAuth2 credentials and API enablement
  • SMTP connection issues: confirm server settings, firewall, and port/security
  • Contact import errors: verify file format, encoding, and column headers
  • Support
  • Check README troubleshooting section
  • Review existing issues and create new ones with system information and error logs

Conclusion#

Match the patterns already in main.js and the form components. Small, reviewable PRs beat drive-by refactors in this hybrid tree.