# aliymn/conventional-commits-check architecture

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

- Interactive diagram: https://gitdiagram.com/aliymn/conventional-commits-check
- Repository: https://github.com/aliymn/conventional-commits-check

## Overview

##### Project Overview and Purpose
- The project, “conventional-commits-check”, is a Python package designed to be used as a pre-commit hook. It enforces Conventional Commits rules on commit messages and can optionally prepend emojis based on the commit types.
- The README makes it clear that the core goal is to ensure that commit messages follow a standardized format, enhancing versioning and collaboration.

##### File Structure
- Key directories and files:
- conventional_commits_check/ – Contains the core logic via main.py and commit_types.py. This directory houses the application’s primary modules.
- test/ – Contains unit tests (e.g., test_main.py) to verify functionality.
- commits_check_config.yaml – External configuration file for customization of commit types and emojis.
- setup.py and requirements.txt – Standard Python packaging files.
- .pre-commit-config.yaml and other pre-commit hooks files – Integration points ensuring that the tool is used as part of a Git commit workflow.
- CI/CD configuration files in .github/workflows/ – Automatically build, test, and deploy package updates.
- The structure signals a standard Python library with testing, configuration, and continuous integration support.

##### Key Architectural Components
- Pre-commit Integration:
- This component is represented by configuration files (like .pre-commit-config.yaml) that tie Git’s commit-msg hook to invoke the tool.
- The flow starts when a developer attempts to make a commit; the Git hook triggers the “conventional-commits-check” script.
- Core Commit Validator:
- Located inside the conventional_commits_check package (main.py), this module contains the logic to validate commit messages.
- It leverages commit type definitions from commit_types.py to check if a commit message adheres to the Conventional Commits specification.
- Customization Module:
- The commits_check_config.yaml allows end users to define additional commit types and emojis.
- Developers can customize behavior by modifying commit_types.py or the YAML file.
- Testing & CI/CD:
- The test folder is dedicated to unit tests ensuring functionality and robustness.
- Github workflows (in .github/workflows) automatically run tests, enforce code style, and publish the package on PyPI.

##### Relationships and Data Flow
- A Git commit triggers the pre-commit hook (configured in .pre-commit-config.yaml).
- The hook calls the main logic in conventional_commits_check/main.py.
- main.py uses commit_types.py and the configuration file commits_check_config.yaml to determine what constitutes a valid commit message.
- Depending on settings, the script may transform auto-merge commit messages or prepend emojis.
- Results are either a successful commit (when compliant) or a block with an error message.

##### Important Architectural Patterns and Technologies
- Modular design: Separation into core validation logic, configurable types, and tests.
- Pre-commit hook integration to enhance Git workflows.
- Standard Python packaging and CI/CD pipelines ensure maintainability and smooth deployments.
- Emphasis on configuration-driven behavior (YAML file for custom commit types/emojis).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Local Environment
    subgraph "Local Environment"
        A("Git Client"):::git
        B("Pre-commit Hook"):::hook
    end

    %% Application Logic
    subgraph "Application Logic"
        C("Core Commit Validator"):::validator
        subgraph "Commit Types Module"
            D1("Commit Types: commit_types.py"):::config
            D2("Commit Config: commits_check_config.yaml"):::config
        end
    end

    %% Quality Assurance
    subgraph "Quality Assurance"
        E("Testing Suite"):::test
        F("CI/CD Pipeline"):::cicd
    end

    %% Connections
    A -->|"triggers"| B
    B -->|"invokes"| C
    C -->|"uses"| D1
    C -->|"uses"| D2
    C -->|"returns"| A
    A -->|"push triggers"| F
    F -->|"runs tests"| E

    %% Click Events
    click B "https://github.com/aliymn/conventional-commits-check/blob/master/.pre-commit-config.yaml"
    click C "https://github.com/aliymn/conventional-commits-check/blob/master/conventional_commits_check/main.py"
    click D1 "https://github.com/aliymn/conventional-commits-check/blob/master/conventional_commits_check/commit_types.py"
    click D2 "https://github.com/aliymn/conventional-commits-check/blob/master/commits_check_config.yaml"
    click E "https://github.com/aliymn/conventional-commits-check/tree/master/test/"
    click F "https://github.com/aliymn/conventional-commits-check/tree/master/.github/workflows/"

    %% Styles
    classDef git fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef hook fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef validator fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef config fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef test fill:#D2B4DE,stroke:#5B2C6F,stroke-width:2px;
    classDef cicd fill:#F5CBA7,stroke:#7E5109,stroke-width:2px;
```
