# im-open/git-version-lite architecture

> Architecture diagram of the GitHub repository im-open/git-version-lite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/im-open/git-version-lite
- Repository: https://github.com/im-open/git-version-lite

## Overview

##### Main Components

a. Input Processing Layer
- Inputs like tag-prefix, branch-name, calculate-prerelease-version, etc.

b. Core Processing Components
- Git Interface Component (representing git-commands.js)
- Version Calculator Component (representing version.js)
- Main Orchestrator (representing main.js)

c. Output Generation Layer
- Version outputs (NEXT_VERSION, PRIOR_VERSION, etc.)

##### Component Relationships

**[GitHub Workflow] → [Input Processing] → [Main Orchestrator]**
- ↓
**[Git Repository] ← [Git Interface] ← → [Version Calculator]**
- ↓
- [Output Generation] → [GitHub Environment/Outputs]

##### Important Elements to Highlight

a. Version Calculation Logic:
- Version increment decision flow
- Commit message pattern matching
- Demonstrate the branching logic for release vs. pre-release

b. Git Integration:
- Interaction with git history
- Tag handling and prefix management

##### Technical Details

- Node.js runtime environment
- GitHub Actions integration points
- Git command execution flow
- Version pattern matching rules

##### Environment variable handling

This system design should help developers understand how the action processes inputs, interacts with git, calculates versions, and provides outputs to the GitHub Actions environment.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "GitHub Actions Environment"
        GHA["GitHub Workflow"]
        GHENV["GitHub Environment/Outputs"]
    end

    subgraph "Input Layer"
        INP["Action Inputs:<br/>tag-prefix<br/>branch-name<br/>calculate-prerelease"]:::input
    end

    subgraph "Core Processing"
        MAIN["Main Orchestrator"]:::core
        GIT["Git Interface"]:::core
        VCALC["Version Calculator"]:::core
    end

    subgraph "Git Layer"
        GREPO["Git Repository"]:::external
    end

    subgraph "Output Layer"
        OUT["Action Outputs:<br/>NEXT_VERSION<br/>PRIOR_VERSION<br/>IS_PRERELEASE"]:::output
    end

    subgraph "Documentation"
        DOC["Version Strategy:<br/>1. Extracts version from git history<br/>2. Analyzes commit messages<br/>3. Calculates next version<br/>4. Handles pre-release versions"]:::doc
    end

    GHA --> INP
    INP --> MAIN
    MAIN --> GIT
    MAIN --> VCALC
    GIT <--> GREPO
    GIT --> VCALC
    VCALC --> OUT
    OUT --> GHENV

    %% Click Events
    click INP "https://github.com/im-open/git-version-lite/blob/main/action.yml"
    click MAIN "https://github.com/im-open/git-version-lite/blob/main/src/main.js"
    click GIT "https://github.com/im-open/git-version-lite/blob/main/src/git-commands.js"
    click VCALC "https://github.com/im-open/git-version-lite/blob/main/src/version.js"
    click OUT "https://github.com/im-open/git-version-lite/blob/main/action.yml"
    click GHENV "https://github.com/im-open/git-version-lite/blob/main/dist/index.js"

    %% Styles
    classDef external fill:#a0d8ef
    classDef input fill:#98fb98
    classDef core fill:#ffa500
    classDef output fill:#98fb98
    classDef doc fill:#f0f0f0,stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        L1["External System"]:::external
        L2["Input/Output"]:::input
        L3["Core Component"]:::core
        L4["Documentation"]:::doc
    end
```
