# laumiulun/exafs-neo-public architecture

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

- Interactive diagram: https://gitdiagram.com/laumiulun/exafs-neo-public
- Repository: https://github.com/laumiulun/exafs-neo-public

## Overview

##### Project Overview and Key Purpose
- EXAFS Neo is an open-source Python tool designed to analyze Extended X-ray Absorption Fine Structure (EXAFS) data.
- It utilizes a genetic algorithm to perform curve fitting, integrates with the Larch library to process the x-ray spectrum, and optionally provides a GUI for interactive analysis.
- The project supports both command-line usage (via the “exafs” package and “setup.py” entry points) and a visual interface (from the “gui” directory).

##### Main Components
a. Core Library (exafs package):
- Modules such as exafs.py, individual.py, parser.py, ini_parser.py, helper.py, and pathObj/pathrange related files.
- Represents the computational engine where genetic algorithms are implemented, data is parsed, and model fitting is executed.
b. Graphical User Interface (GUI):
- Located in the “gui” directory with scripts like XAFS_GUI.py, Analysis_plot.py, and others.
- Acts as a front-end tool to display data, plots, and provide additional user interactions.
c. External Dependencies:
- Larch: Used for x-ray spectrum processing.
- Other Python libraries: numpy, scipy, matplotlib, scikit-learn, pandas, etc.
d. Self-Adsorption Correction Module:
- In “contrib/sabcor”: A submodule (compiled via make) for performing self-adsorption corrections as described in the README.
e. Data Sources and Test Inputs:
- “path_files” directories with sample data (for various elements like Cu, Tc, U).
- “tests” and “test_inputs” directories provide test cases and sample configuration files (INI files) to validate functionality.
f. Continuous Integration & Build Scripts:
- GitHub Actions workflows in “.github/workflows” for CI testing on Ubuntu and Windows, representing automated test and build procedures.
g. Output and Result Handling:
- “result” directory that stores output CSV files from analysis runs.

##### Relationships and Data Flow
- Data Input: Users supply EXAFS data (e.g., via test INI files and raw data from “path_files”). The command-line interface or GUI picks up the input.
- Parsing and Preprocessing: The exafs modules (e.g., ini_parser.py, parser.py, input_arg.py) interpret the supplied data files and parameters.
- Computational Engine: The core engine uses genetic algorithms (and likely other numerical routines) to fit the EXAFS data. It interacts with external libraries like Larch and Numpy/Scipy.
- Post-Processing: The system produces output files (CSV data in “result”) and visual plots through Matplotlib. For GUIs, additional plotting modules (in “gui”) present analysis results.
- Auxiliary Functions: The self-adsorption correction from the “contrib/sabcor” submodule is integrated when needed.
- Testing and CI: Automated workflows ensure that changes tested across different operating systems.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project distinctly separates the data processing core (“exafs” package), GUI components, and configuration/testing/data input handling.
- Modular design: Each functional area (input parsing, algorithm implementation, plotting, and corrections) is organized into its own module.
- Extensibility: The structure supports enhancement, as new parsers or analysis routines could be added with minimal changes to other parts of the system.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Data Inputs"
        A["User/External Data (path_files)"]:::input
        B["Test & Validation (test_inputs, tests)"]:::input
    end

    subgraph "Interfaces"
        C["CLI Interface (setup.py entry)"]:::core
        D["GUI Interface"]:::gui
    end

    E["Input Parsing Modules (exafs: ini_parser, parser, input_arg)"]:::core
    G["Core Fitting & Genetic Algorithm Engine (exafs)"]:::core
    H["Self-Adsorption Correction Module (contrib/sabcor)"]:::core
    I["External Dependencies (Larch, numpy, scipy, etc.)"]:::external
    J["Result Files (CSV) (result)"]:::core
    K["Plotting & Analysis (GUI: XAFS_GUI, Analysis_plot)"]:::gui
    L["Continuous Integration & Build (CI Workflows)"]:::ci

    A -->|"InputData"| E
    B -->|"TestConfigs"| E
    C -->|"CLI_Call"| E
    D -->|"GUI_Call"| E
    E -->|"ParsedParams"| G
    G -->|"Optional:SelfAdsCorr"| H
    G -->|"ComputeWith"| I
    G -->|"FittingResults"| J
    G -->|"PlotData"| K
    L -->|"AutomatedTests"| B
    L -->|"BuildDeploy"| G

    %% Click Events
    click E "https://github.com/laumiulun/exafs-neo-public/tree/master/exafs/"
    click G "https://github.com/laumiulun/exafs-neo-public/tree/master/exafs/"
    click D "https://github.com/laumiulun/exafs-neo-public/tree/master/gui/"
    click H "https://github.com/laumiulun/exafs-neo-public/tree/master/contrib/sabcor/"
    click A "https://github.com/laumiulun/exafs-neo-public/tree/master/path_files/"
    click B "https://github.com/laumiulun/exafs-neo-public/tree/master/tests/"
    click L "https://github.com/laumiulun/exafs-neo-public/tree/master/.github/workflows/"
    click J "https://github.com/laumiulun/exafs-neo-public/tree/master/result/"

    %% Styles
    classDef input fill:#C1FFC1,stroke:#333,stroke-width:2px;
    classDef core fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef gui fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef ci fill:#D5DBDB,stroke:#333,stroke-width:2px;
```
