# muhammad-noraeii/mojo-browser architecture

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

- Interactive diagram: https://gitdiagram.com/muhammad-noraeii/mojo-browser
- Repository: https://github.com/muhammad-noraeii/mojo-browser

## Overview

##### Main Components
- User Interface (UI) Module: Represented by the PyQt5-based main window (launched from main.py). This includes all UI elements such as toolbars, navigation buttons, tabbed browsing, settings dialogs, and pop-up windows.
- Core Browser Engine: This manages web page loading and rendering (likely leveraging QtWebEngineWidgets). Although this is abstracted behind PyQt5, it is a key architectural component.
- Privacy Module: Look at files like MojoPrivacy.py; this module implements privacy features such as tracker blocking, HTTPS enforcement, fingerprint protection, proxy support, and data clearing. Illustrate it as an independent component that interconnects with the core engine and network layer.
- Configuration and Storage: This includes various JSON files used to store settings (settings.json), bookmarks (bookmarks.json), history (history.json), privacy settings (privacy_settings.json), extension status (extension_status.json), extension cache (extension_cache.json), and proxy cache (proxy_cache.json). Represent these as persistent storage components.
- External Dependencies: Note the reliance on external libraries such as PyQt5, PyQtWebEngine, and requests. These should be shown as foundational layers that support the UI and network operations.

##### Relationships and Data Flow
- External libraries (PyQt5, PyQtWebEngine, requests) provide the underlying functionality. Represent these as external blocks that feed into the UI and networking components.

##### Architectural Patterns and Technologies
- Configuration Files as Dynamic Components: Because many settings and caches are stored in JSON files, add labels to the storage component to highlight their role in runtime configuration and state persistence.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    ExternalDep["External Dependencies (Python libraries)"]:::external

    %% Frontend Layer
    subgraph "Frontend"
        UI["Main UI (main.py)"]:::ui
    end

    %% Core Engine Layer
    subgraph "Core Engine"
        Engine["Browser Engine (QtWebEngine)"]:::engine
        Privacy["Privacy Module (MojoPrivacy.py)"]:::privacy
        Extensions["Extensions Manager (MojoX)"]:::extension
    end

    %% Persistent Storage Layer
    subgraph "Persistent Storage"
        Storage["Configuration & Storage (JSON Files)"]:::storage
    end

    %% Data flow arrows
    ExternalDep -->|"supports"| UI
    ExternalDep -->|"supports"| Engine

    UI -->|"navigates_to"| Engine
    Engine -->|"filters_requests"| Privacy
    Extensions -->|"injects_js"| Engine
    Extensions -->|"enhances_UI"| UI

    UI <-->|"read_write"| Storage
    Engine <-->|"read_write"| Storage
    Extensions <-->|"read_write"| Storage

    %% Click Events
    click UI "https://github.com/muhammad-noraeii/mojo-browser/blob/main/main.py"
    click Engine "https://github.com/muhammad-noraeii/mojo-browser/blob/main/main.py"
    click Privacy "https://github.com/muhammad-noraeii/mojo-browser/blob/main/MojoPrivacy.py"
    click Extensions "https://github.com/muhammad-noraeii/mojo-browser/blob/main/addon.py"
    click Storage "https://github.com/muhammad-noraeii/mojo-browser/tree/main/datas/"
    click ExternalDep "https://github.com/muhammad-noraeii/mojo-browser/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef engine fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef privacy fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef extension fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef storage fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#ffeeba,stroke:#f0ad4e,stroke-width:2px;
```
