# jemmy9211/ollamacommit architecture

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

- Interactive diagram: https://gitdiagram.com/jemmy9211/ollamacommit
- Repository: https://github.com/jemmy9211/ollamacommit

## Overview

##### Main Components
- CLI Interface: Represented by the executable script in the bin/ directory (i.e., “ollamacommit”), which is the entry point for users.
- Core Logic Module: Located in src/generate_message.py, this Python module is responsible for sending the Git diff to the locally running Ollama server and processing the response.
- Git Integration: The tool leverages Git commands (e.g., “git diff --cached” and “git commit”) to obtain changes and commit the generated message.
- External Service: The locally running Ollama server hosting the llama3.2 model, which the tool accesses via its REST API at “http://localhost:11434”.
- Installation & Uninstallation Scripts: “install.sh” and “uninstall.sh” handle the environment setup (virtual environment creation, dependency installation, model setup) and teardown respectively.

##### Out Relationships and Interactions
- The CLI (bin/ollamacommit) initiates the process by capturing the staged changes using Git.
- It then calls the Python module in src/ to send the diff data over an HTTP request to the locally running Ollama server.
- The Ollama server processes the input with the llama3.2 model and returns a generated commit message.
- The tool automatically creates a Git commit using the received message.
- The installation script sets up the environment, installs Python dependencies, and downloads the required model if not already present.
- The uninstallation script cleans up the environment (e.g., removes the virtual environment and optionally the model).

##### Architectural Patterns
- Lightweight CLI-based architecture that tightly integrates with Git.
- A modular design separating the command-line interface from the core logic (message generation).
- External dependency management by using a locally running LLM service (demonstrating client-server interaction over HTTP).
- Use of scripting (bash) for installation and cleanup procedures, maintaining portability for Linux users.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        user["User"]
    end

    %% CLI Layer
    subgraph "CLI Layer"
        cli["CLI (bin/ollamacommit)"]
    end

    %% Core Application Layer
    subgraph "Core Application Layer"
        generator["Commit Message Generator (src/generate_message.py)"]
    end

    %% External Service Layer
    subgraph "External Service"
        ollama["Ollama Server (llama3.2 Model)\n(http://localhost:11434)"]
    end

    %% Data Storage for Git Repository
    subgraph "Git Integration"
        repo["Git Repository"]
    end

    %% Auxiliary Scripts
    subgraph "Auxiliary Scripts"
        install["Installation Script (install.sh)"]
        uninstall["Uninstallation Script (uninstall.sh)"]
    end

    %% Connections
    user -->|"invokes"| cli
    cli -->|"extracts diff\n(git diff --cached)"| repo
    cli -->|"calls"| generator
    generator -->|"HTTP request"| ollama
    ollama -->|"HTTP response"| generator
    generator -->|"commits message\n(git commit)"| repo
    install -.->|"setup environment"| cli
    uninstall -.->|"cleanup environment"| cli

    %% Click Events
    click cli "https://github.com/jemmy9211/ollamacommit/tree/main/bin/ollamacommit"
    click generator "https://github.com/jemmy9211/ollamacommit/blob/main/src/generate_message.py"
    click install "https://github.com/jemmy9211/ollamacommit/blob/main/install.sh"
    click uninstall "https://github.com/jemmy9211/ollamacommit/blob/main/uninstall.sh"

    %% Styles
    classDef cli fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef script fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#e2e3e5,stroke:#6c757d,stroke-width:2px,stroke-dasharray: 5 5;

    class cli cli;
    class generator core;
    class ollama external;
    class install,uninstall script;
    class repo database;
```
