# santiagoruiz1314/calculus-llm-deepseek architecture

> Architecture diagram of the GitHub repository santiagoruiz1314/calculus-llm-deepseek, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santiagoruiz1314/calculus-llm-deepseek
- Repository: https://github.com/santiagoruiz1314/calculus-llm-deepseek

## Overview

##### Project Type and Purpose
- This project is a command-line tool focused on solving university-level calculus problems using a language model deployed locally via Ollama.
- The main purpose is to take user input for calculus problems (derivatives, integrals, limits, etc.), forward it to the underlying LLM (e.g., DeepSeek-R1), and then return step-by-step solutions and explanations.

##### Analyzing the File Structure
- The project is minimal with only a couple of files at the root—.gitignore, README.MD, and calculus_solver.py.
- The absence of a directory structure (like separate folders for CLI handling, business logic, or integrations) indicates that the entire functionality is most likely implemented in a single Python script.
- Despite its simplicity, the script encapsulates critical roles: command-line argument processing, LLM query generation, external service (Ollama) communication, and result output.

##### Main Components
a. User Interface / Command-line Interaction:
- Represented by the command-line interface that triggers the program and passes in the problem text.

b. Main Controller / Business Logic (calculus_solver.py):
- The central “Controller” that processes input arguments (like “solve”, “test” or “models”), prepares the request.
- Contains parsing logic for distinguishing between different commands (solving a calculus problem vs. testing or listing models).

c. External Service Integration:
- The component representing the connection to the Ollama service. Illustrate that the script makes HTTP (or similar) API calls to the locally hosted Ollama server (likely on http://localhost:11434).
- Dependency on the DeepSeek-R1 model (or possibly other compatible models) that processes the calculus problem.

d. Output / Result Processor:
- Once the response is received from Ollama, the tool formats and prints the detailed, step-by-step solution to the user.

##### Highlighting Architectural Patterns and Design Principals
- Even though this is a small, monolithic script, it still follows a clear separation of concerns:
- Input processing (command-line arguments)
- Business logic (translating user commands into service requests)
- Integration (communicating with an external LLM service)
- Output rendering (displaying results)

- Clear labels for every component (e.g., CLI/Input, Controller/Business Logic, API Integration, Ollama Service, Output Renderer).
- User input → CLI Handler
- CLI Handler → Business Logic Component
- Business Logic Component → Ollama API Client (External Service)
- Ollama API Response → Business Logic Component
- Business Logic Component → Console Output

1. The user types a command at the terminal.
2. The “calculus_solver.py” reads the command, processes it, and prepares the data.
3. A request is made to the local Ollama service hosting the DeepSeek-R1 model.
4. The LLM processes the calculus problem and returns a detailed, step-by-step solution.
5. The system outputs the solution back to the user on the terminal.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraphs
    subgraph "User Interaction"
        A["User (CLI Command)"]:::user
    end

    subgraph "Application (calculus_solver.py)"
        B["CLI Handler & Controller"]:::internal
        C["API Client"]:::internal
        D["Output Renderer"]:::internal
    end

    subgraph "External Services"
        E(("Ollama Service (DeepSeek-R1)")):::external
    end

    subgraph "Output"
        F["Console Output"]:::output
    end

    %% Connections
    A -->|"input"| B
    B -->|"process_command"| C
    C -->|"send_request"| E
    E -->|"return_response"| C
    C -->|"format_output"| D
    D -->|"display"| F

    %% Click Events
    click A "https://github.com/santiagoruiz1314/calculus-llm-deepseek/blob/main/calculus_solver.py"
    click B "https://github.com/santiagoruiz1314/calculus-llm-deepseek/blob/main/calculus_solver.py"
    click C "https://github.com/santiagoruiz1314/calculus-llm-deepseek/blob/main/calculus_solver.py"
    click D "https://github.com/santiagoruiz1314/calculus-llm-deepseek/blob/main/calculus_solver.py"

    %% Styles
    classDef user fill:#B3E5FC,stroke:#039BE5,stroke-width:2px;
    classDef internal fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef output fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
```
