# minhnvm2307/kepler-equation architecture

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

- Interactive diagram: https://gitdiagram.com/minhnvm2307/kepler-equation
- Repository: https://github.com/minhnvm2307/kepler-equation

## Overview

The Kepler Equation Solver project is a compact Python-based tool whose primary purpose is to compute the eccentric anomaly (E) of a planet in an elliptical orbit, given the mean anomaly (M) and eccentricity (e). It implements three well-known numerical methods (Newton-Raphson, Secant, and Binary Search) and visualizes the orbit through plotting, making it a computational and visualization tool rather than a full-stack or multi-tier web application.

##### Main Components
- Entry Point (main.py): Represents the starting point of the application. This module is responsible for reading inputs (such as e and M), orchestrating the computation by calling the appropriate numerical method, and triggering plotting.
- Numerical Methods (methods.py): Contains the implementations of the three algorithms:
- Newton-Raphson
- Secant
- Binary (Bisection) Method
This component encapsulates the core computational logic.
- Utility Functions (utils.py): Likely provides shared routines such as preprocessing input values, error checking, or additional helper methods for plotting or formatting output.
- Plotting/Visualization: Although not a separate file, the code integrates with external libraries (matplotlib and numpy) to produce orbit graphs which are stored or referenced in the img directory.

##### Relationships and Interactions
- The main.py module acts as the central coordinator. It gathers user parameters, then:
- Calls numerical methods from methods.py to solve the Kepler Equation.
- Uses functions from utils.py for any supplementary tasks (for example, data parsing, formatting, or interfacing with matplotlib).
- The numerical methods in methods.py perform iterative calculations and provide computed results.
- After computation, control is passed back to main.py to handle visualization; here, matplotlib and numpy are used to render plots and save or display orbit images (as seen in the img folder).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The program cleanly separates its core functionalities—input handling (main.py), computation (methods.py), and auxiliary functions (utils.py). This modular design ensures ease of maintenance and straightforward testing.
- Procedural Structure: Given the relatively small codebase, the design focuses on procedural decomposition, with each script handling a specific set of tasks.
- Extensibility: Clear division allows for future expansion (for instance, adding more solution methods or enhancing the visualization module).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core Modules"
        A["Entry Point (main.py)"]:::core
        B["Computational Module (methods.py)\n(Newton-Raphson, Secant, Binary Search)"]:::core
        C["Utility Functions (utils.py)"]:::core
    end

    subgraph "External Dependencies"
        D["NumPy"]:::external
        E["Matplotlib"]:::external
    end

    F["Plot Output (img directory)"]:::resource

    A -->|"CallNumericalMethods"| B
    A -->|"UseHelperFunctions"| C
    A -->|"ConductComputation"| D
    A -->|"PlotResults"| E
    E -->|"SavePlots"| F

    style A fill:#ADD8E6,stroke:#000,stroke-width:2px
    style B fill:#ADD8E6,stroke:#000,stroke-width:2px
    style C fill:#ADD8E6,stroke:#000,stroke-width:2px
    style D fill:#90EE90,stroke:#000,stroke-width:2px
    style E fill:#90EE90,stroke:#000,stroke-width:2px
    style F fill:#FFFFE0,stroke:#000,stroke-width:2px

    click A "https://github.com/minhnvm2307/kepler-equation/blob/main/main.py"
    click B "https://github.com/minhnvm2307/kepler-equation/blob/main/methods.py"
    click C "https://github.com/minhnvm2307/kepler-equation/blob/main/utils.py"
    click F "https://github.com/minhnvm2307/kepler-equation/tree/main/img"
```
