# krutika9021/whatsapp_automator architecture

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

- Interactive diagram: https://gitdiagram.com/krutika9021/whatsapp_automator
- Repository: https://github.com/krutika9021/whatsapp_automator

## Overview

##### Project Type and Purpose
- This is a Python-based automation tool (“WhatsApp Automation Bot”) that uses Selenium to drive a Chrome browser and send messages to WhatsApp Web.
- It is not a multi-service or full-stack app; it’s a single script that orchestrates:
- Input files (numbers.txt, message.txt)
- A Selenium WebDriver session (via chromedriver.exe)
- A Chrome browser instance with a persistent user profile

##### High-Level Components
a. Inputs
- numbers.txt: list of target phone numbers
- message.txt: the message payload
b. Automation Layer (main.py)
- Python script
- Uses Selenium and webdriver-manager libraries
- Reads inputs, loops through numbers, builds WhatsApp Web URLs, types and sends messages
c. Selenium Infrastructure
- Selenium WebDriver API (Python bindings)
- webdriver-manager: automatically downloads & configures chromedriver.exe
d. Browser Layer
- ChromeDriver executable
- Google Chrome browser binary
- Custom Chrome user-data directory (`chrome_automation_profile` or `User_Data`) for session persistence
e. External Service
- WhatsApp Web over HTTPS (websocket/XHR to WhatsApp servers)

##### Component Relationships and Data Flow
1. main.py loads `numbers.txt` and `message.txt`.
2. main.py spawns a Selenium WebDriver session pointing at chromedriver.exe.
3. ChromeDriver launches Chrome with the custom profile directory.
4. Chrome (with persistent cookies & localStorage) connects to WhatsApp Web, requiring only a one-time QR scan.
5. main.py issues WebDriver commands:
– navigate to `https://web.whatsapp.com/send?phone=<number>&text=<message chunk>`
– send message (in chunks as needed)
6. Chrome communicates with WhatsApp servers to deliver the message.
7. main.py handles errors (invalid numbers) and logs progress.

##### Architectural Patterns and Principles
- Single-process orchestration (no microservices).
- Layered separation:
1. Data/Input layer
2. Automation/Control layer (Python)
3. Driver/Browser layer (Selenium + ChromeDriver + Chrome)
4. External Service layer (WhatsApp Web)
- Persistent state management via custom Chrome profile.
- Configuration via simple text files (numbers.txt, message.txt)

##### Essential Elements
- Clear component names: “main.py (Automation Script)”, “Selenium WebDriver (Python)”, “ChromeDriver”, “Chrome Browser + Profile”, “WhatsApp Web Service”
- Inputs: “numbers.txt” and “message.txt”
- Persistent profile: “chrome_automation_profile”
- Network boundary: WhatsApp Web servers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data/Input Layer
    subgraph "Data/Input Layer"
        numbers["numbers.txt"]:::data
        message["message.txt"]:::data
    end

    %% Automation Layer
    subgraph "Automation/Control Layer"
        main["main.py (Automation Script)"]:::code
        test["test_open.py (Test Script)"]:::code
        selenium["Selenium WebDriver (Python)"]:::code
    end

    %% Driver/Browser Layer
    subgraph "Driver/Browser Layer"
        chromedriver["chromedriver.exe"]:::binary
        licenses["ChromeDriver Licenses"] 
        license1["LICENSE.chromedriver"]:::binary
        notice1["THIRD_PARTY_NOTICES.chromedriver"]:::binary
        chrome["Chrome Browser"]:::binary
        profile1["chrome_automation_profile"]:::data
        profile2["User_Data"]:::data
    end

    %% External Service Layer
    subgraph "External Service"
        whatsapp["WhatsApp Web Service"]:::network
    end

    %% Connections
    numbers -->|"read"| main
    message -->|"read"| main
    main -->|"calls"| selenium
    main -->|"verifies launch"| test
    selenium -->|"launch & control"| chromedriver
    chromedriver -->|"launch"| chrome
    chrome -->|"read/write"| profile1
    chrome -->|"read/write"| profile2
    chrome -->|"HTTPS"| whatsapp
    license1 --> licenses
    notice1 --> licenses

    %% Click Events
    click numbers "https://github.com/krutika9021/whatsapp_automator/blob/master/numbers.txt"
    click message "https://github.com/krutika9021/whatsapp_automator/blob/master/message.txt"
    click main "https://github.com/krutika9021/whatsapp_automator/blob/master/main.py"
    click test "https://github.com/krutika9021/whatsapp_automator/blob/master/test_open.py"
    click selenium "https://github.com/krutika9021/whatsapp_automator/tree/master/selenium"
    click chromedriver "https://github.com/krutika9021/whatsapp_automator/blob/master/chromedriver.exe"
    click license1 "https://github.com/krutika9021/whatsapp_automator/blob/master/LICENSE.chromedriver"
    click notice1 "https://github.com/krutika9021/whatsapp_automator/blob/master/THIRD_PARTY_NOTICES.chromedriver"
    click profile1 "https://github.com/krutika9021/whatsapp_automator/tree/master/chrome_automation_profile/"
    click profile2 "https://github.com/krutika9021/whatsapp_automator/tree/master/User_Data/"
    click README "https://github.com/krutika9021/whatsapp_automator/blob/master/README.md"
    click PROJECT_LICENSE "https://github.com/krutika9021/whatsapp_automator/tree/master/LICENSE"
    click THIRD_PARTY_NOTICES "https://github.com/krutika9021/whatsapp_automator/blob/master/THIRD_PARTY_NOTICES.chromedriver"

    %% Styles
    classDef data fill:#ccffcc,stroke:#2d862d;
    classDef code fill:#cce5ff,stroke:#1a75ff;
    classDef binary fill:#ffe5cc,stroke:#ff8c1a;
    classDef network fill:#e5ccff,stroke:#8c1aff;
```
