# hesselberth/cnav architecture

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

- Interactive diagram: https://gitdiagram.com/hesselberth/cnav
- Repository: https://github.com/hesselberth/cnav

## Overview

##### Main Components and Their Roles
- Core Library (Cnav Package):
- The heart of the project is the “cnav” directory which contains Python modules providing core functionality.
- Calculation & Utilities Modules:
- calendar.py, dt.py, dt2.py: Manage calendar computations and date/time arithmetic.
- constants.py: A central repository for astronomical or navigational constants.
- iersch5.py: Likely interacts with IERS data for Earth rotation or similar measurements.
- rot3d.py: Handles three-dimensional rotations – essential for transforming coordinate systems.
- xys.py: Appears to be concerned with coordinate conversions and/or computations.
- Performance Optimization Module:
- cnumba.py: Contains routines that are possibly optimized using numba to speed up calculations.
- External Data Integration:
- webdata.py (with accompanying webdata.ini): Manages configuration and retrieval of external or web-based data that might supplement celestial navigation calculations.
- Testing:
- The “tests” directory holds modules that ensure each chunk of functionality works as expected (e.g., test_calendar.py, test_cip.py).
- CI/CD and Packaging:
- The .github/workflows folder and pyproject.toml denote automated testing/deployment and packaging settings.

##### Relationships and Data Flow
- “Date & Time Utilities” could aggregate calendar.py, dt.py, dt2.py.
- “Mathematical & Coordinate Calculations” might include iersch5.py, rot3d.py, xys.py.
- “Constants & Optimizations” should highlight constants.py and cnumba.py.
- “External Data Module” should showcase webdata.py (supported by the webdata.ini configuration file).
- Dependency on optimization by showing that parts of the calculations initially done in pure Python are enhanced by cnumba.py.

##### Architectural Patterns and Design Principles
- Modularity: Each module (or group of modules) encapsulates a specific functional area.
- Separation of Concerns: Configuration (webdata.ini) is separated from core computational logic (modules under cnav), and testing is separated into the “tests” folder.
- Designated external integration via CI/CD with GitHub Actions (.github/workflows).

##### Additional Detail

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    coreLibrary["Cnav Celestial Navigation Library"]:::module

    subgraph "Date & Time Utilities"
        dt1["calendar.py"]:::module
        dt2["dt.py"]:::module
        dt3["dt2.py"]:::module
    end

    subgraph "Mathematical & Coordinate Calculations"
        mc1["iersch5.py"]:::module
        mc2["rot3d.py"]:::module
        mc3["xys.py"]:::module
        mc4["cip.py"]:::module
    end

    subgraph "Constants & Core Values"
        const["constants.py"]:::module
    end

    subgraph "Performance Optimization Module"
        opt["cnumba.py"]:::module
    end

    subgraph "External Data Integration"
        ext1["webdata.py"]:::module
        ext2["webdata.ini"]:::module
    end

    extSuite["Testing Suite"]:::external

    subgraph "CI/CD and Packaging"
        cicd1["GitHub Workflows"]:::ci
        cicd2["Packaging (pyproject.toml)"]:::ci
    end

    %% Core Library contains modules
    coreLibrary -->|"contains"| dt1
    coreLibrary -->|"contains"| mc1
    coreLibrary -->|"contains"| const
    coreLibrary -->|"contains"| opt
    coreLibrary -->|"contains"| ext1
    coreLibrary -->|"tested_by"| extSuite
    coreLibrary -->|"automates"| cicd1

    %% Inter-module relationships
    dt3 -->|"feeds"| mc3
    ext1 -->|"provides"| mc2
    const -->|"supplies"| mc4
    opt -->|"optimizes"| mc1

    %% CI/CD triggers testing
    cicd1 -->|"triggers"| extSuite

    click coreLibrary "https://github.com/hesselberth/cnav/tree/main/cnav"
    click dt1 "https://github.com/hesselberth/cnav/blob/main/cnav/calendar.py"
    click dt2 "https://github.com/hesselberth/cnav/blob/main/cnav/dt.py"
    click dt3 "https://github.com/hesselberth/cnav/blob/main/cnav/dt2.py"
    click mc1 "https://github.com/hesselberth/cnav/blob/main/cnav/iersch5.py"
    click mc2 "https://github.com/hesselberth/cnav/blob/main/cnav/rot3d.py"
    click mc3 "https://github.com/hesselberth/cnav/blob/main/cnav/xys.py"
    click mc4 "https://github.com/hesselberth/cnav/blob/main/cnav/cip.py"
    click const "https://github.com/hesselberth/cnav/blob/main/cnav/constants.py"
    click opt "https://github.com/hesselberth/cnav/blob/main/cnav/cnumba.py"
    click ext1 "https://github.com/hesselberth/cnav/blob/main/cnav/webdata.py"
    click ext2 "https://github.com/hesselberth/cnav/blob/main/cnav/webdata.ini"
    click extSuite "https://github.com/hesselberth/cnav/tree/main/tests"
    click cicd1 "https://github.com/hesselberth/cnav/tree/main/.github/workflows"
    click cicd2 "https://github.com/hesselberth/cnav/blob/main/pyproject.toml"

    classDef module fill:#AED6F1,stroke:#1F618D,stroke-width:2px,color:#1F618D;
    classDef external fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px,color:#B9770E;
    classDef ci fill:#A9DFBF,stroke:#27AE60,stroke-width:2px,color:#1E8449;
```
