# tardis-sn/carsus architecture

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

- Interactive diagram: https://gitdiagram.com/tardis-sn/carsus
- Repository: https://github.com/tardis-sn/carsus

## Overview

##### Main Components

- Core Package (carsus):
– The heart of the library, where high-level operations and common routines are implemented (e.g., base.py, __init__.py, and conftest.py). This layer acts as the central hub that ties all components together.

- Data Layer:
– Represented by the ‘carsus/data’ directory. This area holds static or reference datasets (e.g., basic_atomic_data.csv, configuration files like cmfgen_config.yml). It’s important to show that this layer provides configuration and input data used by the system.

- Input/Output (I/O) Module:
– This module is extensive and split into multiple submodules based on source types:
- Chianti (folder: carsus/io/chianti_)
- CMFGEN (carsus/io/cmfgen)
- Kurucz (carsus/io/kurucz)
- LANL ADS (carsus/io/lanlads)
- Molecules (carsus/io/molecules)
- NIST (carsus/io/nist)
- NNDC (carsus/io/nndc)
- Nuclear (carsus/io/nuclear)
- VALD (carsus/io/vald)
- Zeta processing (carsus/io/zeta)
- Generic output functionalities (carsus/io/output)

- Utility Layer:
– Located in both carsus/util and other helper files, these utilities (e.g., colored_logger.py, hash.py, helpers.py, selected.py) offer common helper functions and logging capabilities that support processing across modules.

- Testing & Validation:

- Documentation & CI/CD:

##### Relationships and Interactions

- Data Flow:
– Once processed, the output module converts data into formats suitable for radiative transfer codes. Indicate this flow from raw input to processed output.

- Utility Support:
– Connect the core processing and I/O modules to the utility components (logging, helper functions, etc.) to show underlying support functionality.

- Testing & CI:

##### Architectural Patterns and Design Principles

- Modular and Extensible Design:
– The detailed splitting of the I/O module by data source indicates a plug-in architecture where each parser or converter is isolated. This allows for easier extension when adding support for future atomic data sources.

- Separation of Concerns:

- Adoption of Established Tools:
– Note that Carsus is built using an Astropy package template, meaning that many conventions from the Astropy community (like configuration, testing setups, and documentation) are likely in effect.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Carsus Core
    subgraph "Carsus Core"
        CC["Carsus Core"]:::core
    end

    %% Data Layer
    subgraph "Data Layer"
        DL["Data Module"]:::data
    end

    %% I/O Modules
    subgraph "I/O Modules"
        IOchi["carsus/io/chianti_"]:::io
        IOcmf["carsus/io/cmfgen"]:::io
        IOkur["carsus/io/kurucz"]:::io
        IOlan["carsus/io/lanlads"]:::io
        IOmol["carsus/io/molecules"]:::io
        IOnist["carsus/io/nist"]:::io
        IOnndc["carsus/io/nndc"]:::io
        IOnucl["carsus/io/nuclear"]:::io
        IOvald["carsus/io/vald"]:::io
        IOzeta["carsus/io/zeta"]:::io
        IOoutput["carsus/io/output"]:::io
    end

    %% Utility Layer
    subgraph "Utility Layer"
        UTIL["Utilities"]:::util
    end

    %% Quality Assurance
    subgraph "Quality Assurance"
        TEST["Testing & Validation"]:::qa
        CI["CI/CD & Documentation"]:::qa
    end

    %% Connections from Core to other layers
    CC -->|"orchestrates"| DL
    CC -->|"orchestrates"| UTIL

    %% Data ingestion from Data Layer to I/O Modules
    DL -->|"provides raw data"| IOchi
    DL -->|"provides raw data"| IOcmf
    DL -->|"provides raw data"| IOkur
    DL -->|"provides raw data"| IOlan
    DL -->|"provides raw data"| IOmol
    DL -->|"provides raw data"| IOnist
    DL -->|"provides raw data"| IOnndc
    DL -->|"provides raw data"| IOnucl
    DL -->|"provides raw data"| IOvald
    DL -->|"provides raw data"| IOzeta
    DL -->|"provides raw data"| IOoutput

    %% Each I/O module processes data and passes to output interface
    IOchi -->|"processes"| IOoutput
    IOcmf -->|"processes"| IOoutput
    IOkur -->|"processes"| IOoutput
    IOlan -->|"processes"| IOoutput
    IOmol -->|"processes"| IOoutput
    IOnist -->|"processes"| IOoutput
    IOnndc -->|"processes"| IOoutput
    IOnucl -->|"processes"| IOoutput
    IOvald -->|"processes"| IOoutput
    IOzeta -->|"processes"| IOoutput

    %% Quality Assurance connections
    TEST -->|"validates"| CC
    TEST -->|"validates"| UTIL
    CI  -->|"monitors"| CC

    %% Style Classes
    classDef core fill:#7094db,stroke:#333,stroke-width:1px,color:#fff;
    classDef data fill:#a3d39c,stroke:#333,stroke-width:1px,color:#000;
    classDef io fill:#f9d27d,stroke:#333,stroke-width:1px,color:#000;
    classDef util fill:#d1a3e7,stroke:#333,stroke-width:1px,color:#000;
    classDef qa fill:#d0d0d0,stroke:#333,stroke-width:1px,color:#000;

    %% Click Events
    click CC "https://github.com/tardis-sn/carsus/blob/master/carsus/__init__.py"
    click DL "https://github.com/tardis-sn/carsus/tree/master/carsus/data"
    click IOchi "https://github.com/tardis-sn/carsus/tree/master/carsus/io/chianti_"
    click IOcmf "https://github.com/tardis-sn/carsus/tree/master/carsus/io/cmfgen"
    click IOkur "https://github.com/tardis-sn/carsus/tree/master/carsus/io/kurucz"
    click IOlan "https://github.com/tardis-sn/carsus/tree/master/carsus/io/lanlads"
    click IOmol "https://github.com/tardis-sn/carsus/tree/master/carsus/io/molecules"
    click IOnist "https://github.com/tardis-sn/carsus/tree/master/carsus/io/nist"
    click IOnndc "https://github.com/tardis-sn/carsus/tree/master/carsus/io/nndc"
    click IOnucl "https://github.com/tardis-sn/carsus/tree/master/carsus/io/nuclear"
    click IOvald "https://github.com/tardis-sn/carsus/tree/master/carsus/io/vald"
    click IOzeta "https://github.com/tardis-sn/carsus/blob/master/carsus/io/zeta.py"
    click IOoutput "https://github.com/tardis-sn/carsus/tree/master/carsus/io/output"
    click UTIL "https://github.com/tardis-sn/carsus/tree/master/carsus/util"
    click TEST "https://github.com/tardis-sn/carsus/tree/master/carsus/tests"
    click CI "https://github.com/tardis-sn/carsus/tree/master/.github/workflows"
```
