How rushi-ship/whatsapp_groups-automation works
Project type and purpose
• This is a small full-stack web application (“WhatsApp Automation Tool”) built on Python/Flask.
• Purpose: provide a secure web UI for uploading Excel files of group data and sending either generic or stock-recommendation messages to WhatsApp groups via an automated browser (ChromeDriver).
File structure
• app.py: main Flask application (routes, view logic).
• init_db.py: script to initialize the user credentials database.
• whatsapp_utils.py: module encapsulating all WhatsApp-automation logic (launching ChromeDriver, navigating WhatsApp Web, sending messages).
• templates/: Jinja2 templates (login.html, index.html for message selection, base.html).
• requirements.txt: dependencies (Flask, Selenium, openpyxl or pandas, etc.).
• README.md: documents features, usage, Excel format, security.
README for additional insights
• Security: user login, password hashing, session management.
• Excel upload: two modes (generic vs. stock).
• Dependencies: Python 3.8+, Flask, ChromeDriver.
Main components & interactions
a. Components:
• Client Browser (Web UI)
• Flask Web Server (app.py)
• Database (SQLite via init_db.py)
• Excel Parser (built into app.py or whatsapp_utils)
• WhatsApp Automation Service (whatsapp_utils.py using Selenium/ChromeDriver)
• External Service: WhatsApp Web
b. Relationships / data flow:
1. User opens browser → requests login page (Flask).
2. User submits credentials → Flask validates against Database.
3. Upon login, user uploads Excel → Flask parses file, validates columns.
4. User selects message type → Flask passes data to whatsapp_utils.
5. whatsapp_utils spins up ChromeDriver → logs in to WhatsApp Web UI → iterates through rows, sends messages.
6. Completion status returns to Flask → shown in browser.
c. Architectural patterns / principles:
• MVC-style separation: Templates (View), app.py (Controller), Database/Utilities (Model & Services).
• Single-responsibility: whatsapp_utils.py strictly handles messaging logic.
• Modular: Database init & management separated to init_db.py.
d. Key technologies:
• Flask & Jinja2 for web server and templating.
• SQLite (or other relational DB) for user credentials.
• Selenium WebDriver (ChromeDriver) for browser automation.
• openpyxl or pandas (in requirements.txt) for Excel parsing.
• Flask and its sub-components (auth, file upload, business logic) in the Web Server layer.