# koushikraghav/geometric_calculator architecture

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

- Interactive diagram: https://gitdiagram.com/koushikraghav/geometric_calculator
- Repository: https://github.com/koushikraghav/geometric_calculator

## Overview

##### Main Components
- ROS Core / Master: Since the application runs on ROS (ROS1 Noetic), include an element representing the ROS Master (roscore) that manages the ROS communication.
- User Terminal/CLI: Represent the terminal from which the user inputs commands (e.g., “create point”, “area”, “exit”). This is the entry point for user interactions.
- Geometric Calculator ROS Node: This is the central component (implemented in geometric_calculator.cpp) that serves as the ROS node. It listens for CLI inputs, processes commands, and orchestrates the calculation workflow.
- Error Handling Module: Highlight that input validation and error management is crucial per the README guidelines. Error handling can be considered part of the processing logic in the node or as a separate module.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system design should clearly separate CLI input processing (in geometric_calculator.cpp) from the computation logic (in calculator_utils.cpp).
- Modular Design: Although the project is relatively small, depicting modules such as “Input Processing”, “Geometry Computation”, and “Error Handling” helps illustrate maintainability and extensibility.
- ROS Integration: Emphasize the integration with ROS—the use of a package (denoted by package.xml) and the ROS runtime environment, which is linked to the external “roscore” service.
- Command Routing: Capture that the CLI commands are parsed and routed to appropriate functions, a principle that might be diagrammed under a “Command Interpreter” section.

##### Final Touches
- A note regarding the build and project configuration since the CMakeLists.txt and package.xml are essential for building and deploying the ROS node.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CLI["User Terminal (CLI)"]:::cli
    ROSMaster["ROS Master (roscore)"]:::ros
    ROSConf["ROS Integration & Build Configuration"]:::config

    subgraph "Backend Processing"
        GC["Geometric Calculator ROS Node"]:::node
        CU["Calculation Utilities"]:::util
        SR(("Shape Repository/Manager")):::repo
        EH["Error Handling"]:::error
    end

    CLI -->|"sendsCommand"| GC
    GC -->|"delegatesCompute"| CU
    GC -->|"accessesRepository"| SR
    GC -->|"triggersError"| EH
    EH -->|"errorFeedback"| CLI
    GC -->|"communicatesWith"| ROSMaster
    GC -->|"buildConfig"| ROSConf

    %% Click Events
    click GC "https://github.com/koushikraghav/geometric_calculator/blob/main/geometric_calculator/src/geometric_calculator.cpp"
    click CU "https://github.com/koushikraghav/geometric_calculator/blob/main/geometric_calculator/src/calculator_utils.cpp"
    click SR "https://github.com/koushikraghav/geometric_calculator/blob/main/geometric_calculator/include/geometric_calculator/geometric_calculator.h"
    click ROSConf "https://github.com/koushikraghav/geometric_calculator/blob/main/geometric_calculator/package.xml"
    click ROSConf "https://github.com/koushikraghav/geometric_calculator/blob/main/geometric_calculator/CMakeLists.txt"

    %% Classes/Styles
    classDef cli fill:#AED581,stroke:#33691E,stroke-width:2px;
    classDef ros fill:#FFF59D,stroke:#F9A825,stroke-width:2px;
    classDef node fill:#81D4FA,stroke:#01579B,stroke-width:2px;
    classDef util fill:#64B5F6,stroke:#0D47A1,stroke-width:2px;
    classDef repo fill:#A5D6A7,stroke:#1B5E20,stroke-width:2px;
    classDef error fill:#EF9A9A,stroke:#B71C1C,stroke-width:2px;
    classDef config fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
