# kolunmi/bazaar architecture

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

- Interactive diagram: https://gitdiagram.com/kolunmi/bazaar
- Repository: https://github.com/kolunmi/bazaar

## Overview

##### Project Type and Purpose
- Type: Desktop GUI application (GTK4), written in C using GObject.
- Purpose: A Flatpak-focused “app store” for GNOME (“Bazaar”), providing configurable sections of Flatpak applications, handling installs/updates, and styling via custom CSS.

##### File Structure
- Top-level build: Meson build scripts (meson.build, meson_options.txt), Justfile, version.sh.
- Code organization:
– UI definitions (.ui files under src/ and src/gtk/)
– Application logic (.c/.h files prefixed bz-*)
– Configuration: YAML parser (bz-yaml-parser), content-provider schema & loader (bz-content-provider)
– Transaction manager (bz-transaction-manager)
– Backend wrapper (bz-backend) for Flatpak interactions
– Helper dialogs/views (bz-*-dialog.*, bz-*-view.*, bz-*-widget.*)
- Dev environment: .devcontainer for Docker; build-aux for Flatpak packaging.

##### Key Insights from README
- Loads “sections” from YAML configs (hot-reloaded via FS events).
- Interacts with Flatpak (via libflatpak or D-Bus).
- GTK CSS theming for custom styling.
- Uses Meson options to embed default config path.
- Intended to rival gnome-software’s Flatpak features.

##### Main Components & Their Interactions
- UI Layer
– Main Window (bz-window)
– Views & Widgets (browse, search, full-view, transaction view, dialogs)
– CSS Styling Engine (GTK CSS)
- Business Logic Layer
– Content Manager / Sections Loader (bz-content-provider, bz-yaml-parser)
– Transaction Manager (install/update/remove)
– Backend API Wrapper (bz-backend)
- Data & Persistence Layer
– Configuration Files (YAML) & gsettings (GSchema)
- External Services
– Flatpak Daemon (via D-Bus or libflatpak)
– File System (for config watching)

b. Relationships & Data Flows
- Startup: App reads Meson-provided default config path → YAML Parser → Content Manager builds section models
- FS Watcher → triggers re-parse on file change → UI auto-refresh
- UI actions (install/update) → Transaction Manager → Backend API → Flatpak Daemon
- Transaction events → propagate back to UI via signals (GObject signals)
- CSS snippets from config → GTK CSS Parser → style UI widgets

c. Architectural Patterns & Principles
- MVC/MVP-style separation: UI widgets separate from backend logic
- Observer pattern: File-system watchers and GSettings change notifications
- Command pattern: Transactions encapsulated in Transaction Manager
- GObject componentization: each “bz-*” module exposes a GObject interface

d. Key Technologies & Frameworks
- GTK4 (UI toolkit)
- GLib/GIO (signals, file-watching, GSettings, D-Bus)
- libflatpak or D-Bus API to Flatpak daemon
- Meson (build system)
- YAML-cpp or custom parser (bz-yaml-parser)

##### Detailed Elements
- Data stores: “YAML Config Files”, “GSettings Schema”
- External: “Flatpak Daemon (D-Bus)”, “FileSystem Watcher”
– Config Files → YAMLParser → ContentProvider → UI
– UI → TransactionManager → Backend → Flatpak Daemon → Backend → UI
– FS Watcher → ContentProvider
– CSS Config → GTK CSS Engine → UI
- Annotations: note hot-reload capability, Meson options for default config path.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainWindow["Main Window"]:::ui
        BrowseWidget["Browse Widget"]:::ui
        SearchWidget["Search Widget"]:::ui
        FullView["Full-View"]:::ui
        InstalledPage["Installed Page"]:::ui
        TransactionView["Transaction View"]:::ui
        AddonsDialog["Add-ons Dialog"]:::ui
        PreferencesDialog["Preferences Dialog"]:::ui
        ShareDialog["Share Dialog"]:::ui
        UpdateDialog["Update Dialog"]:::ui
        CSSStylingEngine["CSS Styling Engine"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        YAMLParser["YAML Parser"]:::logic
        ContentProvider["Content Provider"]:::logic
        ContentSectionModel["Content Section Model"]:::logic
        TransactionManager["Transaction Manager"]:::logic
        BackendAPI["Backend API Wrapper"]:::logic
    end

    %% Data & Persistence Layer
    subgraph "Data & Persistence Layer"
        direction TB
        YAMLConfigFiles["YAML Config Files"]:::data
        GSettingsSchema["GSettings Schema"]:::data
        GResource["GResource"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FlatpakDaemon["Flatpak Daemon (D-Bus)"]:::external
        FileSystemWatcher["File System Watcher"]:::external
    end

    %% Entry Point
    MainEntry["Application Entry Point\n(main.c)"]:::logic

    %% Connections
    MainEntry -->|initializes| YAMLParser
    YAMLConfigFiles -->|parse| YAMLParser
    YAMLParser -->|provides model| ContentProvider
    ContentSectionModel -->|used by| ContentProvider
    FileSystemWatcher -->|notifies| ContentProvider
    ContentProvider -->|feeds| MainWindow
    MainWindow -->|displays| BrowseWidget
    MainWindow -->|displays| SearchWidget
    MainWindow -->|displays| FullView
    MainWindow -->|displays| InstalledPage
    MainWindow -->|displays| TransactionView
    MainWindow -->|invokes| AddonsDialog
    MainWindow -->|invokes| PreferencesDialog
    MainWindow -->|invokes| ShareDialog
    MainWindow -->|invokes| UpdateDialog
    CSSStylingEngine -->|styles| MainWindow
    CSSStylingEngine -->|styles| BrowseWidget
    CSSStylingEngine -->|styles| SearchWidget
    MainWindow -->|UI action| TransactionManager
    TransactionManager -->|commands| BackendAPI
    BackendAPI -->|calls| FlatpakDaemon
    FlatpakDaemon -->|events| BackendAPI
    BackendAPI -->|signals| TransactionManager
    TransactionManager -->|updates| MainWindow

    %% Click Events
    click MainWindow "https://github.com/kolunmi/bazaar/blob/master/src/bz-window.c"
    click BrowseWidget "https://github.com/kolunmi/bazaar/blob/master/src/bz-browse-widget.c"
    click SearchWidget "https://github.com/kolunmi/bazaar/blob/master/src/bz-search-widget.c"
    click FullView "https://github.com/kolunmi/bazaar/blob/master/src/bz-full-view.c"
    click InstalledPage "https://github.com/kolunmi/bazaar/blob/master/src/bz-installed-page.c"
    click TransactionView "https://github.com/kolunmi/bazaar/blob/master/src/bz-transaction-view.c"
    click AddonsDialog "https://github.com/kolunmi/bazaar/blob/master/src/bz-addons-dialog.c"
    click PreferencesDialog "https://github.com/kolunmi/bazaar/blob/master/src/bz-preferences-dialog.c"
    click ShareDialog "https://github.com/kolunmi/bazaar/blob/master/src/bz-share-dialog.c"
    click UpdateDialog "https://github.com/kolunmi/bazaar/blob/master/src/bz-update-dialog.c"
    click CSSStylingEngine "https://github.com/kolunmi/bazaar/blob/master/src/gtk/styles.css"
    click ContentProvider "https://github.com/kolunmi/bazaar/blob/master/src/bz-content-provider.c"
    click ContentSectionModel "https://github.com/kolunmi/bazaar/blob/master/src/bz-content-section.c"
    click YAMLParser "https://github.com/kolunmi/bazaar/blob/master/src/bz-yaml-parser.c"
    click TransactionManager "https://github.com/kolunmi/bazaar/blob/master/src/bz-transaction-manager.c"
    click BackendAPI "https://github.com/kolunmi/bazaar/blob/master/src/bz-backend.c"
    click GResource "https://github.com/kolunmi/bazaar/blob/master/src/bazaar.gresource.xml"
    click GSettingsSchema "https://github.com/kolunmi/bazaar/blob/master/data/io.github.kolunmi.bazaar.gschema.xml"
    click FileSystemWatcher "https://github.com/kolunmi/bazaar/blob/master/src/bz-content-provider.c"
    click MainEntry "https://github.com/kolunmi/bazaar/blob/master/src/main.c"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#1976d2,stroke-width:2px
    classDef logic fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
    classDef data fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px
    classDef external fill:#cfd8dc,stroke:#607d8b,stroke-width:2px
```
