# jorisroovers/gitlint architecture

> Architecture diagram of the GitHub repository jorisroovers/gitlint, 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/jorisroovers/gitlint
- Repository: https://github.com/jorisroovers/gitlint

## Overview

##### Main Components Identification
The system should be represented with these key components:

a) Core Engine Components:
- Linting Engine (gitlint-core/gitlint/lint.py)
- Rule System (gitlint-core/gitlint/rules.py)
- Configuration Manager (gitlint-core/gitlint/config.py)
- Git Interface (gitlint-core/gitlint/git.py)

b) Extension Points:
- Built-in Rules
- Contrib Rules
- User-Defined Rules

c) Interface Layer:
- CLI Interface (gitlint-core/gitlint/cli.py)
- Git Hooks Integration (gitlint-core/gitlint/hooks.py)

##### Component Relationships

**[Git Repository] → [Git Interface] → [Linting Engine] → [Rule System]**
- ↑                    ↑
- [Configuration Manager] → [Rules]
- /  |  \
- [Built-in] [Contrib] [User-defined]

##### Specific Design Elements

Use these visual elements:
- Hexagons for extension points (rules)
- Blue: Core components
- Green: Extension points
- Gray: External systems
- Orange: Interface components

##### Implementation Details

- Rule loading mechanism (rule_finder.py)
- Configuration hierarchy (CLI → Config file → Default settings)
- Git integration points (commit-msg hooks, direct git commands)
- Cache system for performance optimization (cache.py)

- Input Sources  | →   | Core Processing  | →   | Output/Display|
- Git Repo     |     | - Lint Engine    |     | - CLI Output  |
- Stdin        |     | - Rules          |     | - Error msgs  |
- Files        |     | - Configuration  |     | - Statistics  |

##### Technical Details to Emphasize

- Python-based implementation
- Support for multiple Python versions
- Integration with git hooks
- Extensible rule system
- Configuration flexibility

This architecture reflects gitlint's nature as a modular, extensible tool focused on git commit message validation, with clear separation between core functionality and extension points.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input ["Input Layer"]
        GR[Git Repository]:::external
        SI[Stdin]:::external
        Files[Files]:::external
    end

    subgraph Core ["Core Processing Layer"]
        direction TB
        GI["Git Interface"]:::core
        LE["Linting Engine"]:::core
        CM["Configuration Manager"]:::core
        RS["Rule System"]:::core
        RF["Rule Finder"]:::core
        CS["Cache System"]:::core
        OH["Options Handler"]:::core
    end

    subgraph Rules ["Rule Components"]
        direction TB
        BR["Built-in Rules"]:::rules
        CR["Contrib Rules"]:::rules
        UD["User-Defined Rules"]:::rules
    end

    subgraph Interface ["Interface Layer"]
        direction TB
        CLI["CLI Interface"]:::interface
        GH["Git Hooks"]:::interface
        SH["Shell Interface"]:::interface
        DS["Display System"]:::interface
    end

    %% Relationships
    GR --> GI
    SI --> LE
    Files --> LE
    
    GI --> LE
    LE --> RS
    CM --> LE
    CM --> RS
    RF --> RS
    CS --> LE
    OH --> CM

    RS --> BR
    RS --> CR
    RS --> UD

    LE --> CLI
    LE --> GH
    LE --> DS
    CLI --> SH
    GH --> SH

    %% Click Events
    click LE "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/lint.py"
    click RS "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/rules.py"
    click CM "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/config.py"
    click GI "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/git.py"
    click CLI "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/cli.py"
    click GH "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/hooks.py"
    click CR "https://github.com/jorisroovers/gitlint/tree/main/gitlint-core/gitlint/contrib/rules/"
    click UD "https://github.com/jorisroovers/gitlint/tree/main/examples/"
    click CS "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/cache.py"
    click RF "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/rule_finder.py"
    click DS "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/display.py"
    click BR "https://github.com/jorisroovers/gitlint/tree/main/gitlint-core/gitlint/tests/rules/"
    click SH "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/shell.py"
    click OH "https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/options.py"

    %% Styles
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef rules fill:#57a773,stroke:#000,stroke-width:2px,color:#fff
    classDef interface fill:#ff8c42,stroke:#000,stroke-width:2px,color:#fff
    classDef external fill:#939393,stroke:#000,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Rule Components]:::rules
        L3[Interface Components]:::interface
        L4[External Systems]:::external
    end
```
