# bet-blocker/bet-blocker architecture

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

- Interactive diagram: https://gitdiagram.com/bet-blocker/bet-blocker
- Repository: https://github.com/bet-blocker/bet-blocker

## Overview

##### Project type and purpose
- BetBlocker is a standalone Python utility (proof-of-concept) that blocks access to online gambling sites on a local machine by modifying firewall rules and the hosts file. It is not a client-server or web application but a desktop/CLI tool.

##### File structure
- Top-level scripts and config:
- main.py – application entry point
- requirements.txt / pyproject.toml – Python dependencies
- blocklist.txt – list of domains to block
- hosts – template or backup hosts file
- Business logic under src/:
- src/functions/blocker.py – orchestrates block and unblock operations
- src/functions/firewall.py – applies OS firewall rules
- src/functions/deprecated_functions.py – legacy utilities
- src/utils/… – helpers for path resolution and logging
- Support code:
- app/ – UI styling (if any GUI is introduced)
- scripts/remove_duplicates.py – cleans blocklist
- _cicd/avoid_dup_bet.py + .github/workflows – CI/CD script to prevent duplicate entries
- Documentation:
- page/index.md – project docs

##### Insights from the README
- Core features:
- Block by firewall IP filtering
- Block by editing the hosts file
- “Rede de Apoio” (support network) extension point
- Target platforms: Windows & Linux
- Installation: pip install & run main.py

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interaction"
        User["User"]:::external
        UI["CLI / GUI"]:::core
    end
    User -->|"invoke"| UI

    subgraph "Core Application"
        Controller["Controller<br>(main.py)"]:::core
        Orchestrator["Blocker Orchestrator<br>(src/functions/blocker.py)"]:::core
        FirewallAdapter["Firewall Adapter<br>(src/functions/firewall.py)"]:::core
        HostsAdapter["Hosts File Adapter"]:::core
    end
    UI --> Controller
    Controller -->|"start orchestration"| Orchestrator
    Orchestrator -->|"apply firewall rules"| FirewallAdapter
    Orchestrator -->|"update hosts"| HostsAdapter

    subgraph "Utilities"
        PathResolver["Path Resolver<br>(src/utils/get_paths.py)"]:::utils
        Logger["Logger<br>(src/utils/logs.py)"]:::utils
        Deprecated["Deprecated Utilities<br>(src/functions/deprecated_functions.py)"]:::utils
        UIStyling["UI Styling<br>(app/app_styles.py)"]:::utils
    end
    Controller -->|"resolve paths"| PathResolver
    Controller -->|"log actions"| Logger
    Controller -->|"legacy calls"| Deprecated

    subgraph "Data Sources"
        Blocklist[(blocklist.txt)]:::data
        HostsFile[(hosts)]:::data
    end
    Orchestrator -->|"read blocklist"| Blocklist
    HostsAdapter -->|"template backup"| HostsFile

    subgraph "External Systems"
        OSFirewall["OS Firewall"]:::external
        OSHosts["OS Hosts File"]:::external
    end
    FirewallAdapter -->|"system call"| OSFirewall
    HostsAdapter -->|"file I/O"| OSHosts

    subgraph "CI/CD Pipeline"
        Workflow[".github/workflows/avoid_dup_bet.yml"]:::cicd
        CICDScript["_cicd/avoid_dup_bet.py"]:::cicd
        Cleanup["scripts/remove_duplicates.py"]:::cicd
    end
    Workflow --> CICDScript
    CICDScript --> Cleanup
    Cleanup --> Blocklist

    Documentation["Documentation<br>(page/index.md)"]:::docs

    click UI "https://github.com/bet-blocker/bet-blocker/blob/main/main.py"
    click Controller "https://github.com/bet-blocker/bet-blocker/blob/main/main.py"
    click Orchestrator "https://github.com/bet-blocker/bet-blocker/blob/main/src/functions/blocker.py"
    click FirewallAdapter "https://github.com/bet-blocker/bet-blocker/blob/main/src/functions/firewall.py"
    click HostsAdapter "https://github.com/bet-blocker/bet-blocker/tree/main/hosts"
    click Blocklist "https://github.com/bet-blocker/bet-blocker/blob/main/blocklist.txt"
    click PathResolver "https://github.com/bet-blocker/bet-blocker/blob/main/src/utils/get_paths.py"
    click Logger "https://github.com/bet-blocker/bet-blocker/blob/main/src/utils/logs.py"
    click Deprecated "https://github.com/bet-blocker/bet-blocker/blob/main/src/functions/deprecated_functions.py"
    click Workflow "https://github.com/bet-blocker/bet-blocker/blob/main/.github/workflows/avoid_dup_bet.yml"
    click CICDScript "https://github.com/bet-blocker/bet-blocker/blob/main/_cicd/avoid_dup_bet.py"
    click Cleanup "https://github.com/bet-blocker/bet-blocker/blob/main/scripts/remove_duplicates.py"
    click UIStyling "https://github.com/bet-blocker/bet-blocker/blob/main/app/app_styles.py"
    click Documentation "https://github.com/bet-blocker/bet-blocker/blob/main/page/index.md"

    classDef core fill:#B3CDE0,stroke:#000,stroke-width:1px;
    classDef data fill:#C7E9C0,stroke:#000,stroke-width:1px;
    classDef external fill:#FBB4AE,stroke:#000,stroke-width:1px;
    classDef utils fill:#FEB24C,stroke:#000,stroke-width:1px;
    classDef cicd fill:#D9D9D9,stroke:#000,stroke-width:1px;
    classDef docs fill:#DEEBF7,stroke:#000,stroke-width:1px;
```
