# k1-end/git-reports architecture

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

- Interactive diagram: https://gitdiagram.com/k1-end/git-reports
- Repository: https://github.com/k1-end/git-reports

## Overview

##### Main Components
- CLI Command Handler – Represented by the files under the “cmd” directory (e.g., cmd/root.go, cmd/serve/serve.go). This component handles user input, command-line arguments (such as repository path, printer type, date filtering, etc.), and serves as the entry point to the tool.
- Main Application Controller – Shown by the “main.go” file, which sets up the application, parses the flags, and invokes the appropriate command.
- Report Representation – The “src/report” directory contains core data structures (e.g., Report.go) that encapsulate the collected Git metrics.
- Report Generators – The “src/reportgenerator” directory includes multiple generator modules (for commit heatmaps, per developer reports, file type analysis, etc.). Each generator is responsible for computing a specific metric or report.
- Report Printers – In “src/reportprinter”, you have implementations for outputting the generated report to various formats (ConsolePrinter.go, HtmlPrinter.go). Within this directory, the “templates” folder holds the HTML templates for rendering the output when the HTML printer is used.

##### Relationships and Interactions
- The CLI Command Handler (from “cmd” and triggered by main.go) parses arguments and then calls the main application logic.
- The main controller gathers input data (e.g., repository path, filters) and initializes the Report data structure.
- The Report Generators process the raw Git data and populate different parts of the Report object.
- After the Report is populated, the Report Printers are used to format and output the data. For instance, if the user selects HTML output (using the “--printer html” flag), the HtmlPrinter is invoked with the appropriate HTML templates.
- Data flows sequentially from user input -> command processing -> report generation -> report printing.

##### Architectural Patterns & Design Principles
- Separation of Concerns – The project neatly divides its functionality: CLI input, processing (report generation), and output (report printing) are clearly separated into different modules and directories.
- Modular Design – Each report generator (e.g., CommitCountDateHeatMapGenerator, CommitPerDevReportGenerator) is self-contained, allowing for easy extension or modification.
- Extensibility – Adding a new report type involves creating a new generator and updating the report printing logic if needed.

##### Relevant Technologies, Frameworks, and Libraries
- Go (Golang) – The entire app is built with standard Go libraries.
- Git – Although not directly specified, the tool works with Git repositories. Any Git interaction logic (parsing repositories, commits, etc.) would be part of the internal logic called by the generators.
- HTML/CSS – Used within the HtmlPrinter’s templates for output rendering.

##### Elements
- Clear Labels – Name each component (CLI, Main Controller, Report Generators, Report Printers, HTML Templates).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        CLI["CLI Command Handler"]:::input
        MC["Main Application Controller"]:::input
    end

    %% Processing Layer
    subgraph "Processing Layer"
        RG["Report Generators"]:::processing
        RR["Report Representation"]:::processing
    end

    %% Output Layer
    subgraph "Output Layer"
        RP["Report Printers"]:::output
        CP["Console Printer"]:::output
        HP["HTML Printer"]:::output
        HT["HTML Templates"]:::output
    end

    %% Connections - Vertical Flow
    CLI -->|"invokes"| MC
    MC -->|"processes"| RG
    RG -->|"populates"| RR
    RR -->|"passes data to"| RP
    RP -->|"outputs via"| CP
    RP -->|"outputs via"| HP
    HP -->|"renders using"| HT

    %% Click Events
    click CLI "https://github.com/k1-end/git-reports/tree/main/cmd/"
    click MC "https://github.com/k1-end/git-reports/blob/main/main.go"
    click RG "https://github.com/k1-end/git-reports/tree/main/src/reportgenerator/"
    click RR "https://github.com/k1-end/git-reports/blob/main/src/report/Report.go"
    click RP "https://github.com/k1-end/git-reports/tree/main/src/reportprinter/"
    click HT "https://github.com/k1-end/git-reports/tree/main/src/reportprinter/templates"

    %% Styles
    classDef input fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef processing fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef output fill:#8fbc8f,stroke:#333,stroke-width:2px;
```
