# bupd/git-donkey architecture

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

- Interactive diagram: https://gitdiagram.com/bupd/git-donkey
- Repository: https://github.com/bupd/git-donkey

## Overview

##### Project Type & Purpose
- Git-donkey is a CLI tool that automates the management of local git repositories by scanning local directories, identifying GitHub repos, and ensuring local branches are synchronized with their remotes.
- The README indicates its core functionality is triggered via commands (for example, “git-donkey scan”), and it leverages Golang along with libraries like cobra (for CLI command handling) and gogit (to interact with git repositories).

##### File Structure Analysis
- Top-Level Components:
- Root-level files such as LICENSE, README.md, main.go, and go.mod/go.sum suggest a Go project.
- The /cmd directory holds the bulk of the CLI command implementations and supports modular commands:
▸ The “program” subdirectory contains core logic files (e.g., program.go, sessioniser.go, gitTypes.go) that likely handle the scanning, session management, and git operations.
▸ Additional command files like scan.go and version.go indicate separate functionalities invoked via the CLI.
▸ The “ui” folder within cmd (with subdirectories listdirs and multiinputs) suggests specialized user interaction components for listing directories or handling multi-input scenarios.
- CI/CD and Build Automation:
- The .github/workflows files denote automated linting, auditing, and code quality checks, indicating integration with GitHub Actions.
- Dagger Component:
- The dagger directory appears to be an alternate entry point or a specific build/deployment configuration using Dagger (with its own Go module files and main.go). This may be used for containerized builds or CI-specific tasks.

##### Final Advice to the Principal Software Engineer
- Keep the design flexible enough for future extension while accurately depicting the current project structure.
- Periodically cross-check with the README and file structure to ensure that all references (such as dependencies on cobra and gogit) are correctly represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI Interface (cobra)"]:::cli
    end

    %% Command Handlers
    subgraph "Command Handlers"
        ScanCmd["Scan Command Handler"]:::command
        VersionCmd["Version Command Handler"]:::command
    end

    %% Backend Processing
    subgraph "Backend Processing"
        CoreLogic["Program Core Logic"]:::backend
        GitOps["Git Operations Module (gogit)"]:::backend
    end

    %% UI Components
    subgraph "UI Components"
        ListUI["Directory Listing UI"]:::ui
        MultiInputUI["Multi-input UI"]:::ui
    end

    %% External Services
    CICD["CI/CD Workflows"]:::cicd
    Dagger["Dagger Integration"]:::dagger

    %% Connections
    CLI -->|"routes"| ScanCmd
    CLI -->|"routes"| VersionCmd

    ScanCmd -->|"invokes_core_logic"| CoreLogic
    VersionCmd -->|"invokes_core_logic"| CoreLogic

    ScanCmd -->|"calls_git_ops"| GitOps
    VersionCmd -->|"calls_git_ops"| GitOps

    CoreLogic -->|"fetches_data"| GitOps

    ScanCmd -->|"updates_UI"| ListUI
    VersionCmd -->|"updates_UI"| MultiInputUI

    %% Linking external services
    CLI -->|"build_trigger"| CICD
    Dagger -->|"orchestrates_build"| CLI

    %% Click Events
    click CLI "https://github.com/bupd/git-donkey/blob/main/main.go"
    click CLI "https://github.com/bupd/git-donkey/blob/main/cmd/root.go"
    click ScanCmd "https://github.com/bupd/git-donkey/blob/main/cmd/scan.go"
    click VersionCmd "https://github.com/bupd/git-donkey/blob/main/cmd/version.go"
    click GitOps "https://github.com/bupd/git-donkey/blob/main/cmd/program/gitTypes.go"
    click GitOps "https://github.com/bupd/git-donkey/blob/main/cmd/program/sessioniser.go"
    click CoreLogic "https://github.com/bupd/git-donkey/blob/main/cmd/program/program.go"
    click ListUI "https://github.com/bupd/git-donkey/blob/main/cmd/ui/listdirs/listDirs.go"
    click MultiInputUI "https://github.com/bupd/git-donkey/blob/main/cmd/ui/multiinputs/multiinputs.go"
    click CICD "https://github.com/bupd/git-donkey/tree/main/.github/workflows"
    click Dagger "https://github.com/bupd/git-donkey/tree/main/dagger"

    %% Styles
    classDef cli fill:#f9d423,stroke:#333,stroke-width:2px,color:black;
    classDef command fill:#f08a5d,stroke:#333,stroke-width:2px,color:black;
    classDef backend fill:#B83B5E,stroke:#333,stroke-width:2px,color:white;
    classDef ui fill:#6A2C70,stroke:#333,stroke-width:2px,color:white;
    classDef cicd fill:#17a2b8,stroke:#333,stroke-width:2px,color:white;
    classDef dagger fill:#f8b195,stroke:#333,stroke-width:2px,color:black;
```
