# selcukemreozer/mocomtool architecture

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

- Interactive diagram: https://gitdiagram.com/selcukemreozer/mocomtool
- Repository: https://github.com/selcukemreozer/mocomtool

## Overview

##### Project Type and Purpose
- MocomTool is a command-line interface (CLI) application designed to help developers compare responses from multiple Large Language Models (LLMs) concurrently.
- The README clearly details that the tool is experimental, supports various LLMs (e.g., GPT, Gemini, Claude, Ollama, Groq), and works by reading prompts (either directly or via JSON files) and returning model responses for comparison.
- The primary goal is not to serve as a production service but rather as a developer’s helper tool, which suggests a relatively lightweight, modular design rather than a full-stack web architecture.

##### Analyzing the File Structure
- Top-level Files and Directories:
- mocom.py: Likely the main entry point. It interprets CLI arguments (e.g., commands like "introduce" and "compare") and dispatches the operations.
- fileprocess.py and terminal.py: Provide supporting functions for processing files and handling terminal input/output.
- introduce.py: Handles the introduction/help functionality for users.
- modelsConfig/ directory: Contains the configuration logic and helper modules for different models (e.g., callClaude.py, callGPT.py, callGemini.py, callOther.py) plus a models.py file where model names and the CALL_ALL_MODELS dictionary are defined.
- templates/ directory: Contains sample environment and JSON prompt templates.
- This organization indicates the tool’s modular design where each aspect (command handling, model integration, file processing) is separated into different modules.

##### Reading the README for Insights
- The README explains the core functions:
- “introduce” to guide users.
- “compare” to compare model responses based on either a one-off prompt or multiple prompts using JSON input.
- It provides code examples and usage instructions, clearly indicating that interactions are initiated via CLI commands with flags for specifying which models to call.
- External dependencies (via requirements.txt) and the need for environment configurations (using .env templates) are detailed.

##### Main Components
a. CLI Interface Component:
- Represented by the main script (mocom.py) and supported by terminal.py.
- Handles argument parsing, dispatches command (e.g., “compare”, “introduce”) based on argument flags.
b. Command Handlers/Controllers:
- Introduce Module (introduce.py): Provides user guidance for available commands and usage.
- Comparison Controller: Manages the “compare” function; accepts prompts (direct or JSON), iterates over chosen LLM model functions, aggregates responses.
c. Model Integration Layer:
- Located within modelsConfig/: Modules such as callGPT.py, callGemini.py, callClaude.py, callOther.py serve as connectors to respective LLM APIs.
- A shared configuration (models.py) supplies model identifiers and selection flags.
d. File Processing/Template Component:
- fileprocess.py and the templates/ directory for handling external configuration (.env) and prompt input (JSON file templates).
e. External API Dependency:
- Although not shown explicitly as network modules, indicate that each callXXX module interacts with an external API (e.g., OpenAI, Google Gemini, etc.) using API keys provided in the .env file.
f. Response Aggregation and Scoring:
- The application collects model responses, times their execution, and may support manual scoring (as per the README examples).

##### Relationships and Interactions
- The CLI Interface component receives user commands and passes instructions to the command handlers.
- The Comparison Controller directs calls to each model’s integration module within modelsConfig/, using configuration data from models.py.
- After receiving responses from each external LLM service (triggered by the respective call modules), the controller aggregates the responses.
- The tool might format or store the output based on further processing defined in fileprocess.py or terminal.py.
- Data flow is unidirectional from the CLI entry to the controllers, through model integration calls, and finally back to the CLI for output.

##### Architectural Patterns and Design Principles
- Modular design: Separate concerns are clearly demarcated (CLI parsing, file processing, model integration).
- Dependency injection via configuration: The model names and selection flags are centralized in modelsConfig/models.py.
- A layered architecture pattern is evident – the presentation layer (CLI), business logic layer (command handling), and integration layer (calls to external APIs).
- Emphasis on extensibility: Adding support for additional LLMs or modifying existing model call behaviors can be performed in the modelsConfig/ submodules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        user["User CLI Command"]:::cli
        mocom["CLI Entry (mocom.py)"]:::cli
        term["Terminal Output (terminal.py)"]:::cli
        user --> mocom
    end

    %% Command Handlers/Controllers
    subgraph "Command Controllers"
        introduce["Introduce Module (introduce.py)"]:::controller
        compare["Comparison Controller"]:::controller
        mocom -->|"introduce"| introduce
        mocom -->|"compare"| compare
        introduce -->|"guides"| term
    end

    %% File Processing/Template Component
    subgraph "File & Template Processing"
        fileproc["File Processing (fileprocess.py)"]:::fileproc
        templates["Templates Folder"]:::fileproc
        compare -->|"prompt_input"| fileproc
        fileproc -->|"uses"| templates
    end

    %% Model Integration Layer
    subgraph "Model Integration Layer"
        callGPT["CallGPT Module"]:::model
        callGemini["CallGemini Module"]:::model
        callClaude["CallClaude Module"]:::model
        callOther["CallOther Module"]:::model
        models_config["Models Config (models.py)"]:::model
        compare -->|"invoke_models"| callGPT
        compare -->|"invoke_models"| callGemini
        compare -->|"invoke_models"| callClaude
        compare -->|"invoke_models"| callOther
        models_config --> callGPT
        models_config --> callGemini
        models_config --> callClaude
        models_config --> callOther
    end

    %% External API Integration
    subgraph "External Integration"
        external_api["External LLM APIs"]:::external
        callGPT -->|"call"| external_api
        callGemini -->|"call"| external_api
        callClaude -->|"call"| external_api
        callOther -->|"call"| external_api
    end

    %% Aggregation of responses back to CLI
    external_api -->|"responses"| compare
    compare -->|"output"| term

    %% Click Events
    click mocom "https://github.com/selcukemreozer/mocomtool/blob/main/mocom.py"
    click term "https://github.com/selcukemreozer/mocomtool/blob/main/terminal.py"
    click introduce "https://github.com/selcukemreozer/mocomtool/blob/main/introduce.py"
    click callGPT "https://github.com/selcukemreozer/mocomtool/blob/main/modelsConfig/callGPT.py"
    click callGemini "https://github.com/selcukemreozer/mocomtool/blob/main/modelsConfig/callGemini.py"
    click callClaude "https://github.com/selcukemreozer/mocomtool/blob/main/modelsConfig/callClaude.py"
    click callOther "https://github.com/selcukemreozer/mocomtool/blob/main/modelsConfig/callOther.py"
    click models_config "https://github.com/selcukemreozer/mocomtool/blob/main/modelsConfig/models.py"
    click fileproc "https://github.com/selcukemreozer/mocomtool/blob/main/fileprocess.py"
    click templates "https://github.com/selcukemreozer/mocomtool/tree/main/templates/"

    %% Style Definitions
    classDef cli fill:#ffdddd,stroke:#d62728,stroke-width:2px;
    classDef controller fill:#ddffdd,stroke:#2ca02c,stroke-width:2px;
    classDef model fill:#d1e5f0,stroke:#1f77b4,stroke-width:2px;
    classDef fileproc fill:#fff2cc,stroke:#ff7f0e,stroke-width:2px;
    classDef external fill:#fce5cd,stroke:#9467bd,stroke-width:2px;
```
