# huangli712/acflow architecture

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

- Interactive diagram: https://gitdiagram.com/huangli712/acflow
- Repository: https://github.com/huangli712/acflow

## Overview

##### Project Type and Purpose
- ACFlow is a specialized scientific toolkit for analytic continuation that provides multiple state-of-the-art methods (e.g., maximum entropy, stochastic methods, Nevanlinna, barycentric rational approximations). It is designed for converting quantum many-body simulation correlation functions from the imaginary axis to the real axis.
- The focus is on numerical methods and simulation data processing for physics applications, so the design needs to highlight modular algorithm implementations specific to analytic continuation.

##### File Structure
- Top-Level Components:
- The “src” directory contains the core code modules (e.g., ACFlow.jl, base.jl, config.jl, grid.jl, and other modules corresponding to different aspects like math, kernel, inout, and various methods such as maxent, nac, rfa, sac, etc.). This represents the heart of the toolkit where each method is encapsulated in its own module.
- The “docs” directory holds the documentation including user guides, theoretical backgrounds, and example files (drawn from subdirectories like “intro”, “library”, “theory”, and “man”). This indicates that the project is well-documented and that the documentation can be seen as a separate “component” interfacing with the code.
- The “test” directory shows comprehensive testing examples, categorized by subdomains (basic tests, lqcd, nac, pole, rfa, etc.). This emphasizes that test cases are organized to validate various analytic continuation approaches.
- The “tutor” directory appears to provide tutorial examples to help users run the toolkit.
- Additional utilities in the “util” folder help with script-based operations or pre-/post-processing.
- There are also standard project files (e.g., Project.toml, LICENSE, README.md) which frame project configuration and legal/licensing information.

##### Core Components
a. Core Library / Modules:
- “src” directory as the central computing engine.
- Inside “src”, create separate nodes for modules such as:
- ACFlow (main entry point)
- Base, Config, Global, Grid, InOut (for configuration/input-output handling)
- Modules implementing specific analytic continuation methods (maxent, nac, rfa, sac, san, som, spx, etc.)
- Utility modules (math, mesh, types, util) that support the computation.
b. Documentation Component:
- A component node for “Documentation” that references the “docs” directory. This node can connect to both the user and developer layers, showing how detailed guidance and theoretical background are made available.
c. Testing and Validation:
- The “test” suite should be shown as a separate module. Use clusters to organize tests in areas such as “basic”, “lqcd”, “nac”, “pole”, “rfa”, etc.
- This indicates robust validation of various algorithm implementations.
d. Tutorial / Example Component:
- A separate node for “Tutor” or “Tutorial Examples” representing usage examples provided for new users.
e. Utility and Auxiliary Scripts:
- Nodes for “Utilities” (from “util”), which support execution or possibly preprocessing (e.g., acprun.jl, gmesh.jl, ppole.jl).

##### Relationships and Interactions
- The “ACFlow.jl” (main engine) interacts with various modules (like math, grid, inout, and each analytic continuation method module).
- That configuration (via “config.jl”) and global settings (global.jl) underlie these interactions.

##### Architectural Patterns and Technologies
- The project appears modular with a clear separation of concerns: core computational logic (src), testing (test), documentation (docs), and tutorials (tutor).
- The separation of individual analytic continuation methods into separate modules illustrates the plug-and-play style, which is critical for a toolkit aimed at multiple methods.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Engine Subgraph
    subgraph "Core Engine (src modules)"
        ACFlow["ACFlow (Main Entry Point)"]:::core
        Base["Base Module"]:::core
        Config["Configuration Module"]:::core
        Global["Global Settings Module"]:::core
        Grid["Grid Module"]:::core
        InOut["Input/Output Handling"]:::core
        Kernel["Kernel Module"]:::core
        Math["Math Utilities"]:::core
        Mesh["Mesh Module"]:::core
        Model["Model Module"]:::core
        subgraph "Analytic Methods"
            MaxEnt["Maximum Entropy Method Module"]:::core
            NAC["NAC (Nevenlinna/Stochastic) Module"]:::core
            RFA["Rational Function Approximation Module"]:::core
            SAC["SAC Module"]:::core
            SAN["SAN Module"]:::core
            SOM["SOM Module"]:::core
            SPX["SPX Module"]:::core
        end
        Types["Type Definitions Module"]:::core
        Util["Utility Functions (Core Support)"]:::core
    end

    %% Documentation Subgraph
    subgraph "Documentation (docs)"
        Docs["Documentation"]:::docs
    end

    %% Testing Suite Subgraph
    subgraph "Testing Suite (test)"
        TestBasic["Basic Tests"]:::test
        TestLQCD["LQCD Tests"]:::test
        TestNAC["NAC Tests"]:::test
        TestPole["Pole Tests"]:::test
        TestRFA["RFA Tests"]:::test
    end

    %% Tutorial / Examples Subgraph
    subgraph "Tutorial / Examples (tutor)"
        Tutor["Tutorial Examples"]:::tutor
    end

    %% Auxiliary Utilities Subgraph
    subgraph "Auxiliary Utilities (util)"
        AcpRun["acprun.jl"]:::aux
        ACRun["acrun.jl"]:::aux
        GMesh["gmesh.jl"]:::aux
        PPole["ppole.jl"]:::aux
    end

    %% Relationships between components
    ACFlow -->|"dependsOn"| Config
    ACFlow -->|"reads"| InOut
    InOut -->|"feeds dataTo"| Kernel
    Kernel -->|"utilizes"| Math
    Kernel -->|"utilizes"| Grid
    ACFlow -->|"calls"| MaxEnt
    ACFlow -->|"calls"| NAC
    ACFlow -->|"calls"| RFA
    ACFlow -->|"calls"| SAC
    ACFlow -->|"calls"| SAN
    ACFlow -->|"calls"| SOM
    ACFlow -->|"calls"| SPX
    ACFlow -->|"integrates"| Util

    %% Peripheral Interactions
    Docs -->|"provides info to"| ACFlow
    TestBasic ---|"validates"| ACFlow
    TestLQCD ---|"validates"| ACFlow
    TestNAC ---|"validates"| ACFlow
    TestPole ---|"validates"| ACFlow
    TestRFA ---|"validates"| ACFlow
    Tutor -->|"demonstrates usage of"| ACFlow
    AcpRun -->|"supports execution of"| ACFlow
    ACRun -->|"supports execution of"| ACFlow
    GMesh -->|"supports execution of"| ACFlow
    PPole -->|"supports execution of"| ACFlow

    %% Click Events for src modules
    click ACFlow "https://github.com/huangli712/acflow/blob/main/src/ACFlow.jl"
    click Base "https://github.com/huangli712/acflow/blob/main/src/base.jl"
    click Config "https://github.com/huangli712/acflow/blob/main/src/config.jl"
    click Global "https://github.com/huangli712/acflow/blob/main/src/global.jl"
    click Grid "https://github.com/huangli712/acflow/blob/main/src/grid.jl"
    click InOut "https://github.com/huangli712/acflow/blob/main/src/inout.jl"
    click Kernel "https://github.com/huangli712/acflow/blob/main/src/kernel.jl"
    click Math "https://github.com/huangli712/acflow/blob/main/src/math.jl"
    click Mesh "https://github.com/huangli712/acflow/blob/main/src/mesh.jl"
    click Model "https://github.com/huangli712/acflow/blob/main/src/model.jl"
    click MaxEnt "https://github.com/huangli712/acflow/blob/main/src/maxent.jl"
    click NAC "https://github.com/huangli712/acflow/blob/main/src/nac.jl"
    click RFA "https://github.com/huangli712/acflow/blob/main/src/rfa.jl"
    click SAC "https://github.com/huangli712/acflow/blob/main/src/sac.jl"
    click SAN "https://github.com/huangli712/acflow/blob/main/src/san.jl"
    click SOM "https://github.com/huangli712/acflow/blob/main/src/som.jl"
    click SPX "https://github.com/huangli712/acflow/blob/main/src/spx.jl"
    click Types "https://github.com/huangli712/acflow/blob/main/src/types.jl"
    click Util "https://github.com/huangli712/acflow/blob/main/src/util.jl"

    %% Click Events for documentation and tests
    click Docs "https://github.com/huangli712/acflow/tree/main/docs"
    click TestBasic "https://github.com/huangli712/acflow/tree/main/test/basic"
    click TestLQCD "https://github.com/huangli712/acflow/tree/main/test/lqcd"
    click TestNAC "https://github.com/huangli712/acflow/tree/main/test/nac"
    click TestPole "https://github.com/huangli712/acflow/tree/main/test/pole"
    click TestRFA "https://github.com/huangli712/acflow/tree/main/test/rfa"
    click Tutor "https://github.com/huangli712/acflow/tree/main/tutor"
    
    %% Click Events for auxiliary utilities
    click AcpRun "https://github.com/huangli712/acflow/blob/main/util/acprun.jl"
    click ACRun "https://github.com/huangli712/acflow/blob/main/util/acrun.jl"
    click GMesh "https://github.com/huangli712/acflow/blob/main/util/gmesh.jl"
    click PPole "https://github.com/huangli712/acflow/blob/main/util/ppole.jl"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef docs fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef test fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef tutor fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef aux fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
```
