# jumpyvi/pilot-whale architecture

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

- Interactive diagram: https://gitdiagram.com/jumpyvi/pilot-whale
- Repository: https://github.com/jumpyvi/pilot-whale

## Overview

##### Project Type and Purpose
Pilot Whale is a **desktop application** designed for **managing Docker containers**. It provides functionalities such as starting/stopping containers, viewing logs, and searching/pulling images from DockerHub. The application is built using **GTK4** and **libadwaita**, and it leverages **Vala** as the primary programming language.

##### File Structure Analysis
- **Top-Level Directories:**
- `.devcontainer`: Configuration for development environments.
- `.github`: GitHub workflows for CI/CD.
- `src`: Source code organized into submodules.
- `po`: Localization files.
- `vapi`: Vala API files.

- **Key Files and Configuration:**
- `meson.build`: Build configuration using Meson.
- `README.md`: Project documentation.
- `Justfile`: Defines tasks using Just.

- **Source Code Organization (`src` Directory):**
- **Docker**: Handles Docker API interactions (`ApiClient.vala`, `ContainerLogWatcher.vala`).
- **State**: Manages application state (`Root.vala`, `ScreenMain.vala`).
- **Utilities**: Utility functions and helpers (`ActionHandler.vala`, `HttpClient.vala`).
- **Widgets**: UI components and dialogs (`Dialogs`, `Screens`, `Utils`).

##### README Insights
- **Description:** Emphasizes basic Docker management functionalities.
- **Development:** Utilizes a devcontainer for consistent development environments.
- **Building:** Uses Meson and Ninja for building, with `just` for task automation.
- **Dependencies:** Lists various GTK4, libadwaita, and Vala-related dependencies.

**a. Identify Main Components:**
- **Frontend (UI Layer):**
- **Widgets:** Dialogs, Screens, and UI components built with GTK4.
- **Stylesheets:** CSS files for UI styling.
- **Backend (Logic Layer):**
- **Docker Module:** Handles interactions with Docker APIs.
- **State Management:** Maintains the application's state and screens.
- **Utilities:** Helper functions for actions, HTTP requests, and sorting.
- **Data Layer:**
- **Localization:** PO files for language support.
- **Build and Deployment:**
- **Meson Build System:** Manages build configurations.
- **CI/CD Workflows:** GitHub Actions for automated builds.
- **Devcontainer:** Development environment setup.

**b. Determine Relationships and Interactions:**
- **Frontend ↔ Backend:**
- Widgets communicate with backend modules to perform actions like starting/stopping containers.
- **Backend ↔ Docker:**
- The Docker module interacts with Docker APIs to manage containers.
- **Utilities ↔ Backend:**
- Utilities provide support functions for backend operations.
- **Data ↔ Frontend:**
- UI components use resources and stylesheets for rendering.

**c. Highlight Architectural Patterns:**
- **Modular Architecture:** Separation of concerns with distinct modules for Docker interactions, state management, utilities, and UI components.
- **MVC-Like Pattern:** While not strictly MVC, there's a clear separation between the UI (View), application state (Controller), and backend logic (Model).

**d. Include Relevant Technologies:**
- **Programming Language:** Vala
- **UI Framework:** GTK4, libadwaita
- **Build Tools:** Meson, Ninja
- **Task Automation:** Just
- **Version Control & CI/CD:** GitHub, GitHub Actions
- **Container Management:** Docker APIs

##### Elements
- **Clear Labels:** Name each component (e.g., Widgets, Docker Module, State Management).

##### Detail Orientation
- Breaking down main modules into sub-components where necessary (e.g., Utilities can include ActionHandler, HttpClient).
- Capturing all interactions, especially between the UI and Docker APIs.
- Including build and development components to provide a complete architectural view.

##### Final Recommendations
- Review the file structure and README to ensure all critical parts of the system are represented.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Subgraphs and modules
    subgraph "Frontend (UI Layer)"
        Widgets["Widgets"]:::frontend
        Stylesheets["Stylesheets"]:::frontend
    end

    subgraph "Backend (Logic Layer)"
        DockerModule["Docker Module"]:::backend
        StateManagement["State Management"]:::backend
        Utilities["Utilities"]:::utilities
    end

    subgraph "Data Layer"
        Resources["Resources"]:::data
        Localization["Localization"]:::data
    end

    subgraph "Build and Deployment"
        MesonBuildSystem["Meson Build System"]:::build
        CICDWorkflows["CI/CD Workflows"]:::build
        Devcontainer["Devcontainer"]:::build
    end

    %% External Entities
    DockerAPIs["Docker APIs"]:::external

    %% Connections
    Widgets -->|"communicates with"| StateManagement
    Widgets -->|"communicates with"| DockerModule
    StateManagement -->|"uses"| Utilities
    DockerModule -->|"interacts with"| DockerAPIs
    Widgets -->|"uses"| Resources
    Widgets -->|"uses"| Stylesheets
    Resources -->|"includes"| Localization
    MesonBuildSystem -->|"builds"| Widgets
    MesonBuildSystem -->|"builds"| DockerModule
    CICDWorkflows -->|"uses"| MesonBuildSystem
    Devcontainer -->|"sets up"| DevelopmentEnvironment["Development Environment"]:::external

    %% Click Events
    click Widgets "https://github.com/jumpyvi/pilot-whale/tree/master/src/Widgets"
    click Stylesheets "https://github.com/jumpyvi/pilot-whale/tree/master/data/resources/stylesheets"
    click DockerModule "https://github.com/jumpyvi/pilot-whale/tree/master/src/Docker"
    click StateManagement "https://github.com/jumpyvi/pilot-whale/tree/master/src/State"
    click Utilities "https://github.com/jumpyvi/pilot-whale/tree/master/src/Utilities"
    click Resources "https://github.com/jumpyvi/pilot-whale/tree/master/data/resources"
    click Localization "https://github.com/jumpyvi/pilot-whale/tree/master/po"
    click MesonBuildSystem "https://github.com/jumpyvi/pilot-whale/blob/master/meson.build"
    click CICDWorkflows "https://github.com/jumpyvi/pilot-whale/tree/master/.github/workflows"
    click Devcontainer "https://github.com/jumpyvi/pilot-whale/blob/master/.devcontainer"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef backend fill:#82E0AA,stroke:#333,stroke-width:2px;
    classDef utilities fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef build fill:#D7BDE2,stroke:#333,stroke-width:2px;
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:2px;

    class Widgets,Stylesheets frontend
    class DockerModule,StateManagement backend
    class Utilities utilities
    class Resources,Localization data
    class MesonBuildSystem,CICDWorkflows,Devcontainer build
    class DockerAPIs,DevelopmentEnvironment external
```
