# devnoname120/vhbb architecture

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

- Interactive diagram: https://gitdiagram.com/devnoname120/vhbb
- Repository: https://github.com/devnoname120/vhbb

## Overview

##### Project Type & Purpose
- VHBB is a native PS Vita application serving as an app store that lets users browse and install homebrew applications from the VitaDB.
- The README explains that it is built with vitasdk, supports debug logging (via debugnet and file logging), and is compiled using CMake. It also emphasizes handling of specialized assets (images, fonts, sounds) and the packaging into a VPK for installation on the device.
- The project is organized as a full application with a graphical user interface on the Vita, together with various threads and network capabilities.

##### Analyzing the File Structure
- The source code is primarily located under the /src directory. Notice that the /src/Views subdirectory holds many UI components (CategoryView, HomebrewView, ListView, etc.), indicating adherence to a separation of UI concerns.
- Other core components spread across the src folder include modules for networking (network.cpp/h), database operations (database.cpp/h), concurrency (concurrency.cpp/h), file system handling (filesystem.cpp/h), installation threads (install_thread, fetch_load_icons_thread, nosleep_thread), and miscellaneous utilities.
- The project also contains additional components like src_updater (likely a separate process or module to handle updating the application) and tools (which includes PNG optimization utilities and examples).

##### Defining Main Components
a. User Interface Layer:
- Collection of Views (CategoryView, HomebrewView, ListView, IMEView, ProgressView, mainView, dialogView, splash, statusBar, etc.).
- That the UI layer is responsible for displaying homebrew items, details, and interactive elements.
b. Application Core / Business Logic:
- Modules like activity.cpp, homebrew.cpp, homebrewDownload.cpp, homebrewRelease.cpp, and update.cpp handle the core functionality of the app (browsing, downloading and updating homebrew applications).
c. Data Management:
- The database.cpp/h module likely abstracts access to the VitaDB data.
- Filesystem and asset management (filesystem.cpp, assets directory) should be depicted as supporting modules.
d. Networking & Communication:
- The network.cpp/h handles any online connectivity to fetch data from VitaDB.
- Debug/logging mechanisms (debug.cpp, debugnet integration instructions in README) should be noted.
e. Concurrency & Thread Management:
- Various threads such as install_thread, fetch_load_icons_thread, and nosleep_thread are used to maintain responsiveness and perform background operations.
f. Packaging and Deployment:
- The build system is based on CMake (CMakeLists.txt files in the root and src_updater).
- Release-related directories and configuration files (release/version.yml, sce_sys for Vita livearea configurations) should be shown indicating how the packaged VPK is structured and deployed.
g. Ancillary Components:
- The updater module (src_updater) provides an example of how the application is refreshed or debugged.
- External tools under the /tools directory indicate helper scripts and utilities (like PNGO for image optimization).

##### Architectural Relationships & Interactions
- How user interactions trigger UI components to forward requests to the app core.
- How the application core makes network requests (illustrate connections from network module to VitaDB) and database queries.
- Concurrency components (background threads) interacting with update and installation operations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interface (Views)"]:::ui
    end

    %% Core Services Layer
    subgraph "Core Services Layer"
        subgraph "Application Core"
            A1["homebrew.cpp"]:::core
            A2["homebrewDownload.cpp"]:::core
            A3["homebrewRelease.cpp"]:::core
            A4["update.cpp"]:::core
            A5["activity.cpp"]:::core
        end
        subgraph "Data Management"
            DB["database.cpp/h"]:::data
            FS["filesystem.cpp/h"]:::data
            AS["assets (Asset Manager)"]:::data
        end
        subgraph "Networking & Communication"
            NM["network.cpp/h (Network Module)"]:::network
            DBG["debug.cpp/h (Debug Logger)"]:::network
        end
        subgraph "Concurrency & Threads"
            CONC["concurrency.cpp/h (Concurrency Manager)"]:::thread
            IT["install_thread.cpp/h"]:::thread
            FLIT["fetch_load_icons_thread.cpp/h"]:::thread
            NST["nosleep_thread.cpp/h"]:::thread
        end
    end

    %% Packaging & Deployment
    subgraph "Packaging & Deployment"
        CB["CMakeLists.txt (Root)"]:::packaging
        CP["CMakeLists.txt (src_updater)"]:::packaging
        REL["release/version.yml"]:::packaging
        SYS["sce_sys (Vita LiveArea)"]:::packaging
    end

    %% Ancillary Components
    subgraph "Ancillary Components"
        UPD["src_updater (Updater Module)"]:::ancillary
        TOOL["tools (External Tools)"]:::ancillary
    end

    %% Relationships & Data Flow
    UI -->|"triggers"| A1
    A1 -->|"queries"| DB
    A1 -->|"requests"| NM
    A1 -->|"invokes"| CONC
    AS -->|"supplies assets to"| UI
    %% Packaging links
    CB -->|"builds"| UI
    CB -->|"builds"| A1
    CP -->|"updates"| UPD
    CB --> REL
    CB --> SYS

    %% Styles
    classDef ui fill:#a3d5ff,stroke:#333,stroke-width:2px;
    classDef core fill:#c3f7a3,stroke:#333,stroke-width:2px;
    classDef data fill:#f7d3a3,stroke:#333,stroke-width:2px;
    classDef network fill:#f7a3a3,stroke:#333,stroke-width:2px;
    classDef thread fill:#d3a3f7,stroke:#333,stroke-width:2px;
    classDef packaging fill:#dff7a3,stroke:#333,stroke-width:2px;
    classDef ancillary fill:#a3f7df,stroke:#333,stroke-width:2px;

    %% Click Events
    click UI "https://github.com/devnoname120/vhbb/tree/master/src/Views"
    click A1 "https://github.com/devnoname120/vhbb/blob/master/src/homebrew.cpp"
    click A2 "https://github.com/devnoname120/vhbb/blob/master/src/homebrewDownload.cpp"
    click A3 "https://github.com/devnoname120/vhbb/blob/master/src/homebrewRelease.cpp"
    click A4 "https://github.com/devnoname120/vhbb/blob/master/src/update.cpp"
    click A5 "https://github.com/devnoname120/vhbb/blob/master/src/activity.cpp"
    click DB "https://github.com/devnoname120/vhbb/blob/master/src/database.cpp"
    click FS "https://github.com/devnoname120/vhbb/blob/master/src/filesystem.cpp"
    click AS "https://github.com/devnoname120/vhbb/tree/master/assets"
    click NM "https://github.com/devnoname120/vhbb/blob/master/src/network.cpp"
    click DBG "https://github.com/devnoname120/vhbb/blob/master/src/debug.cpp"
    click CONC "https://github.com/devnoname120/vhbb/blob/master/src/concurrency.cpp"
    click IT "https://github.com/devnoname120/vhbb/blob/master/src/install_thread.cpp"
    click FLIT "https://github.com/devnoname120/vhbb/blob/master/src/fetch_load_icons_thread.cpp"
    click NST "https://github.com/devnoname120/vhbb/blob/master/src/nosleep_thread.cpp"
    click CB "https://github.com/devnoname120/vhbb/blob/master/CMakeLists.txt"
    click CP "https://github.com/devnoname120/vhbb/tree/master/src_updater"
    click REL "https://github.com/devnoname120/vhbb/blob/master/release/version.yml"
    click SYS "https://github.com/devnoname120/vhbb/tree/master/sce_sys"
    click UPD "https://github.com/devnoname120/vhbb/tree/master/src_updater"
    click TOOL "https://github.com/devnoname120/vhbb/tree/master/tools"
```
