# helabenkhalfallah/code-health-meter architecture

> Architecture diagram of the GitHub repository helabenkhalfallah/code-health-meter, 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/helabenkhalfallah/code-health-meter
- Repository: https://github.com/helabenkhalfallah/code-health-meter

## Overview

##### Main Components
- • Core Engine (src/index.js): This is the entry point that orchestrates the scanning process.
- • Audit Modules (located under src/kernel):
- Complexity Analysis (src/kernel/complexity): Contains CodeComplexityAuditor, CodeComplexityConfig, and utility functions.
- Duplication Analysis (src/kernel/duplication): Contains CodeDuplicationAuditor for detecting redundant code blocks using the Rabin–Karp algorithm.
- Modularity Analysis (src/kernel/modularity): Contains CodeModularityAuditor and its configuration and helper files for assessing dependencies and coupling.
- • Common Utilities (src/commons): These include shared functions and utilities such as AppLogger, AuditUtils, and Matcher, which support logging, common audit utilities, and pattern matching across different modules.
- • Testing & Reporting: The tests directory contains various mock scans and sample projects along with pre-generated HTML and JSON report examples. This validates how the core engine processes and outputs its analyses.

##### Relationships and Data Flow
- • Show the Core Engine as the central orchestrator that invokes each audit module.
- • Include Report Generation as a component that collects the outcomes of all audits and formats them into either JSON or HTML, based on configuration parameters passed via the CLI (as shown in the README usage).

##### Architectural Patterns and Technologies
- • Modular Design: The separation into distinct audit modules (complexity, duplication, modularity) shows a clear separation of concerns.
- • Extensibility: The use of configuration files and shared utilities hints at a design that can be expanded. New audit modules can be incorporated following the established pattern.
- • Integration with External Tools: Note the Graphviz dependency mentioned in the README, which is used for graph-based analysis and visualization.
- • Command Line Interface (CLI): The provided npm and pnpm scripts show that the tool is designed to be run via a command-line interface, receiving parameters such as source directory, output directory, and output format.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Code Health Meter"
        subgraph "Analysis Engine"
            direction TB
            engine["Core Engine (src/index.js)"]:::engineStyle
            complexity["Complexity Auditor"]:::auditStyle
            duplication["Duplication Auditor"]:::auditStyle
            modularity["Modularity Auditor"]:::auditStyle
            utilities["Common Utilities"]:::utilityStyle
        end
        subgraph "Output and Reports"
            direction TB
            reportGen["Report Generator"]:::reportStyle
            sampleTests["Test & Sample Reports"]:::testStyle
        end
    end

    engine -->|"analyzes"| complexity
    engine -->|"analyzes"| duplication
    engine -->|"analyzes"| modularity

    complexity -->|"utilizes"| utilities
    duplication -->|"utilizes"| utilities
    modularity -->|"utilizes"| utilities

    complexity -->|"sendsResults"| reportGen
    duplication -->|"sendsResults"| reportGen
    modularity -->|"sendsResults"| reportGen

    reportGen -->|"outputs"| sampleTests

    click engine "https://github.com/helabenkhalfallah/code-health-meter/blob/main/src/index.js"
    click complexity "https://github.com/helabenkhalfallah/code-health-meter/tree/main/src/kernel/complexity"
    click duplication "https://github.com/helabenkhalfallah/code-health-meter/blob/main/src/kernel/duplication/CodeDuplicationAuditor.js"
    click modularity "https://github.com/helabenkhalfallah/code-health-meter/tree/main/src/kernel/modularity"
    click utilities "https://github.com/helabenkhalfallah/code-health-meter/tree/main/src/commons"
    click sampleTests "https://github.com/helabenkhalfallah/code-health-meter/tree/main/tests"

    classDef engineStyle fill:#F2A900,stroke:#333,stroke-width:2px;
    classDef auditStyle fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef utilityStyle fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef reportStyle fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef testStyle fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
