# ninja-asa/cell-peak-calcium-activity-processor architecture

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

- Interactive diagram: https://gitdiagram.com/ninja-asa/cell-peak-calcium-activity-processor
- Repository: https://github.com/ninja-asa/cell-peak-calcium-activity-processor

## Overview

##### Main Components
- User Interface:
- Web Application using Streamlit (represented by files in the “.streamlit” directory, “main-page.py”, and “pages/debug_page.py”).
- Command Line Interface (the entry point in “app/__main__.py”).
- Pipeline Orchestrator:
- The “app/orchestrator/pipeline.py” module coordinates the overall processing flow.
- Data Processing Modules:
- “app/data/” contains modules for processing (cell, population, process) that implements the core business logic for peak detection, feature extraction, and cell activity determination.
- File Handling and Export:
- The “app/file/” folder (e.g., “tables.py”) handles the formatting and exporting of results to CSV and Excel.
- Configuration and Environment:
- “app/config.py”, “app_config.json”, and the “example.env” file provide adjustable parameters for the processing pipeline.
- Deployment and Infrastructure:
- Containerization (Dockerfile, Docker Compose, and .devcontainer) for consistent development and deployment environments.
- Testing and CI/CD:
- The “tests/” directory with unit tests for data processing and orchestration, along with GitHub workflows for automated tests.

##### Relationships and Interactions
- Both the Web UI (Streamlit pages) and CLI entry point invoke the Pipeline Orchestrator.
- The Pipeline Orchestrator calls Data Processing modules to analyze time series data (reading, peak detection, feature extraction).
- Once processed, the File Handling component formats the results into output files (CSV/Excel) according to the configuration.
- Configuration settings (from “app_config.json” and environment variables) drive processing parameters (such as PEAK_THRESHOLD and PEAK_WINDOW) and output directories.
- Containerization components (Dockerfiles and docker-compose) ensure that the app runs in a reproducible environment.
- Testing components verify the correctness of data processing and pipeline orchestration.

##### Architectural Patterns and Design Principles
- Modular design/separation of concerns: The project is divided into clear, logically separated modules (UI, orchestration, processing, file handling, configuration).
- Multiple entry points: Providing both a web-based and a CLI-based user interface.
- Container-oriented deployment: Ensuring consistency across development and deployment environments.
- Test-driven development with clearly defined unit tests and integration testing through GitHub workflows.

##### Presenting Detail
- Be very detailed: Even though it is beneficial to break out the system into as many discrete components as possible, ensure that the relationships—especially the interactions between the web interface, the orchestrator, and the data processing modules—are clearly illustrated.
- For clarity, an example breakdown could be:
- User interacts with the web UI (Streamlit pages) or triggers the CLI.
- This interaction calls the Pipeline Orchestrator.
- The orchestrator uses the Data Processing modules (cells, peaks, populations) to calculate desired metrics.
- The processed data is handed off to the File Export Module which then outputs CSV and Excel reports.
- The entire setup is governed by configuration files and runs within containers, with tests ensuring quality across modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["Streamlit Frontend"]:::frontend
        UI2["CLI Entry Point"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        ORCH["Pipeline Orchestrator"]:::orchestrator
        subgraph "Data Processing Modules"
            DP1["Cell Processing"]:::data
            DP2["Population Analysis"]:::data
            DP3["Process Logic"]:::data
        end
        FE["File Exporter"]:::export
        CONF["Configuration Manager"]:::config
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DEP["Container/DevOps"]:::deployment
        TEST["Testing/CI-CD"]:::testing
    end

    %% Connections
    UI1 -->|"triggers"| ORCH
    UI2 -->|"triggers"| ORCH
    CONF -->|"influences"| ORCH
    ORCH -->|"calls"| DP1
    ORCH -->|"calls"| DP2
    ORCH -->|"calls"| DP3
    DP1 -->|"sendsData"| FE
    DP2 -->|"sendsData"| FE
    DP3 -->|"sendsData"| FE
    DEP --- ORCH
    TEST --- ORCH
    TEST --- DP1
    TEST --- DP2
    TEST --- DP3

    %% Click Events for Web UI
    click UI1 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/.streamlit"
    click UI1 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/main-page.py"
    click UI1 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/pages/debug_page.py"

    %% Click Event for CLI
    click UI2 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/__main__.py"

    %% Click Event for Pipeline Orchestrator
    click ORCH "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/orchestrator/pipeline.py"

    %% Click Events for Data Processing Modules
    click DP1 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/data/cell.py"
    click DP2 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/data/population.py"
    click DP3 "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/data/process.py"

    %% Click Event for File Handling and Export Module
    click FE "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/file/tables.py"

    %% Click Events for Configuration and Environment Management
    click CONF "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app/config.py"
    click CONF "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/app_config.json"
    click CONF "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/example.env"

    %% Click Events for Deployment and Infrastructure
    click DEP "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/tree/main/Dockerfile"
    click DEP "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/docker-compose.yml"
    click DEP "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/blob/main/.devcontainer"

    %% Click Events for Testing and CI/CD
    click TEST "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/tree/main/tests/"
    click TEST "https://github.com/ninja-asa/cell-peak-calcium-activity-processor/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#aqua,stroke:#333,stroke-width:2px;
    classDef ui fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef orchestrator fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef data fill:#f94144,stroke:#333,stroke-width:2px;
    classDef export fill:#277da1,stroke:#333,stroke-width:2px;
    classDef config fill:#f3722c,stroke:#333,stroke-width:2px;
    classDef deployment fill:#577590,stroke:#333,stroke-width:2px;
    classDef testing fill:#6a4c93,stroke:#333,stroke-width:2px;
```
