# tiwarishubham635/go-calculator architecture

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

## Overview

##### Main Components
- Basic Math Module (located in the "math" directory):
- Contains basic functions and related testing (e.g., output operations).
- Advanced Math Module (located in the "advanced_math" directory):
- Contains advanced functions including trigonometric operations and other extended functionalities.
- Module & Dependency Management:
- Use of go.mod and go.sum files to manage module dependencies.
- Testing Components:
- That each module (both “math” and “advanced_math”) has associated test files (files ending with _test.go).

##### Relationships and Interactions
- The core operation (i.e., the Go calculator functionality) interacts with both Basic and Advanced Math Modules.
- Think of the basic math functionality (from the "math" directory) as providing earlier versions (v0 or v1) of the calculator features.
- The advanced_math module further extends this functionality for v2 and beyond—indicating a form of versioned evolution where the system delegates requests to appropriate function sets.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project logically divides its functionality into two main packages – basic and advanced mathematical computations.
- Layered Architecture: Even though it is a library, think of the system as having layers, where one layer (basic math) covers elementary operations and the other (advanced math) deals with extended functionalities.

##### Relevant Technologies, Frameworks, or Libraries
- The project is written in Go, so standard Go conventions for package structuring and testing are followed.
- There’s no external framework or service integration, but the build and dependency management are handled through Go Modules (via go.mod/go.sum).

##### Detailed Elements
- “Basic Math Module” for the math directory content.
- “Advanced Math Module” for the advanced_math directory content.
- “Testing” segments for the _test.go files.
- “Dependency Management” for go.mod and go.sum.
- Changes in function behavior across versions by differentiating the modules; for instance, add annotations such as “v0/v1: Basic operations” and “v2: Advanced operations with breaking changes.”

## Diagram (Mermaid)

```mermaid
graph TD
    A("Client/Caller"):::client

    subgraph "Basic Math Module"
        B("Basic Functions"):::basic
        C("Basic Tests"):::testing
    end

    subgraph "Advanced Math Module"
        D("Advanced Functions"):::advanced
        E("Advanced Functions Test"):::testing
        F("Advanced Trigonometry"):::advanced
        G("Advanced Trigonometry Test"):::testing
    end

    H("Module & Dependency Management"):::module

    A -->|"calls"| B
    A -->|"calls"| D
    A -->|"calls"| F
    B -->|"tested-by"| C
    D -->|"tested-by"| E
    F -->|"tested-by"| G
    B -.->|"uses"| H
    D -.->|"uses"| H
    F -.->|"uses"| H

    click B "https://github.com/tiwarishubham635/go-calculator/blob/main/math/output.go"
    click C "https://github.com/tiwarishubham635/go-calculator/blob/main/math/output_test.go"
    click D "https://github.com/tiwarishubham635/go-calculator/blob/main/advanced_math/functions.go"
    click E "https://github.com/tiwarishubham635/go-calculator/blob/main/advanced_math/functions_test.go"
    click F "https://github.com/tiwarishubham635/go-calculator/blob/main/advanced_math/trigonometry.go"
    click G "https://github.com/tiwarishubham635/go-calculator/blob/main/advanced_math/trigonometry_test.go"
    click H "https://github.com/tiwarishubham635/go-calculator/blob/main/go.mod"
    click H "https://github.com/tiwarishubham635/go-calculator/blob/main/go.sum"

    classDef client fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef basic fill:#aed581,stroke:#7cb342,stroke-width:2px;
    classDef advanced fill:#81d4fa,stroke:#039be5,stroke-width:2px;
    classDef module fill:#ffe082,stroke:#ffab00,stroke-width:2px;
    classDef testing fill:#ce93d8,stroke:#ab47bc,stroke-width:2px;
```
