# has1elb/datacarelytics architecture

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

- Interactive diagram: https://gitdiagram.com/has1elb/datacarelytics
- Repository: https://github.com/has1elb/datacarelytics

## Overview

##### Project Type & Purpose
- DataCarelytics is a Python-based analytics suite for healthcare data.
- It provides:
- Medical chatbots (two versions)
- Medical-report natural-language analysis
- Tabular-data ML workflows
- Image-based tumor classification

##### File Structure
Top-level modules each represent a distinct service/component:
- medical_chatbot & medical_chatbot2 – chat interfaces + FAISS vector store
- medical_report_analysis – text-analysis agents & app logic
- tabular_data – data ingestion, preprocessing, ML models
- trt_image – pre-trained H5 models & image classification logic
- main.py (root) – likely an entry-point or orchestrator
- assets/style.css, style.css – shared front-end styling
- requirements.txt – dependencies (e.g., Flask/FastAPI, FAISS, TensorFlow/PyTorch)

##### Additional Insights (README is minimal, so infer from code)
- medical_chatbot2/create_vectorstore.py builds FAISS indices
- Each sub-folder has `app.py` or `main.py`, hinting at micro-app endpoints
- Vector store data lives under `vectorstore/db_faiss/`

##### Main Components
a. Client Layer
- Web UI (HTML/CSS) served by each “app.py”
- Could be browser or CLI
b. API Gateway / Orchestrator
- root `main.py` routes incoming requests to the correct service
c. Services (each as its own module)
1. Chatbot Service v1 (medical_chatbot/app.py + utils.py)
2. Chatbot Service v2 (medical_chatbot2/main.py + vectorstore)
3. Report Analysis Service (medical_report_analysis/app.py + agents.py)
4. Tabular Data Service (tabular_data/data_processing.py + ml_models.py)
5. Image Classification Service (trt_image/main.py)
d. Storage & Models
- FAISS Vector Store (`.faiss` & `.pkl` files)
- Pretrained models (`.h5` under trt_image)
- Tabular data configs & model artifacts
e. Shared Libraries
- utils.py under various modules

##### Relationships & Data Flows
- Client → API Gateway (`main.py`) → specific service
- Chatbot services query/update FAISS vector store
- Report Analysis and Tabular Data services read input from client or data sources, run models, return results
- Image service loads H5 models in memory, processes uploads, returns predictions
- All services may share common configs or auth middleware

##### Architectural Patterns
- Modular (micro-app) services
- Separation of concerns: each domain in its own package
- Data-flow pipelines (e.g., vectorstore build → query → chat response)
- ML model hosting and inference

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["Browser UI"]:::client
        CSS_shared["style.css"]:::client
        CSS_chatbot1["style.css (Chatbot1)"]:::client
    end

    %% API Gateway
    APIGateway["API Gateway\nmain.py"]:::gateway

    %% Services
    subgraph "Chatbot Service v1" 
        direction TB
        Chat1_app["app.py"]:::service
        Chat1_utils["utils.py"]:::service
    end

    subgraph "Chatbot Service v2" 
        direction TB
        Chat2_main["main.py"]:::service
        Chat2_create["create_vectorstore.py"]:::service
        Chat2_index_faiss["index.faiss"]:::service
        Chat2_index_pkl["index.pkl"]:::service
    end

    subgraph "Report Analysis Service" 
        direction TB
        RA_app["app.py"]:::service
        RA_agents["agents.py"]:::service
    end

    subgraph "Tabular Data Service" 
        direction TB
        TD_proc["data_processing.py"]:::service
        TD_ml["ml_models.py"]:::service
        TD_config["config.py"]:::service
        TD_utils["utils.py"]:::service
    end

    subgraph "Image Classification Service" 
        direction TB
        Img_main["main.py"]:::service
        Img_model1["advanced_tumor_classification_model.h5"]:::service
        Img_model2["chest_xray_model.h5"]:::service
    end

    %% Datastores & Models
    FAISS["FAISS Vector Store"]:::db
    TabularModels["Tabular Data Models"]:::db
    MLModels["H5 Models"]:::db

    %% Connections
    Browser -->|"HTTP/REST"| APIGateway
    CSS_shared --> Browser
    CSS_chatbot1 --> Browser

    APIGateway -->|"route to v1"| Chat1_app
    APIGateway -->|"route to v2"| Chat2_main
    APIGateway -->|"route to analysis"| RA_app
    APIGateway -->|"route to tabular"| TD_proc
    APIGateway -->|"route to image"| Img_main

    Chat1_app -->|"FAISS API call"| FAISS
    FAISS -->|"vector query"| Chat1_app

    Chat2_create -->|"build index"| FAISS
    Chat2_main -->|"FAISS API call"| FAISS
    FAISS -->|"vector query"| Chat2_main

    RA_app -->|"invoke agents"| RA_agents

    TD_proc -->|"load models"| TabularModels
    TabularModels -->|"model inference"| TD_proc

    Img_main -->|"load H5"| MLModels
    MLModels -->|"inference"| Img_main

    %% Click Events
    click CSS_shared "https://github.com/has1elb/datacarelytics/blob/main/style.css"
    click CSS_chatbot1 "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot/assets/style.css"
    click APIGateway "https://github.com/has1elb/datacarelytics/blob/main/main.py"
    click Chat1_app "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot/app.py"
    click Chat1_utils "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot/utils.py"
    click Chat2_main "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot2/main.py"
    click Chat2_create "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot2/create_vectorstore.py"
    click Chat2_index_faiss "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot2/vectorstore/db_faiss/index.faiss"
    click Chat2_index_pkl "https://github.com/has1elb/datacarelytics/blob/main/medical_chatbot2/vectorstore/db_faiss/index.pkl"
    click RA_app "https://github.com/has1elb/datacarelytics/blob/main/medical_report_analysis/app.py"
    click RA_agents "https://github.com/has1elb/datacarelytics/blob/main/medical_report_analysis/agents.py"
    click TD_proc "https://github.com/has1elb/datacarelytics/blob/main/tabular_data/data_processing.py"
    click TD_ml "https://github.com/has1elb/datacarelytics/blob/main/tabular_data/ml_models.py"
    click TD_config "https://github.com/has1elb/datacarelytics/blob/main/tabular_data/config.py"
    click TD_utils "https://github.com/has1elb/datacarelytics/blob/main/tabular_data/utils.py"
    click Img_main "https://github.com/has1elb/datacarelytics/blob/main/trt_image/main.py"
    click Img_model1 "https://github.com/has1elb/datacarelytics/blob/main/trt_image/advanced_tumor_classification_model.h5"
    click Img_model2 "https://github.com/has1elb/datacarelytics/blob/main/trt_image/chest_xray_model.h5"

    %% Styles
    classDef client fill:#FFA500,stroke:#333,stroke-width:1px
    classDef gateway fill:#ADD8E6,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef service fill:#E0FFFF,stroke:#333,stroke-width:1px
    classDef db fill:#90EE90,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
