# klept0/ms-rewards-farmer architecture

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

- Interactive diagram: https://gitdiagram.com/klept0/ms-rewards-farmer
- Repository: https://github.com/klept0/ms-rewards-farmer

## Overview

##### Main Components
- Main Entry Point: Highlight main.py as the central script that initializes and orchestrates the execution.
- Authentication & Account Management: Emphasize the management of credentials from the accounts file (accounts.json) and any related login functionality (src/login.py).
- Functionality Modules: Show several functional components from the src/ directory such as:
- src/account.py
- src/activities.py (for modeling various daily actions)
- src/dailySet.py, src/punchCards.py, src/morePromotions.py, src/readToEarn.py, src/searches.py (each representing a distinct reward or search operation)
- src/browser.py (could serve as the abstraction layer over Selenium)
- src/utils.py and src/constants.py (supporting utilities and configurations)
- Configuration & Environment Setup: Include config.yaml and accounts.json (the user’s credentials file) as configuration data components.
- Tests: Represent the test suite (in the test folder) to indicate verification of system behavior.
- External Dependencies: Add a node for external resources (e.g., Selenium, Chrome browser, and third-party libraries as specified in requirements.txt) plus the Windows Task Scheduler XML generation (via generate_task_xml.py).

##### Relationships and Data/Control Flow
- From the Browser Controller, branch out to the different functionality modules (searches, daily set, punch cards, promotions, read-to-earn) as separate operations. Each module “calls” the automation layer.
- Integrate the Authentication & Account Management module (src/login.py and src/account.py) which feeds credentials and login state into the Browser Controller.
- Link the Logging and Notification component to every module that requires error and activity reporting.
- For Windows users, illustrate that generate_task_xml.py provides a scheduling configuration which, when imported into Task Scheduler, triggers main.py periodically.

##### Architectural Patterns & Design Principles
- Modularity: Demonstrate the separation of concerns by grouping functionality (e.g., searches, promotions, login) into separate modules within src/.
- Configuration Driven: Mark the configuration files as central to the application’s behavior.
- External Service Integration: Indicate integration with external tools (Chrome/ChromeDriver, Selenium, Apprise notifications, and Windows Task Scheduler).
- Testability: Represent the tests directory as supporting continuous integration practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Main Entry Point (main.py)"]:::core
    B["Configuration (config.yaml)"]:::config
    C["Credential File (accounts.json.sample)"]:::config
    D1["Login (src/login.py)"]:::core
    D2["Account Management (src/account.py)"]:::core
    E["Browser Controller (src/browser.py)"]:::core

    subgraph "Functional Modules"
        F1["Daily Set (src/dailySet.py)"]:::functional
        F2["Punch Cards (src/punchCards.py)"]:::functional
        F3["Promotions (src/morePromotions.py)"]:::functional
        F4["ReadToEarn (src/readToEarn.py)"]:::functional
        F5["Searches (src/searches.py)"]:::functional
        F5a["Remaining Searches (src/remainingSearches.py)"]:::functional
        F6["Activities (src/activities.py)"]:::functional
    end

    G["Logging (src/loggingColoredFormatter.py)"]:::logging
    H["External Notifications (Apprise)"]:::external
    I["Task Scheduling (generate_task_xml.py)"]:::scheduler
    J["Test Suite (test/)"]:::test

    subgraph "Utilities"
        K["Utilities (src/utils.py)"]:::util
        L["Constants (src/constants.py)"]:::util
        M["User Agent (src/userAgentGenerator.py)"]:::util
    end

    %% Main Flow: Initialization and Authentication
    A -->|"loads"| B
    A -->|"loads"| C
    A -->|"initiates"| D1
    A -->|"manages"| D2
    B -->|"configures"| E
    C -->|"supplies"| D1
    C -->|"supplies"| D2
    D1 -->|"providesAuth"| E
    D2 -->|"providesAuth"| E
    A -->|"starts"| E

    %% Browser Controller executes functionality modules
    E -->|"executes"| F1
    E -->|"executes"| F2
    E -->|"executes"| F3
    E -->|"executes"| F4
    E -->|"executes"| F5
    E -->|"executes"| F5a
    E -->|"executes"| F6

    %% Logging and Notification flow
    E -.->|"logs"| G
    F1 -.->|"reports"| G
    F2 -.->|"reports"| G
    F3 -.->|"reports"| G
    F4 -.->|"reports"| G
    F5 -.->|"reports"| G
    F5a -.->|"reports"| G
    F6 -.->|"reports"| G
    G -->|"notifies"| H

    %% Task Scheduling triggers the main entry point
    I -->|"triggers"| A

    %% Test Suite validates main system functionality
    J -->|"tests"| A

    %% Utilities usage in the system
    K -.->|"usedBy"| A
    L -.->|"usedBy"| A
    M -.->|"usedBy"| A

    %% Click Events
    click A "https://github.com/klept0/ms-rewards-farmer/blob/master/main.py"
    click B "https://github.com/klept0/ms-rewards-farmer/blob/master/config.yaml"
    click C "https://github.com/klept0/ms-rewards-farmer/blob/master/accounts.json.sample"
    click D1 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/login.py"
    click D2 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/account.py"
    click E "https://github.com/klept0/ms-rewards-farmer/blob/master/src/browser.py"
    click F1 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/dailySet.py"
    click F2 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/punchCards.py"
    click F3 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/morePromotions.py"
    click F4 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/readToEarn.py"
    click F5 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/searches.py"
    click F5a "https://github.com/klept0/ms-rewards-farmer/blob/master/src/remainingSearches.py"
    click F6 "https://github.com/klept0/ms-rewards-farmer/blob/master/src/activities.py"
    click G "https://github.com/klept0/ms-rewards-farmer/blob/master/src/loggingColoredFormatter.py"
    click I "https://github.com/klept0/ms-rewards-farmer/blob/master/generate_task_xml.py"
    click J "https://github.com/klept0/ms-rewards-farmer/tree/master/test/"
    click K "https://github.com/klept0/ms-rewards-farmer/blob/master/src/utils.py"
    click L "https://github.com/klept0/ms-rewards-farmer/blob/master/src/constants.py"
    click M "https://github.com/klept0/ms-rewards-farmer/blob/master/src/userAgentGenerator.py"

    %% Styles
    classDef core fill:#C3E5AE,stroke:#333,stroke-width:2px;
    classDef config fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef functional fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef logging fill:#D2B4DE,stroke:#333,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef scheduler fill:#FCF3CF,stroke:#333,stroke-width:2px;
    classDef test fill:#D5F5E3,stroke:#333,stroke-width:2px;
    classDef util fill:#FDEBD0,stroke:#333,stroke-width:2px;
```
