# viswa4403/linescananalyzer architecture

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

- Interactive diagram: https://gitdiagram.com/viswa4403/linescananalyzer
- Repository: https://github.com/viswa4403/linescananalyzer

## Overview

##### Main Components of the System
a. Data Generation Block:
- Simulated Data Source: Manages random number generation for test mode.
- CSV Input Handler: Reads the “input.csv” file for real data.
b. Filter & Threshold Block:
- Filtering Module: Applies a sliding window (typically using a nine-element dot product with predetermined filter coefficients) to smooth out the input data.
- Thresholding Module: Analyzes the filtered values to detect and flag defective pixels.
c. Mode Selection & Parallel Processing:
- Execution Mode Selector: Determines whether the sequential (“line_scanner_sequential.py”) or parallel (“line_scanner_parallel.py”) code path is executed.
- Parallel Processing Infrastructure: Illustrates how both processing blocks work concurrently to achieve real-time performance.

##### Relationships and Interactions
- The Data Generation Block is the first entry point where data is either simulated or loaded from a CSV, feeding the output (a stream or batch of pixel values) into the Filter & Threshold Block.
- The Filter & Threshold Block receives data from the Data Generation Block, processes it via filtering (using a sliding window approach) and then applies threshold logic.
- Two execution paths (sequential and parallel) should be reflected as alternative flows, showing that the system is modular and can switch between a simple pipeline and a parallelized version for improved performance.

##### Architectural Patterns and Design Principles
- Pipeline Architecture: The system can be seen as a pipeline where data flows sequentially through stages—data acquisition followed by processing (filtering and thresholding).
- Parallelism: Emphasize that for parallel execution, data processing stages run concurrently, which is key for minimizing latency.
- Modularity: Each block (data generation, filtering, thresholding) is an independent unit that can be developed, tested, and scaled separately.

##### Relevant Technologies, Frameworks, or Libraries
- Python is the primary language, so assume built-in or popular libraries for data handling (such as csv or numpy might be in use for numerical operations).
- Although not explicitly mentioned, note that the parallel implementation may use Python’s multiprocessing, threading, or asyncio constructs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Data Module
    subgraph "Input Data Module"
        A["CSV Reader"]:::input
        B["Random Data Generator"]:::input
    end

    %% Data Generation Block
    C["Data Generation Block"]:::process

    %% Mode Selector (Decision)
    D{"Execution Mode Selector"}:::decision

    %% Sequential Processing Branch
    E["line_scanner_sequential.py"]:::process
    F["Filtering Module (Sequential)\n[Sliding Window: 9-element dot product]"]:::process
    G["Thresholding Module (Sequential)"]:::process

    %% Parallel Processing Branch
    H["line_scanner_parallel.py"]:::parallel
    I["Filtering Module (Parallel)\n[Sliding Window: 9-element dot product]"]:::parallel
    J["Thresholding Module (Parallel)"]:::parallel

    %% Merging and Output
    K["Output / Defect Reporting"]:::output

    %% Connections for Input Data Module to Data Generation Block
    A --> C
    B --> C

    %% Connection from Data Generation Block to Mode Selector
    C --> D

    %% Sequential Branch Flow
    D -- "sequential" --> E
    E --> F
    F --> G
    G --> K

    %% Parallel Branch Flow
    D -- "parallel" --> H
    H --> I
    I --> J
    J --> K

    %% Click Events
    click A "https://github.com/viswa4403/linescananalyzer/blob/main/input.csv"
    click B "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_sequential.py"
    click E "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_sequential.py"
    click H "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_parallel.py"
    click F "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_sequential.py"
    click G "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_sequential.py"
    click I "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_parallel.py"
    click J "https://github.com/viswa4403/linescananalyzer/blob/main/line_scanner_parallel.py"

    %% Styles
    classDef input fill:#f9c,stroke:#333,stroke-width:2px;
    classDef process fill:#cfc,stroke:#333,stroke-width:2px;
    classDef decision fill:#ff9,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef parallel fill:#9cf,stroke:#333,stroke-width:2px;
    classDef output fill:#fc9,stroke:#333,stroke-width:2px;
```
