# dexxeth/ml-studio architecture

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

- Interactive diagram: https://gitdiagram.com/dexxeth/ml-studio
- Repository: https://github.com/dexxeth/ml-studio

## Overview

##### Project Type and Purpose
- This is a full-stack machine-learning model management web application.
- Frontend: Next.js (React) UI for dataset upload, preview, feature selection, model training, and download.
- Backend: Python service (main.py) exposing REST endpoints under `backend/routes` for data ingestion, preprocessing, ML training, and model persistence.
- Database: MongoDB (via `backend/database/mongo.py`) to store datasets, feature metadata, training run info, and saved model references.

##### File Structure Analysis
- Top-level directories:
- `backend/` – Python service modules (database, preprocessing, models, routes, utils).
- `src/app/` – Next.js app pages for each user workflow step.
- `src/components/` – Reusable UI components (buttons, tables, cards, alerts).
- `src/hooks/`, `src/lib/`, `src/styles/` – Client-side utilities, global styles, and custom hooks.
- Key config files: `next.config.ts`, `tsconfig.json`, Tailwind (`tailwind.config.js`), ESLint (`eslint.config.mjs`), `.hintrc`.
- ML modules under `backend/models/` implement algorithms (SVM, K-means, Random Forest, Linear Regression).
- `backend/preprocessing/preprocessor.py` cleans and transforms raw datasets.
- `backend/utils/` contains helper scripts (`clean_nan_inf.py`, `save_model.py`).

##### README Insights
- Confirms Next.js frontend bootstrapped with create-next-app.
- No explicit backend framework mentioned; infer a lightweight Python HTTP server (Flask or FastAPI) in `backend/main.py`.
- Workflow: dev server at `npm run dev` for frontend; likely separate command for Python backend.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client"
        direction TB
        User["User"]:::frontend
        Browser["Browser UI"]:::frontend
        User -->|interacts| Browser
        Browser -->|navigates| UploadPage
        UploadPage["UploadDatasetPage"]:::frontend
        PreviewPage["PreviewDatasetPage"]:::frontend
        FeaturePage["FeatureSelectionPage"]:::frontend
        TrainingPage["TrainingPage"]:::frontend
        UIComponents["UI Components"]:::frontend
        ReusableComponents["Reusable Components"]:::frontend

        Browser --> UploadPage
        UploadPage --> PreviewPage
        PreviewPage --> FeaturePage
        FeaturePage --> TrainingPage
    end

    %% API Gateway
    APIGateway["API Gateway\n(backend/main.py)"]:::backend

    %% Backend Side
    subgraph "Backend"
        direction TB
        APIGateway -->|HTTP POST /upload_dataset| UploadRoute
        APIGateway -->|HTTP GET /get_dataset| GetDatasetRoute
        APIGateway -->|HTTP GET /get_features| GetFeaturesRoute
        APIGateway -->|HTTP POST /select_features| SelectFeaturesRoute
        APIGateway -->|HTTP POST /train_models| TrainRoute
        APIGateway -->|HTTP GET /download_model| DownloadRoute

        subgraph "API Layer"
            direction TB
            UploadRoute["UploadDataset Route"]:::backend
            GetDatasetRoute["GetDataset Route"]:::backend
            GetFeaturesRoute["GetFeatures Route"]:::backend
            SelectFeaturesRoute["SelectFeatures Route"]:::backend
            TrainRoute["TrainModels Route"]:::backend
            DownloadRoute["DownloadModel Route"]:::backend
        end

        subgraph "Processing & Training"
            direction TB
            Preprocessor["Preprocessing Module"]:::backend
            MLTraining["ML Training Service"]:::backend
        end

        subgraph "Persistence Layer"
            direction TB
            MongoConnector["MongoDB Connector"]:::database
            SaveModelHelper["Model Serialization Helper"]:::storage
        end

        %% Internal flows
        UploadRoute -->|dataset file| Preprocessor
        GetDatasetRoute -->|query| MongoConnector
        GetFeaturesRoute -->|query metadata| MongoConnector
        SelectFeaturesRoute -->|features list| Preprocessor
        TrainRoute -->|training request| MLTraining
        MLTraining -->|use models| AllModels
        MLTraining -->|use model k-means| KMeans
        MLTraining -->|use model linear regression| LinearReg
        MLTraining -->|use model random forest| RandomForest
        MLTraining -->|use model svm| SVM
        Preprocessor -->|cleaned data| MLTraining
        MLTraining -->|model artifact| SaveModelHelper
        MLTraining -->|run logs| MongoConnector
        SaveModelHelper -->|persist artifact| MongoConnector
        DownloadRoute -->|fetch artifact| SaveModelHelper
    end

    %% Click Events
    click UploadPage "https://github.com/dexxeth/ml-studio/blob/main/src/app/upload-dataset/page.tsx"
    click PreviewPage "https://github.com/dexxeth/ml-studio/blob/main/src/app/preview-dataset/page.tsx"
    click FeaturePage "https://github.com/dexxeth/ml-studio/blob/main/src/app/features-selection/page.tsx"
    click TrainingPage "https://github.com/dexxeth/ml-studio/blob/main/src/app/training/page.tsx"
    click UIComponents "https://github.com/dexxeth/ml-studio/tree/main/src/components/ui/"
    click ReusableComponents "https://github.com/dexxeth/ml-studio/tree/main/src/components/"
    click APIGateway "https://github.com/dexxeth/ml-studio/blob/main/backend/main.py"
    click UploadRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/upload_dataset.py"
    click GetDatasetRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/get_dataset.py"
    click GetFeaturesRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/get_features.py"
    click SelectFeaturesRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/select_features.py"
    click TrainRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/train_models.py"
    click DownloadRoute "https://github.com/dexxeth/ml-studio/blob/main/backend/routes/download_model.py"
    click Preprocessor "https://github.com/dexxeth/ml-studio/blob/main/backend/preprocessing/preprocessor.py"
    click AllModels "https://github.com/dexxeth/ml-studio/blob/main/backend/models/all.py"
    click KMeans "https://github.com/dexxeth/ml-studio/blob/main/backend/models/k_means.py"
    click LinearReg "https://github.com/dexxeth/ml-studio/blob/main/backend/models/linear_regression.py"
    click RandomForest "https://github.com/dexxeth/ml-studio/blob/main/backend/models/random_forest.py"
    click SVM "https://github.com/dexxeth/ml-studio/blob/main/backend/models/svm.py"
    click MongoConnector "https://github.com/dexxeth/ml-studio/blob/main/backend/database/mongo.py"
    click SaveModelHelper "https://github.com/dexxeth/ml-studio/blob/main/backend/utils/save_model.py"
    click CleanHelpers "https://github.com/dexxeth/ml-studio/blob/main/backend/utils/clean_nan_inf.py"

    %% Styles
    classDef frontend fill:#b3e5fc,stroke:#0288d1,stroke-width:1px;
    classDef backend fill:#bbdefb,stroke:#1976d2,stroke-width:1px;
    classDef database fill:#ffe0b2,stroke:#e65100,stroke-width:1px;
    classDef storage fill:#cfd8dc,stroke:#546e7a,stroke-width:1px;
```
