# zbrateam/zebra architecture

> Architecture diagram of the GitHub repository zbrateam/zebra, 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/zbrateam/zebra
- Repository: https://github.com/zbrateam/zebra

## Overview

Based on analyzing the file tree and the README, Zebra is an iOS/macOS package manager for jailbroken devices that interfaces with the APT/dpkg system. The project is built using Xcode (with both an .xcodeproj and an .xcworkspace), and it follows an MVC-inspired structure through its Controllers, Views (under UI and Tabs), Models, and supporting Helpers/Utilities/Extensions. In addition, there are helper subprojects (under “Catalyst Helper”, “Relaunch”, and “Supersling”) that likely serve as auxiliary binaries or modules to support launching, updating, or other package operations. The extensive asset catalog, localization resources, and organization of UI elements (multiple Tabs for Home, Browse, Packages, Sources, etc.) further indicate the project’s complexity in presenting a rich user interface for package management.

- Application Entry Points: Include the App Delegate (ZBAppDelegate, BaseSceneDelegate, PackageSceneDelegate) which kickstarts the app, and scene delegates that handle UI scene life cycle.
- Controllers and Business Logic: Include Controllers for app management, HTTP requests, notifications, device commands, and plain utilities (like job queues and source refresh controllers). This layer mediates between the UI and the underlying logic.
- Models: Include the Model folder components that represent package and source data structures, filters, and JSON parsing modules.
- Helper Binaries/Secondary Modules: Highlight the separate modules such as “Catalyst Helper”, “Relaunch”, and “Supersling”. These are likely helper executables or libraries used for tasks that might require separate privileges or context (for example, safely relaunching or interfacing with underlying package management systems during installation or updates).
- Build and Configuration: Incorporate build configuration elements like Makefiles, the Xcode project structure, and GitHub workflows to indicate the build and deployment processes.

##### Relationships and Data Flow
- Interaction between Controllers and Models (for fetching package data, updating filters, etc.).
- How Controllers interact with the HTTP/Network layer to fetch data from remote sources or updates.
- Communication flows with external systems (the APT/dpkg system) and how the helpers (e.g., Relaunch, Supersling) work as separate processes that may get invoked by the main app.
- Integration points such as notifications (ZBNotificationManager) that broadcast events across the system.
- Dependency on configuration and build tools (Makefiles, project settings) which are used during development and deployment.

##### Architectural Patterns/Design Principles
- MVC/MVVM Separation: Clearly delineate the controllers, views, and models even if some logic resides in utility classes.
- Modularity: Show how helper modules (Catalyst Helper, Relaunch, Supersling) run side-by-side with the main app, perhaps in a microservices-like or modular helper architecture.
- Code Reuse and Extensions: Capture the use of numerous extensions and utility modules that add common functionality to built-in classes.

##### Incorporate Technology, Frameworks, and External Dependencies
- That this is an iOS/macOS app built using Xcode with Swift and objective-C interop (look at .swift, .h, .m, .mm files).
- Mention Theos and Procursus for different build targets (jailbroken iOS devices and macOS builds).
- Integration with APT/dpkg under the hood for package management.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Application Layer
    subgraph "Application Layer"
        AEP("Application Entry Points") 
    end

    %% UI Layer
    subgraph "UI Layer"
        UI("Tabs & UI Modules")
    end

    %% Controller Layer
    subgraph "Controller Layer"
        CTRL("Controllers & Business Logic")
    end

    %% Data Layer
    subgraph "Data Layer"
        MODEL("Models")
    end

    %% Helper Layer
    subgraph "Helper Layer"
        HELP("Extensions")
        UTL("Utilities")
    end

    %% Helper Binaries
    subgraph "Helper Binaries"
        CAT("Catalyst Helper")
        REL("Relaunch")
        SUP("Supersling")
    end

    %% Resources
    subgraph "Resources"
        RES("Assets & Localization")
    end

    %% Build and Configuration
    subgraph "Build & Config"
        BP("Xcode Projects")
        MAKE("Makefile & Workflows")
    end

    %% External Systems
    APT("APT/dpkg System") 

    %% Connections (vertical flow)
    AEP -->|"launchesUI"| UI
    UI -->|"userActions"| CTRL
    CTRL -->|"fetchData"| MODEL
    CTRL -->|"aptIntegration"| APT
    CTRL -->|"invokeHelper"| CAT
    HELP -->|"supports"| CTRL
    UTL -->|"supports"| CTRL
    UI -->|"usesAssets"| RES
    BP -->|"buildsLaunch"| AEP
    BP -->|"configures"| UI
    MAKE -->|"drivesBuild"| BP

    %% Classes and Colors
    class AEP appEntry
    class UI ui
    class CTRL controller
    class MODEL model
    class HELP helper
    class UTL helper
    class CAT helper
    class REL helper
    class SUP helper
    class BP build
    class MAKE build
    class RES resource
    class APT external

    %% Class Definitions
    classDef appEntry fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef controller fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef model fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef helper fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef build fill:#A9A9A9,stroke:#000,stroke-width:2px;
    classDef resource fill:#DA70D6,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-dasharray: 5 5,stroke-width:2px;

    %% Click Events
    click AEP "https://github.com/zbrateam/zebra/tree/main/Zebra/Controllers/App"
    click UI "https://github.com/zbrateam/zebra/tree/main/Zebra/Tabs"
    click CTRL "https://github.com/zbrateam/zebra/tree/main/Zebra/Controllers"
    click MODEL "https://github.com/zbrateam/zebra/tree/main/Zebra/Model"
    click HELP "https://github.com/zbrateam/zebra/tree/main/Zebra/Extensions"
    click UTL "https://github.com/zbrateam/zebra/tree/main/Zebra/Utilities"
    click CAT "https://github.com/zbrateam/zebra/tree/main/Catalyst Helper"
    click REL "https://github.com/zbrateam/zebra/tree/main/Relaunch"
    click SUP "https://github.com/zbrateam/zebra/tree/main/Supersling"
    click RES "https://github.com/zbrateam/zebra/blob/main/Zebra/Assets.xcassets"
    click BP "https://github.com/zbrateam/zebra/blob/main/Zebra.xcodeproj"
    click MAKE "https://github.com/zbrateam/zebra/tree/main/Makefile"
```
