# jdx/demand architecture

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

- Interactive diagram: https://gitdiagram.com/jdx/demand
- Repository: https://github.com/jdx/demand

## Overview

##### Main Components
- Core Library (src directory): This contains the backend logic for different prompt types. Modules such as confirm.rs, dialog.rs, input.rs, list.rs, multiselect.rs, select.rs, spinner.rs, and theme.rs encapsulate functionality for various prompt interfaces.
- Asset Management (assets directory): Holds assets for the prompt animations and themes. Notice there are files that define specific UI behavior such as confirm.tape, input.tape, themes, etc.
- Examples (examples directory): Provides usage samples for each feature (confirm, dialog, input, list, etc.) – these serve as a supplemental view of how the library components interact with a client’s code.
- CI/CD & DevOps ( .github folder, Cargo.toml, etc. ): Contains configuration for automated testing, builds, dependency management, and release notes (CHANGELOG.md, LICENSE, etc.).

##### Relationships and Interactions
- The build and CI configuration files (e.g., Cargo.toml, .github/workflows) enable continuous integration, testing, and packaging. It’s valuable to show these as external support systems interacting with the overall project to ensure stability and quality.

##### Architectural Patterns and Design Principles
- Extensibility: The design allows users to define custom behavior (e.g., setting up custom themes and input validations). This can be shown by highlighting extension points.
- Separation of Concerns: The presentation layers (assets and themes) are clearly separate from the logical processing (input handling, validation, and display logic).
- Testing & Continuous Integration: The .github workflows and CI configuration ensure code quality. This external system interacts regularly with the code repository via the test (src/test.rs) and other validation files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Demand Prompt Library System

    subgraph "Demand Prompt Library"
        %% Core Library Subgraph
        subgraph "Core Library"
            direction TB
            input_module["Input Module"]:::api
            confirm_module["Confirm Module"]:::api
            dialog_module["Dialog Module"]:::api
            list_module["List Module"]:::api
            select_module["Select Module"]:::api
            multiselect_module["MultiSelect Module"]:::api
            spinner_module["Spinner Module"]:::api
            theme_module["Theme Module"]:::api
            option_module["Option Utility"]:::util
            ctrlc_module["CtrlC Utility"]:::util
            ctrlc_stub_module["CtrlC Stub Utility"]:::util
        end

        %% Asset Manager Subgraph
        subgraph "Asset Manager"
            direction TB
            asset_manager["Assets (Prompts/Themes)"]:::asset
        end

        %% Examples Subgraph
        subgraph "Examples"
            direction TB
            examples["Usage Examples"]:::example
        end

        %% CI/CD & DevOps Subgraph
        subgraph "CI/CD & DevOps"
            direction TB
            cicd["CI/CD & Build Config"]:::cicd
        end
    end

    %% Relationships
    %% Examples invoking Core API Modules
    examples -->|"invokes"| input_module
    examples -->|"invokes"| confirm_module
    examples -->|"invokes"| dialog_module
    examples -->|"invokes"| list_module
    examples -->|"invokes"| select_module
    examples -->|"invokes"| multiselect_module
    examples -->|"invokes"| spinner_module
    examples -->|"invokes"| theme_module

    %% Core API Modules depend on Asset Manager for UI assets
    input_module -->|"uses assets"| asset_manager
    confirm_module -->|"uses assets"| asset_manager
    dialog_module -->|"uses assets"| asset_manager
    list_module -->|"uses assets"| asset_manager
    select_module -->|"uses assets"| asset_manager
    multiselect_module -->|"uses assets"| asset_manager
    spinner_module -->|"uses assets"| asset_manager
    theme_module -->|"uses assets"| asset_manager

    %% CI/CD interacts with Core Library (for testing/builds)
    cicd -->|"tests/builds"| input_module
    cicd -->|"tests/builds"| confirm_module
    cicd -->|"tests/builds"| dialog_module
    cicd -->|"tests/builds"| list_module
    cicd -->|"tests/builds"| select_module
    cicd -->|"tests/builds"| multiselect_module
    cicd -->|"tests/builds"| spinner_module
    cicd -->|"tests/builds"| theme_module

    %% Class Definitions with Colors/Styles
    classDef api fill:#A2D9CE,stroke:#1E8449,stroke-width:2px;
    classDef util fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef asset fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef example fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef cicd fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;

    %% Click Events
    click input_module "https://github.com/jdx/demand/blob/main/src/input.rs"
    click confirm_module "https://github.com/jdx/demand/blob/main/src/confirm.rs"
    click dialog_module "https://github.com/jdx/demand/blob/main/src/dialog.rs"
    click list_module "https://github.com/jdx/demand/blob/main/src/list.rs"
    click select_module "https://github.com/jdx/demand/blob/main/src/select.rs"
    click multiselect_module "https://github.com/jdx/demand/blob/main/src/multiselect.rs"
    click spinner_module "https://github.com/jdx/demand/blob/main/src/spinner.rs"
    click theme_module "https://github.com/jdx/demand/blob/main/src/theme.rs"
    click option_module "https://github.com/jdx/demand/blob/main/src/option.rs"
    click ctrlc_module "https://github.com/jdx/demand/blob/main/src/ctrlc.rs"
    click ctrlc_stub_module "https://github.com/jdx/demand/blob/main/src/ctrlc_stub.rs"
    click asset_manager "https://github.com/jdx/demand/tree/main/assets"
    click examples "https://github.com/jdx/demand/tree/main/examples"
    click cicd "https://github.com/jdx/demand/blob/main/.github"
```
