# saijeevanpuchakayala/nomadanalytix architecture

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

- Interactive diagram: https://gitdiagram.com/saijeevanpuchakayala/nomadanalytix
- Repository: https://github.com/saijeevanpuchakayala/nomadanalytix

## Overview

##### Main Components
- Frontend/User Interface:
- The Streamlit application (streamlit_app.py) forms the main user interface.
- The .streamlit/config.toml file indicates configuration and theming.
- Backend/Processing Logic:
- control.py – Contains logic to control UI modifications and orchestrate actions.
- query_handler.py – Likely deals with processing and interpreting user queries.
- runner.py – Handles error management and might handle the app's re-run logic.
- sqlite_implementation.py – Manages integration with SQLite databases and data export functionality.
- Data Layer:
- dataset_files directory – Contains static CSV/Excel and other dataset files (e.g., various CSVs and possibly databases).
- runtime_files directory – Holds runtime-specific files such as live SQLite databases.
- External Services & Dependencies:
- Integration with the OpenAI API (for GPT-4 vision and natural language processing).
- Underlying Python dependencies (as specified in requirements.txt and packages.txt) that include necessary libraries for data analysis and visualization.
- Assets & Configuration:
- LICENSE, README, and Images (e.g., logo.png) serve documentation and branding purposes.

##### Relationships and Data Flow
- The user interacts with the Frontend (Streamlit app) which sends queries to the backend.
- Data is loaded from dataset_files or runtime_files, then processed by backend scripts (sqlite_implementation.py might retrieve or store query results in a SQLite database).
- The results (visualizations, summaries) are sent back to the frontend for display.
- It is likely that there is a loosely coupled interaction where the frontend communicates directly with backend modules, and external calls (to OpenAI API) are triggered as needed.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clear division between UI, business logic, and data management.
- Modular Design: Scripts such as control.py, query_handler.py, and sqlite_implementation.py indicate independent modules responsible for specific concerns.
- Integration with External Services: The project leverages OpenAI for AI-driven insights and visual data analysis.
- Configurability: The .streamlit directory and configuration files allow for custom theming and adapted runtime behavior.

##### Relevant Technologies and Frameworks
- Streamlit for rapid development of the frontend.
- Python (likely with related data analysis libraries, given the focus on datasets and visualizations).
- SQLite for lightweight database operations.
- OpenAI’s API (integrating GPT-4 Vision) for processing natural language and image data.

##### Elements to Emphasize
- That each component is clearly labeled (e.g., "Streamlit UI", "Control Logic", "Query Handler", "SQLite Integration", "Data Files", "External AI Service").
- Dependencies, such as configuration settings flowing from .streamlit/config.toml to streamlit_app.py, or environment-dependent API keys flowing into the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    U("User"):::user

    %% Frontend/User Interface Layer
    subgraph "User Interface Layer"
        SA("Streamlit App (streamlit_app.py)"):::frontend
        SC("Config (config.toml)"):::frontend
    end

    %% Application Logic Layer (Backend)
    subgraph "Application Logic Layer"
        CL("Control Logic (control.py)"):::backend
        QH("Query Handler (query_handler.py)"):::backend
        RN("Runner (runner.py)"):::backend
        SI("SQLite Integration (sqllite_implementation.py)"):::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        DS("Datasets (dataset_files)"):::data
        RF("Runtime Files (runtime_files)"):::data
    end

    %% External Integration
    subgraph "External Integration"
        OA("External AI Service (OpenAI GPT-4 Vision)"):::external
        RQ("Dependencies (requirements.txt)"):::external
        PK("Dependencies (packages.txt)"):::external
    end

    %% Assets & Documentation
    subgraph "Assets & Documentation"
        LC("License (LICENSE)"):::asset
        RM("Readme (README.md)"):::asset
        IM("Images (Assets)"):::asset
    end

    %% Connections - User Flow
    U -->|"sends query"| SA
    SC -->|"configures"| SA

    %% Frontend to Backend interactions
    SA -->|"submits query"| QH
    QH -->|"processes query"| CL
    CL -->|"calls rerun if needed"| RN
    CL -->|"manages SQLite tasks"| SI

    %% Backend to data flow
    QH -->|"reads data"| DS
    SI -->|"reads/writes"| RF

    %% Backend to External API
    QH -->|"calls API"| OA

    %% External dependencies supporting backend modules
    RQ ---|"provides"| QH
    PK ---|"provides"| QH

    %% Backend output back to Frontend
    CL -->|"returns results"| SA

    %% Styling for vertical layout
    class U user
    class SA,SC frontend
    class CL,QH,RN,SI backend
    class DS,RF data
    class OA,RQ,PK external
    class LC,RM,IM asset

    %% Click Events
    click SA "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/streamlit_app.py"
    click SC "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/.streamlit/config.toml"
    click CL "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/control.py"
    click QH "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/query_handler.py"
    click RN "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/runner.py"
    click SI "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/sqllite_implementation.py"
    click DS "https://github.com/saijeevanpuchakayala/nomadanalytix/tree/main/dataset_files"
    click RF "https://github.com/saijeevanpuchakayala/nomadanalytix/tree/main/runtime_files"
    click RQ "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/requirements.txt"
    click PK "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/packages.txt"
    click LC "https://github.com/saijeevanpuchakayala/nomadanalytix/tree/main/LICENSE"
    click RM "https://github.com/saijeevanpuchakayala/nomadanalytix/blob/main/README.md"
    click IM "https://github.com/saijeevanpuchakayala/nomadanalytix/tree/main/Images"

    %% Class Definitions for colors
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef asset fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef user fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
