# varadpatil07/mechmodel architecture

> Architecture diagram of the GitHub repository varadpatil07/mechmodel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/varadpatil07/mechmodel
- Repository: https://github.com/varadpatil07/mechmodel

## Overview

MLPlatform is a full-stack ML SaaS: users manage datasets, explore them, train and evaluate models, then register models for predictions and reports. Its frontend reaches a FastAPI API; training is dispatched asynchronously to Celery. The README documents the broader product capabilities, while sampled source confirms the application entry point, training task flow, preprocessing, inference, and natural-language query orchestration. Some endpoint internals and integrations are unsampled, so uncertain wiring is omitted.

Main entry points: [`backend/app/api/v1/router.py`](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/router.py) (API router), [`backend/app/db/session.py`](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/db/session.py) (PostgreSQL), [`backend/app/tasks/training_tasks.py`](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/tasks/training_tasks.py) (Training task), [`backend/app/nlquery/engine.py`](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/engine.py) (Query engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["User interface"]
  node_frontend["Next.js app"]
  node_api_client["API client<br/>[api.ts]"]
  node_auth_store["Auth state<br/>[authStore.ts]"]
end

subgraph group_api["Platform API"]
  node_main["FastAPI app<br/>[main.py]"]
  node_router["API router<br/>[router.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_projects["Projects<br/>[projects.py]"]
  node_datasets["Dataset management<br/>[datasets.py]"]
  node_eda["EDA and reports<br/>[eda.py]"]
  node_training_api["Training jobs<br/>[training.py]"]
  node_models_api["Model registry<br/>[models.py]"]
  node_predictions["Prediction API<br/>[predictions.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_admin["Admin<br/>[admin.py]"]
end

subgraph group_ml["ML lifecycle"]
  node_preprocessing["Preprocessing<br/>[pipeline.py]"]
  node_trainer["Model training<br/>[trainer.py]"]
  node_tuning["Hyperparameter tuning<br/>[tuning.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
  node_explainer["Explainability<br/>[explainer.py]"]
  node_registry["Artifact registry<br/>[model_registry.py]"]
  node_inference["Inference helpers<br/>[inference.py]"]
end

subgraph group_query["Natural-language query"]
  node_query_api["Query endpoint<br/>[query.py]"]
  node_query_engine["Query engine<br/>[engine.py]"]
  node_providers["Query providers"]
  node_executor["Query executor<br/>[executor.py]"]
  node_validator["Query validator<br/>[validator.py]"]
  node_sessions["Query sessions<br/>[session.py]"]
end

subgraph group_infra["State and workers"]
  node_database[("PostgreSQL<br/>[session.py]")]
  node_celery["Celery worker<br/>[celery_app.py]"]
  node_training_task["Training task<br/>[training_tasks.py]"]
  node_redis[("Redis broker")]
end

node_user(("User"))
node_llm_service["LLM provider"]

node_user -->|"uses"| node_frontend
node_frontend -->|"requests through"| node_api_client
node_api_client -->|"HTTP requests"| node_main
node_auth -->|"JWT state"| node_auth_store
node_main -->|"mounts routes"| node_router
node_router -->|"dispatches"| node_auth
node_router -->|"dispatches"| node_projects
node_router -->|"dispatches"| node_datasets
node_router -->|"dispatches"| node_eda
node_router -->|"dispatches"| node_training_api
node_router -->|"dispatches"| node_models_api
node_router -->|"dispatches"| node_predictions
node_router -->|"dispatches"| node_dashboard
node_router -->|"dispatches"| node_admin
node_auth -->|"reads/writes"| node_database
node_projects -->|"reads/writes"| node_database
node_datasets -->|"stores metadata"| node_database
node_eda -->|"reads dataset records"| node_database
node_training_api -->|"creates job"| node_database
node_training_api -->|"dispatches job"| node_celery
node_models_api -->|"reads/writes"| node_database
node_predictions -->|"reads model records"| node_database
node_dashboard -->|"aggregates statistics"| node_database
node_admin -->|"manages records"| node_database
node_celery -->|"runs task"| node_training_task
node_celery -->|"uses broker"| node_redis
node_training_task -->|"updates job/model"| node_database
node_training_task -->|"builds pipeline"| node_preprocessing
node_training_task -->|"tunes parameters"| node_tuning
node_training_task -->|"fits model"| node_trainer
node_training_task -->|"evaluates model"| node_metrics
node_training_task -->|"explains model"| node_explainer
node_training_task -->|"saves artifacts"| node_registry
node_predictions -->|"runs inference"| node_inference
node_models_api -->|"manages artifacts"| node_registry
node_router -->|"dispatches"| node_query_api
node_query_api -->|"checks ownership/models"| node_database
node_query_api -->|"processes question"| node_query_engine
node_query_engine -->|"parses query"| node_providers
node_providers -.->|"requests interpretation"| node_llm_service
node_query_engine -->|"validates query"| node_validator
node_query_engine -->|"executes structured query"| node_executor
node_query_engine -->|"reads/writes follow-ups"| node_sessions
node_query_api -->|"predicts from model"| node_inference

click node_frontend "https://github.com/varadpatil07/mechmodel/tree/main/frontend/src/app"
click node_api_client "https://github.com/varadpatil07/mechmodel/blob/main/frontend/src/lib/api.ts"
click node_auth_store "https://github.com/varadpatil07/mechmodel/blob/main/frontend/src/stores/authStore.ts"
click node_main "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/main.py"
click node_router "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/router.py"
click node_auth "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/auth.py"
click node_projects "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/projects.py"
click node_datasets "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/datasets.py"
click node_eda "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/eda.py"
click node_training_api "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/training.py"
click node_models_api "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/models.py"
click node_predictions "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/predictions.py"
click node_dashboard "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/dashboard.py"
click node_admin "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/admin.py"
click node_preprocessing "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/preprocessing/pipeline.py"
click node_trainer "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/training/trainer.py"
click node_tuning "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/training/tuning.py"
click node_metrics "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/evaluation/metrics.py"
click node_explainer "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/explainability/explainer.py"
click node_registry "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/registry/model_registry.py"
click node_inference "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/inference.py"
click node_query_api "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/query.py"
click node_query_engine "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/engine.py"
click node_providers "https://github.com/varadpatil07/mechmodel/tree/main/backend/app/nlquery/providers"
click node_executor "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/executor.py"
click node_validator "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/validator.py"
click node_sessions "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/session.py"
click node_database "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/db/session.py"
click node_celery "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/tasks/celery_app.py"
click node_training_task "https://github.com/varadpatil07/mechmodel/blob/main/backend/app/tasks/training_tasks.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_api_client,node_auth_store,node_user toneBlue
class node_main,node_router,node_auth,node_projects,node_datasets,node_eda,node_training_api,node_models_api,node_predictions,node_dashboard,node_admin toneAmber
class node_preprocessing,node_trainer,node_tuning,node_metrics,node_explainer,node_registry,node_inference toneMint
class node_query_api,node_query_engine,node_providers,node_executor,node_validator,node_sessions toneRose
class node_database,node_celery,node_training_task,node_redis,node_llm_service toneIndigo
```

## Components

### User interface

- [Next.js app](https://github.com/varadpatil07/mechmodel/tree/main/frontend/src/app): `frontend/src/app`
- [API client](https://github.com/varadpatil07/mechmodel/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Auth state](https://github.com/varadpatil07/mechmodel/blob/main/frontend/src/stores/authStore.ts): `frontend/src/stores/authStore.ts`

### Platform API

- [FastAPI app](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Authentication](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/auth.py): `backend/app/api/v1/endpoints/auth.py`
- [Projects](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/projects.py): `backend/app/api/v1/endpoints/projects.py`
- [Dataset management](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/datasets.py): `backend/app/api/v1/endpoints/datasets.py`
- [EDA and reports](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/eda.py): `backend/app/api/v1/endpoints/eda.py`
- [Training jobs](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/training.py): `backend/app/api/v1/endpoints/training.py`
- [Model registry](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/models.py): `backend/app/api/v1/endpoints/models.py`
- [Prediction API](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/predictions.py): `backend/app/api/v1/endpoints/predictions.py`
- [Dashboard](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/dashboard.py): `backend/app/api/v1/endpoints/dashboard.py`
- [Admin](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/admin.py): `backend/app/api/v1/endpoints/admin.py`

### ML lifecycle

- [Preprocessing](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/preprocessing/pipeline.py): `backend/app/ml/preprocessing/pipeline.py`
- [Model training](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/training/trainer.py): `backend/app/ml/training/trainer.py`
- [Hyperparameter tuning](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/training/tuning.py): `backend/app/ml/training/tuning.py`
- [Evaluation metrics](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/evaluation/metrics.py): `backend/app/ml/evaluation/metrics.py`
- [Explainability](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/explainability/explainer.py): `backend/app/ml/explainability/explainer.py`
- [Artifact registry](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/registry/model_registry.py): `backend/app/ml/registry/model_registry.py`
- [Inference helpers](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/ml/inference.py): `backend/app/ml/inference.py`

### Natural-language query

- [Query endpoint](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/api/v1/endpoints/query.py): `backend/app/api/v1/endpoints/query.py`
- [Query engine](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/engine.py): `backend/app/nlquery/engine.py`
- [Query providers](https://github.com/varadpatil07/mechmodel/tree/main/backend/app/nlquery/providers): `backend/app/nlquery/providers`
- [Query executor](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/executor.py): `backend/app/nlquery/executor.py`
- [Query validator](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/validator.py): `backend/app/nlquery/validator.py`
- [Query sessions](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/nlquery/session.py): `backend/app/nlquery/session.py`

### State and workers

- [PostgreSQL](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Celery worker](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/tasks/celery_app.py): `backend/app/tasks/celery_app.py`
- [Training task](https://github.com/varadpatil07/mechmodel/blob/main/backend/app/tasks/training_tasks.py): `backend/app/tasks/training_tasks.py`
- **Redis broker**

### Other components

- **User**
- **LLM provider**

## Connections

- User → Next.js app: uses
- Next.js app → API client: requests through
- API client → FastAPI app: HTTP requests
- Authentication → Auth state: JWT state
- FastAPI app → API router: mounts routes
- API router → Authentication: dispatches
- API router → Projects: dispatches
- API router → Dataset management: dispatches
- API router → EDA and reports: dispatches
- API router → Training jobs: dispatches
- API router → Model registry: dispatches
- API router → Prediction API: dispatches
- API router → Dashboard: dispatches
- API router → Admin: dispatches
- Authentication → PostgreSQL: reads/writes
- Projects → PostgreSQL: reads/writes
- Dataset management → PostgreSQL: stores metadata
- EDA and reports → PostgreSQL: reads dataset records
- Training jobs → PostgreSQL: creates job
- Training jobs → Celery worker: dispatches job
- Model registry → PostgreSQL: reads/writes
- Prediction API → PostgreSQL: reads model records
- Dashboard → PostgreSQL: aggregates statistics
- Admin → PostgreSQL: manages records
- Celery worker → Training task: runs task
- Celery worker → Redis broker: uses broker
- Training task → PostgreSQL: updates job/model
- Training task → Preprocessing: builds pipeline
- Training task → Hyperparameter tuning: tunes parameters
- Training task → Model training: fits model
- Training task → Evaluation metrics: evaluates model
- Training task → Explainability: explains model
- Training task → Artifact registry: saves artifacts
- Prediction API → Inference helpers: runs inference
- Model registry → Artifact registry: manages artifacts
- API router → Query endpoint: dispatches
- Query endpoint → PostgreSQL: checks ownership/models
- Query endpoint → Query engine: processes question
- Query engine → Query providers: parses query
- Query providers → LLM provider: requests interpretation
- Query engine → Query validator: validates query
- Query engine → Query executor: executes structured query
- Query engine → Query sessions: reads/writes follow-ups
- Query endpoint → Inference helpers: predicts from model
