# mr-arashnm/auto_git_push architecture

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

- Interactive diagram: https://gitdiagram.com/mr-arashnm/auto_git_push
- Repository: https://github.com/mr-arashnm/auto_git_push

## Overview

##### Project Type and Purpose
- This is a Python‑based automation tool/service that periodically scans local Git repositories and automatically pushes commits to remote (GitHub).
- It optionally provides a minimal web interface (serviced by app.py + static/templates) and sends notifications via Email and Telegram.

##### File Structure
- Top‑level artifacts
- app.py              → Entrypoint (likely Flask or CLI/web server)
- install.py          → Installation script
- requirements.txt    → Dependencies list
- config/             → Configuration loader (settings, secure_settings)
- Core logic
- core/repo_scanner.py → Finds repos, checks for new commits
- core/git_handler.py  → Performs Git push operations
- Notifications
- notifications/email_notifier.py
- notifications/telegram_bot.py
- notifications/notifier.py  → Abstract notifier interface
- Auxiliary
- utils/logger.py      → Logging framework
- utils/validator.py   → Input validation
- utils/id_to_chatId.py→ Mapping IDs for Telegram
- UI/Web assets
- static/… (CSS, JS)
- templates/index.html

##### Extract Key Insights from the README
- Core features: scheduler, multi‑repo support, logging, Telegram & Email notifications.
- Configurable parameters: list of repos, push frequency, notifier preferences.

##### Main Components
a. Scheduler Service
- Reads schedule from config
- Triggers the Repo Scanner at defined intervals
b. Repo Scanner
- Iterates through configured local Git repos
- Determines if new commits exist
c. Git Handler
- Executes `git push` to remote (GitHub)
d. Logging Module
- Records each push attempt/result to filesystem or a log sink
e. Notification Manager
- Implements a Notifier interface
- Email Notifier → SMTP server
- Telegram Notifier → Telegram Bot API
f. Configuration Loader
- Reads `config/settings.py` and `secure_settings.py`
g. (Optional) Web/CLI Interface
- app.py exposing a UI or REST endpoints for status & manual triggers
h. External Services
- GitHub (Git remote)
- SMTP service
- Telegram Bot API

##### Relationships and Data Flows
- Scheduler → triggers → Repo Scanner
- Repo Scanner → calls → Git Handler
- Git Handler → writes → Logging Module
- Git Handler → on success/failure → Notification Manager
- Notification Manager → Email Notifier → SMTP
- Notification Manager → Telegram Notifier → Telegram API
- app.py UI ↔ Configuration Loader
- UI ↔ Scheduler (for manual triggers/status)

##### Architectural Patterns
- Modular, layered design (separate `core`, `notifications`, `utils`)
- Strategy pattern for notifiers (common interface in `notifier.py`)
- Single responsibility per module
- Config‑driven behavior

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Layer
    subgraph "Configuration Loader" 
        direction TB
        ConfigPub["Settings Loader"]:::config
        ConfigSec["Secure Settings Loader"]:::config
    end

    %% Core Engine
    subgraph "Core Engine"
        direction TB
        Scheduler["Scheduler Service"]:::core
        Scanner["Repo Scanner"]:::core
        Handler["Git Handler"]:::core
        Logger["Logging Module"]:::core
    end

    %% Notification Layer
    subgraph "Notifications" 
        direction TB
        NotifierMgr["Notification Manager"]:::notify
        EmailNotif["Email Notifier"]:::notify
        TelegramNotif["Telegram Notifier"]:::notify
        TelBotHelper["Telegram Bot Integration Helper"]:::notify
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        Validator["Validator"]:::utils
        IDMapper["ID-to-ChatID Mapper"]:::utils
        InitUtils["utils/__init__.py"]:::utils
    end

    %% UI/Web Layer
    subgraph "Web/CLI Interface"
        direction TB
        App["Web/CLI Interface"]:::ui
        Template["templates/index.html"]:::ui
        Styles["static/css/styles.css"]:::ui
        Scripts["static/js/scripts.js"]:::ui
    end

    %% Installation
    Install["Installation Script"]:::utilMisc

    %% External Services
    GitHub(("GitHub Remote")):::external
    SMTP(("SMTP Service")):::external
    TelegramAPI(("Telegram Bot API")):::external

    %% Configuration Flows
    ConfigPub -->|reads at startup| Scheduler
    ConfigSec -->|reads at startup| Scheduler
    ConfigPub -->|provides settings| App
    ConfigSec -->|provides secure settings| App

    %% Core Flows
    Scheduler -->|triggers scan| Scanner
    Scanner -->|push request| Handler
    Handler -->|writes log entry| Logger
    Handler -->|push result| NotifierMgr

    %% Notification Flows
    NotifierMgr -->|uses| EmailNotif
    NotifierMgr -->|uses| TelegramNotif
    TelegramNotif -->|calls| TelBotHelper
    EmailNotif -->|sends email| SMTP
    TelegramNotif -->|sends message| TelegramAPI

    %% UI Interactions
    App -->|manual trigger/status| Scheduler
    App -->|loads config| ConfigPub

    %% Utilities Usage
    Scanner -->|validate repos| Validator
    TelegramNotif -->|map IDs| IDMapper

    %% Installation Link
    Install

    %% Click Events
    click Scheduler "https://github.com/mr-arashnm/auto_git_push/blob/main/app.py"
    click Scanner "https://github.com/mr-arashnm/auto_git_push/blob/main/core/repo_scanner.py"
    click Handler "https://github.com/mr-arashnm/auto_git_push/blob/main/core/git_handler.py"
    click Logger "https://github.com/mr-arashnm/auto_git_push/blob/main/utils/logger.py"
    click NotifierMgr "https://github.com/mr-arashnm/auto_git_push/blob/main/notifications/notifier.py"
    click EmailNotif "https://github.com/mr-arashnm/auto_git_push/blob/main/notifications/email_notifier.py"
    click TelegramNotif "https://github.com/mr-arashnm/auto_git_push/blob/main/notifications/telegram_bot.py"
    click TelBotHelper "https://github.com/mr-arashnm/auto_git_push/blob/main/telegram_bot/python_telegram_bot.py"
    click ConfigPub "https://github.com/mr-arashnm/auto_git_push/blob/main/config/settings.py"
    click ConfigSec "https://github.com/mr-arashnm/auto_git_push/blob/main/config/secure_settings.py"
    click App "https://github.com/mr-arashnm/auto_git_push/blob/main/app.py"
    click Template "https://github.com/mr-arashnm/auto_git_push/blob/main/templates/index.html"
    click Styles "https://github.com/mr-arashnm/auto_git_push/blob/main/static/css/styles.css"
    click Scripts "https://github.com/mr-arashnm/auto_git_push/blob/main/static/js/scripts.js"
    click Install "https://github.com/mr-arashnm/auto_git_push/blob/main/install.py"
    click Validator "https://github.com/mr-arashnm/auto_git_push/blob/main/utils/validator.py"
    click IDMapper "https://github.com/mr-arashnm/auto_git_push/blob/main/utils/id_to_chatId.py"
    click InitUtils "https://github.com/mr-arashnm/auto_git_push/blob/main/utils/__init__.py"

    %% Styles
    classDef core fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef notify fill:#d4edda,stroke:#28a745,color:#000;
    classDef config fill:#fff3cd,stroke:#ffca2c,color:#000;
    classDef utils fill:#f0f0f0,stroke:#a9a9a9,color:#000;
    classDef ui fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef utilMisc fill:#f8d7da,stroke:#dc3545,color:#000;
    classDef external fill:#e9ecef,stroke:#6c757d,color:#000;
```
