Bulk Messaging System

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

Contact management system

Introduction#

How contacts get into the app: file import, manual paste, phone cleaning, and the Pyodide path that runs the same Python logic in the renderer.

  • Multi-format contact import (CSV, Excel, and text files) with automatic format detection
  • Phone number validation and normalization including country code handling
  • Manual contact entry interface with real-time validation feedback
  • Duplicate detection and removal algorithms
  • Pyodide runtime integration for browser-based Python execution
  • Detailed error handling for invalid formats, encoding issues, and malformed data
  • Export capabilities for processed contacts and validation results
  • Performance considerations for large contact lists and memory optimization strategies

Project structure#

The system is composed of:

  • Electron desktop application with React UI
  • Python backend utilities for contact extraction and validation
  • Pyodide integration for browser-side Python execution
  • Local CLI utilities for prototyping and development

Core components#

  • Contact extraction utilities:
  • CSV, Excel, and text file parsers with automatic column detection and phone number cleaning
  • Manual number parser:
  • Parses user-entered text with optional names and cleans phone numbers
  • Phone number validator:
  • Validates and returns normalized numbers
  • Pyodide integration:
  • Loads Python runtime and executes number parsing in the browser
  • Electron IPC:
  • Exposes APIs for contact import, validation, and WhatsApp messaging
  • React UI:
  • Provides manual entry interface, import controls, and real-time feedback

Architecture overview#

The system supports two primary flows:

  • Desktop import via Electron main process (CSV/Excel/TXT) with local parsing
  • Browser-based manual entry via Pyodide (Python executed in the renderer)

Detailed component analysis#

Contact import pipeline (desktop)#

The Electron main process handles file selection and parsing for CSV and TXT. Excel support is present but not used in the current UI flow.

Phone number validation and normalization#

Phone numbers are normalized by removing separators, adding a leading plus for international numbers, and enforcing digit-only length constraints. The same logic is applied in both Python utilities and the browser via Pyodide.

Manual contact entry interface#

The manual entry interface supports:

  • Text area input with examples for formats
  • Real-time validation feedback
  • Immediate addition to the contact list with normalized numbers

Duplicate detection and removal#

The system does not implement explicit duplicate detection in the provided code. To maintain data integrity, consider:

  • Using a set keyed by normalized phone numbers for deduplication
  • Optional name-aware deduplication if names are present
  • Preprocessing before adding to the contact list

Pyodide runtime integration#

Pyodide is dynamically loaded and used to execute Python scripts in the renderer process. The loader fetches the script and runs it asynchronously.

Export capabilities#

The system currently focuses on ingestion and validation. Export functionality for processed contacts and validation results is not implemented in the provided code. To add export:

  • Provide CSV/JSON download options for the current contact list
  • Include validation status and normalized numbers in exports

Dependency analysis#

The contact processing pipeline depends on:

  • Electron main process for file I/O and IPC
  • Python utilities for reliable parsing and validation
  • Pyodide for browser-side Python execution
  • React components for UI and user interaction

Performance considerations#

  • Large CSV/Excel parsing:
  • Prefer streaming parsers for very large files to reduce memory usage
  • Validate and normalize incrementally
  • Browser-based parsing:
  • Pyodide adds overhead; batch processing and progress indicators improve UX
  • Limit concurrent parsing operations
  • Memory optimization:
  • Deduplicate contacts early using normalized keys
  • Avoid storing intermediate unprocessed rows
  • I/O and network:
  • Use buffered reads and writes
  • Implement timeouts for external services

Troubleshooting guide#

Common issues and resolutions:

  • Unsupported file types:
  • Ensure CSV, TXT, XLSX, or XLS formats
  • Encoding problems:
  • Use UTF-8 encoded files
  • Malformed phone numbers:
  • Validate numbers before import; rely on normalization rules
  • Pyodide loading failures:
  • Confirm CDN availability and correct index URL
  • Electron IPC errors:
  • Verify preload exposure and handler registration

Conclusion#

Bad contact data is the usual reason campaigns look broken. Fix normalization first, then chase send errors.