# hamzaaitbrik/redditdmbot architecture

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

- Interactive diagram: https://gitdiagram.com/hamzaaitbrik/redditdmbot
- Repository: https://github.com/hamzaaitbrik/redditdmbot

## Overview

##### Project type and purpose
- This is a Python-based automation tool (“RedditDMBot”) whose sole purpose is to log into multiple Reddit accounts in Chrome (via CDP), navigate to a user’s chat page, and send DMs in bulk. It relies on a private browser-driving framework (zendriver) instead of Selenium/Playwright to avoid detection.

##### File structure
- Top-level entrypoint:
- RedditDMBot.py – orchestrates the bot’s workflow
- modules.py – helper functions
- Configuration/resources:
- rsrc/ – JSON config files (config.json, proxies.json, links/locators/paths), JS snippets, Chrome extension for proxying
- Account management:
- rdt/ – account definitions (accounts.json), toss_accounts.csv
- Data stores:
- db/ – input list of usernames, and CSVs for failed/sent usernames
- results/ – final output grouping (failed/succeeded)
- Logging:
- log/, logs/log – logging output
- Browser automation engine:
- zendriver/ – vendored CDP-based framework modules (cdp/*, core/*)

##### README for additional insights
- The workflow (login → navigate → check message status → send → update CSV → rotate account) is fully described.
- Dependencies: Python 3.11, Pipenv, zendriver framework, optional proxies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraphs
    subgraph "CLI Orchestrator" 
        direction TB
        BOT["RedditDMBot.py"]:::code
        MOD["modules.py"]:::code
    end

    subgraph "Configuration & Resources" 
        direction TB
        RSRC["rsrc/"]:::data
        CFG["config.json"]:::data
        PRX["proxies.json"]:::data
        LNK["links.json"]:::data
        LOC["locators.json"]:::data
        PTH["paths.json"]:::data
        JS["getElementByAttributeValue.js"]:::data
        EXT["proxy extension/"]:::browser
    end

    subgraph "Account Manager"
        direction TB
        ACC_JSON["accounts.json"]:::data
        ACC_CSV["toss_accounts.csv"]:::data
    end

    subgraph "Data Store"
        direction TB
        DB_IN["usernames.csv"]:::data
        DB_FAIL["usernames_failed.csv"]:::data
        DB_SENT["usernames_sent.csv"]:::data
        RES_FAIL["results/failed/"]:::data
        RES_SUCC["results/succeeded/"]:::data
    end

    subgraph "Logging Service"
        direction TB
        LOG_DIR["log/"]:::data
        LOG_FILE["logs/log"]:::data
    end

    subgraph "Automation Engine"
        direction TB
        ZEN_CDP["zendriver/cdp/"]:::code
        ZEN_CORE["zendriver/core/"]:::code
    end

    BROWSER["Browser Instance (Chrome + Proxy Extension)"]:::browser
    REDDIT["Reddit Web Service"]:::external

    %% Connections
    BOT -->|"reads"| RSRC
    BOT -->|"loads accounts"| ACC_JSON
    BOT -->|"loads accounts"| ACC_CSV
    BOT -->|"calls"| ZEN_CDP
    BOT -->|"calls"| ZEN_CORE
    ZEN_CDP -->|"launch via CDP"| BROWSER
    ZEN_CORE -->|"launch via CDP"| BROWSER
    BROWSER -->|"HTTP/HTTP2 over CDP"| REDDIT
    BOT -->|"injects JS"| BROWSER
    BOT -->|"updates"| DB_IN
    BOT -->|"updates"| DB_FAIL
    BOT -->|"updates"| DB_SENT
    BOT -->|"writes results"| RES_FAIL
    BOT -->|"writes results"| RES_SUCC
    BOT -->|"logs events/errors"| LOG_DIR
    BOT -->|"logs events/errors"| LOG_FILE

    %% Click Events
    click BOT "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/RedditDMBot.py"
    click MOD "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/modules.py"
    click RSRC "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/rsrc/"
    click CFG "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/config.json"
    click PRX "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/proxies.json"
    click LNK "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/links.json"
    click LOC "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/locators.json"
    click PTH "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/paths.json"
    click JS "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rsrc/JavaScript/getElementByAttributeValue.js"
    click EXT "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/rsrc/extensions/proxy/"
    click ACC_JSON "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rdt/accounts.json"
    click ACC_CSV "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/rdt/toss_accounts.csv"
    click DB_IN "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/db/usernames.csv"
    click DB_FAIL "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/db/usernames_failed.csv"
    click DB_SENT "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/db/usernames_sent.csv"
    click RES_FAIL "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/results/failed/.gitkeep"
    click RES_SUCC "https://github.com/hamzaaitbrik/redditdmbot/blob/zendriver/results/succeeded/.gitkeep"
    click LOG_DIR "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/log/"
    click LOG_FILE "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/logs/log"
    click ZEN_CDP "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/zendriver/cdp/"
    click ZEN_CORE "https://github.com/hamzaaitbrik/redditdmbot/tree/zendriver/zendriver/core/"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef browser fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
