# charlesbel/microsoft-rewards-farmer architecture

> Architecture diagram of the GitHub repository charlesbel/microsoft-rewards-farmer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/charlesbel/microsoft-rewards-farmer
- Repository: https://github.com/charlesbel/microsoft-rewards-farmer

## Overview

##### Project type and purpose
- Type: A command-line, open-source automation tool (bot) written in Python.
- Purpose: Automate Microsoft Rewards tasks (searches, daily sets, punch cards, promotions), support multi-account management, proxies, notifications, and auto-updates via Selenium.

##### File structure
- Entry points:
- main.py – primary orchestrator
- autoupdate_main.py – wraps main.py with self-update logic
- src/ – core modules:
- browser.py – sets up Selenium WebDriver
- login.py – handles authentication (including 2FA)
- searches.py, dailySet.py, punchCards.py, morePromotions.py, activities.py – implement individual task flows
- notifier.py – dispatches Discord/Telegram notifications
- userAgentGenerator.py, constants.py, utils.py, loggingColoredFormatter.py – supporting utilities
- accounts.json.sample – credentials template
- requirements.txt – dependency list (selenium, requests, etc.)

##### README for architectural insights
- The tool relies on Selenium (with WebDriver Manager).
- Supports CLI flags for headless mode, language, geo, proxy, notifications.
- Session storing indicates persistence of cookies or session state between runs.
- Auto-update checks a repo, downloads a new version, then executes.

a. Main components
- CLI Interface (main.py / autoupdate_main.py)
- Configuration Loader (accounts.json + CLI args parser)
- Session Manager (session storage on disk)
- Selenium Controller (browser.py + WebDriver Manager)
- Task Modules (searches, dailySet, punchCards, morePromotions, activities)
- Notification Module (notifier.py)
- Auto-Updater (autoupdate_main.py logic)
- External Services:
– Microsoft Rewards web endpoints
– Discord Webhook API
– Telegram Bot API
– GitHub (for updates)
b. Relationships & interactions
1. CLI → Configuration Loader reads accounts.json & flags.
2. CLI/autoupdate_main → Auto-Updater (if enabled) → may restart the tool.
3. Main orchestrator instantiates Session Manager & Selenium Controller.
4. Selenium Controller launches Chrome, loads cookies or logs in via login module.
5. Main orchestrator sequentially invokes Task Modules. Each:
– Uses Selenium Controller to navigate & perform UI actions.
– Reports status to Notification Module.
6. After tasks complete, Notification Module posts to Discord/Telegram.
7. Session Manager persists cookies/session for next run.
c. Architectural patterns / design principles
- Modular decomposition: each feature in its own module.
- Single Responsibility: browser setup, login, each task, and notifications are separate.
- Orchestration Layer: main.py controls the overall flow.
- Self-updating: bootstrap wrapper for version management.
- Config-driven: JSON + CLI arguments.
d. Key technologies / frameworks
- Python 3.x
- Selenium with webdriver-manager
- requests (for notifications)
- argparse or click (CLI parsing)
- JSON for config

##### Elements
- CLI → Config Loader, Auto-Updater, Session Manager, Selenium Controller
- Selenium Controller ↔ Microsoft Rewards
- Task Modules → Selenium Controller
- Task Modules → Notification Module → (Discord API, Telegram API)
- Auto-Updater → GitHub → restart flow
- Session Manager → local disk
- Arrowheads – data/control flow direction

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Points"
        CLI["main.py"]:::entry
        AutoEntry["autoupdate_main.py"]:::entry
    end

    subgraph "Core Library"
        CLConf["Configuration Loader\n(accounts.json.sample + CLI args)"]:::core
        SessMgr["Session Manager\n(utils session persistence)"]:::core
        Selenium["Selenium Controller\n(browser.py)"]:::core
        Auth["Authentication Module\n(login.py)"]:::core

        subgraph "Task Modules"
            Searches["Searches Module\n(searches.py)"]:::core
            Daily["Daily Set Module\n(dailySet.py)"]:::core
            Punch["Punch Cards Module\n(punchCards.py)"]:::core
            MorePromo["More Promotions Module\n(morePromotions.py)"]:::core
            Activities["Activities Module\n(activities.py)"]:::core
        end

        Notifier["Notification Module\n(notifier.py)"]:::core

        subgraph "Utilities"
            Utils["Utils\n(src/utils.py)"]:::util
            UA["UserAgentGenerator\n(src/userAgentGenerator.py)"]:::util
            Const["Constants\n(src/constants.py)"]:::util
            LogFmt["LoggingFormatter\n(src/loggingColoredFormatter.py)"]:::util
        end
    end

    subgraph "External Services"
        Rewards["Microsoft Rewards Web"]:::external
        Discord["Discord Webhook API"]:::external
        Telegram["Telegram Bot API"]:::external
        GitHub["GitHub Releases"]:::external
        Disk["Local Disk"]:::external
    end

    %% Control Flow
    AutoEntry -->|"check updates"| GitHub
    GitHub -.->|"download new version"| AutoEntry
    AutoEntry -->|"launch main"| CLI

    CLI -->|"load config"| CLConf
    CLI -->|"init session"| SessMgr
    CLI -->|"init browser"| Selenium

    Selenium -->|"authenticate"| Auth
    Selenium <-->|"web interactions"| Rewards

    CLI -->|"execute tasks"| Searches
    CLI -->|"execute tasks"| Daily
    CLI -->|"execute tasks"| Punch
    CLI -->|"execute tasks"| MorePromo
    CLI -->|"execute tasks"| Activities

    Searches -->|"use selenium"| Selenium
    Daily -->|"use selenium"| Selenium
    Punch -->|"use selenium"| Selenium
    MorePromo -->|"use selenium"| Selenium
    Activities -->|"use selenium"| Selenium

    Searches -->|"report status"| Notifier
    Daily -->|"report status"| Notifier
    Punch -->|"report status"| Notifier
    MorePromo -->|"report status"| Notifier
    Activities -->|"report status"| Notifier

    Notifier -->|"post message"| Discord
    Notifier -->|"post message"| Telegram

    SessMgr -->|"persist cookies"| Disk

    CLConf -->|"use utils"| Utils

    %% Click Events
    click CLI "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/main.py"
    click AutoEntry "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/autoupdate_main.py"
    click CLConf "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/accounts.json.sample"
    click CLConf "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/utils.py"
    click Selenium "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/browser.py"
    click Auth "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/login.py"
    click Searches "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/searches.py"
    click Daily "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/dailySet.py"
    click Punch "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/punchCards.py"
    click MorePromo "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/morePromotions.py"
    click Activities "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/activities.py"
    click Notifier "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/notifier.py"
    click Utils "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/utils.py"
    click UA "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/userAgentGenerator.py"
    click Const "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/constants.py"
    click LogFmt "https://github.com/charlesbel/microsoft-rewards-farmer/blob/master/src/loggingColoredFormatter.py"

    %% Styles
    classDef entry fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef core fill:#E8F1FF,stroke:#1F78C1,color:#1F78C1;
    classDef util fill:#F0FFF4,stroke:#2E8B57,color:#2E8B57;
    classDef external fill:#F0F0F0,stroke:#AAAAAA,color:#555555,stroke-dasharray: 2 2;
```
