# adithyan777/biasbalance architecture

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

- Interactive diagram: https://gitdiagram.com/adithyan777/biasbalance
- Repository: https://github.com/adithyan777/biasbalance

## Overview

##### Main Components Identification

a) Frontend Layer (Streamlit UI):
- Home interface (Home.py)
- Dataset Info page
- Goodness of Fit Test page
- Independence Test page
- Final Augmentation page

b) Core Processing Layer:
- Data processing utilities (utils.py)
- Component management (components.py)
- Data augmentation engine (data_augmentation.py)

c) External Services:
- OpenAI API integration (for AI-powered augmentation)

d) Data Layer:
- File upload/download handling
- Session state management

##### Detailed Component Breakdown

Frontend Layer (Blue):
**[Home Page] → [Dataset Info] → [Goodness of Fit] → [Independence Test] → [Final Augmentation]**

Processing Layer (Green):
**[Utils] ↔ [Components] ↔ [Data Augmentation Engine]**

External Services (Yellow):
**[OpenAI API] ← → [Data Augmentation Engine]**

##### Key Flows to Highlight

a) Data Upload Flow:
**User → Upload CSV → Dataset Info → Session State Storage**

b) Analysis Flow:
**Dataset → Goodness of Fit Test → Independence Test → Results Display**

c) Augmentation Flow:
**Biased Data → Data Augmentation Engine → OpenAI API → Enhanced Dataset**

##### Additional Elements

Supporting components:
- Environment variables section
- File I/O handlers
- Error handling paths

##### Notes for Implementation

- Keep the Streamlit-specific architecture visible
- Containerization boundary (Docker)
- Where environment variables are used
- Entry and exit points for data
- Session state management

##### Technical Details

- Python 3.11+ requirement
- Streamlit server port (8501)
- Docker container configuration
- API key management
- File format support (CSV)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        Home["Home Interface"]:::ui
        DatasetInfo["Dataset Info"]:::ui
        GoodnessTest["Goodness of Fit Test"]:::ui
        IndependenceTest["Independence Test"]:::ui
        FinalAug["Final Augmentation"]:::ui
    end

    subgraph Processing
        Utils["Data Processing Utilities"]:::processing
        Components["Component Management"]:::processing
        AugEngine["Data Augmentation Engine"]:::processing
    end

    subgraph Data
        SessionState[(Session State)]:::data
        FileIO["File I/O Handler"]:::data
    end

    subgraph External
        OpenAI["OpenAI API"]:::external
    end

    subgraph Infrastructure
        Docker["Docker Container"]:::infra
        DockerCompose["Docker Compose"]:::infra
        CICD["CI/CD Pipeline"]:::infra
    end

    %% Frontend Flow
    Home --> DatasetInfo
    DatasetInfo --> GoodnessTest
    GoodnessTest --> IndependenceTest
    IndependenceTest --> FinalAug

    %% Data Flow
    FileIO --> SessionState
    SessionState --> Utils
    Utils --> Components
    Components --> AugEngine
    AugEngine <-.-> OpenAI

    %% Component Interactions
    DatasetInfo --> FileIO
    GoodnessTest --> Utils
    IndependenceTest --> Utils
    FinalAug --> AugEngine

    %% Infrastructure
    Docker -.-> Home
    DockerCompose -.-> Docker
    CICD -.-> DockerCompose

    %% Click Events
    click Home "https://github.com/Adithyan777/BiasBalance/blob/main/src/Home.py"
    click DatasetInfo "https://github.com/Adithyan777/BiasBalance/blob/main/src/pages/1_Dataset_Info.py"
    click GoodnessTest "https://github.com/Adithyan777/BiasBalance/blob/main/src/pages/2_Goodness_of_Fit_Test.py"
    click IndependenceTest "https://github.com/Adithyan777/BiasBalance/blob/main/src/pages/3_Independence_Test.py"
    click FinalAug "https://github.com/Adithyan777/BiasBalance/blob/main/src/pages/4_Final_Augmentation.py"
    click Utils "https://github.com/Adithyan777/BiasBalance/blob/main/src/utils.py"
    click Components "https://github.com/Adithyan777/BiasBalance/blob/main/src/components.py"
    click AugEngine "https://github.com/Adithyan777/BiasBalance/blob/main/src/data_augmentation.py"
    click Docker "https://github.com/Adithyan777/BiasBalance/tree/main/Dockerfile"
    click DockerCompose "https://github.com/Adithyan777/BiasBalance/blob/main/docker-compose.yml"
    click CICD "https://github.com/Adithyan777/BiasBalance/blob/main/.github/workflows/docker-image.yml"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef infra fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        UI[UI Component]:::ui
        Proc[Processing Component]:::processing
        Data[(Data Storage)]:::data
        Ext[External Service]:::external
        Inf[Infrastructure]:::infra
    end
```
