# adopy/adopy architecture

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

- Interactive diagram: https://gitdiagram.com/adopy/adopy
- Repository: https://github.com/adopy/adopy

## Overview

##### Main Components

a) Core Components:
- Task Module
- Model Module
- Engine Module
- Functions Module

b) Pre-implemented Tasks:
- PSI (Psychometric function estimation)
- DD (Delay discounting)
- CRA (Choice under risk and ambiguity)

**Top Level (User Interface Layer)**

**Middle Level (Core Components)**

**Bottom Level (Implementation Layer)**

##### Component Relationships

a) Core Architecture:
- Engine depends on both Task and Model
- Task and Model are independent base classes
- Functions module provides utilities to all components

b) Implementation Flow:
- How pre-implemented tasks inherit from base Task class
- Data flow between components during optimization

##### Specific Elements

- Rectangle: Base classes (Task, Model, Engine)
- Hexagon: Utility functions
- Rounded Rectangle: Pre-implemented tasks

b) Connections:

##### Implementation Details

Technical aspects:
- Grid-based computation methods
- Python version requirement (3.6+)
- Key dependencies
- Computation flow for optimal design

**┌─────────────────────────────────────┐**
- External Layer           │
- (NumPy, SciPy, Pandas, Python 3.6+)│
- ┤
- Core Components           │
- (Task, Model, Engine, Functions)   │
- ┤
- Pre-implemented Tasks        │
- (PSI, DD, CRA)                │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef task fill:#90EE90,stroke:#333,stroke-width:2px
    classDef function fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef external fill:#f0f0f0,stroke:#333,stroke-width:2px

    %% External Dependencies
    subgraph External["External Dependencies"]
        Python["Python 3.6+"]:::external
        NumPy["NumPy"]:::external
        SciPy["SciPy"]:::external
        Pandas["Pandas"]:::external
    end

    %% Core Components
    subgraph Core["Core Components"]
        Task["Task Base Class"]:::core
        Model["Model Base Class"]:::core
        Engine["Engine"]:::core
        
        subgraph Functions["Functions Module"]
            GridFn["Grid Functions"]:::function
            ConstFn["Constants"]:::function
            UtilFn["Utilities"]:::function
        end
    end

    %% Pre-implemented Tasks
    subgraph Tasks["Pre-implemented Tasks"]
        PSI["PSI\n(Psychometric function)"]:::task
        DD["DD\n(Delay discounting)"]:::task
        CRA["CRA\n(Choice under risk)"]:::task
    end

    %% Relationships
    Engine --> Task
    Engine --> Model
    Task --> Functions
    Model --> Functions
    
    PSI --> Task
    DD --> Task
    CRA --> Task
    
    Python --> Core
    NumPy --> Core
    SciPy --> Core
    Pandas --> Core

    %% Click Events
    click Task "https://github.com/adopy/adopy/blob/develop/adopy/base/_task.py"
    click Model "https://github.com/adopy/adopy/blob/develop/adopy/base/_model.py"
    click Engine "https://github.com/adopy/adopy/blob/develop/adopy/base/_engine.py"
    click Functions "https://github.com/adopy/adopy/tree/develop/adopy/functions/"
    click GridFn "https://github.com/adopy/adopy/blob/develop/adopy/functions/_grid.py"
    click ConstFn "https://github.com/adopy/adopy/blob/develop/adopy/functions/_const.py"
    click UtilFn "https://github.com/adopy/adopy/blob/develop/adopy/functions/_utils.py"
    click PSI "https://github.com/adopy/adopy/blob/develop/adopy/tasks/psi.py"
    click DD "https://github.com/adopy/adopy/blob/develop/adopy/tasks/dd.py"
    click CRA "https://github.com/adopy/adopy/blob/develop/adopy/tasks/cra.py"
    click Tasks "https://github.com/adopy/adopy/blob/develop/adopy/tasks/__init__.py"
    click Core "https://github.com/adopy/adopy/blob/develop/adopy/base/__init__.py"

    %% Legend
    subgraph Legend
        CoreLegend["Core Component"]:::core
        TaskLegend["Task Implementation"]:::task
        FunctionLegend["Function Module"]:::function
        ExtLegend["External Dependency"]:::external
    end
```
