# mohamednihmath18/diamond-dynamics architecture

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

- Interactive diagram: https://gitdiagram.com/mohamednihmath18/diamond-dynamics
- Repository: https://github.com/mohamednihmath18/diamond-dynamics

## Overview

Diamond Dynamics is a Streamlit application for diamond price prediction, market segmentation, and visual summaries, backed by trained ML artifacts and processed diamond data. Its documented development workflow moves from preprocessing and exploration through feature engineering, regression/ANN modeling, and clustering; users enter diamond attributes to obtain prices or a segment, while the dashboard summarizes stored segment data. The app implementation is excerpted; notebook-stage links follow the README pipeline, which documents these capabilities but does not establish every implementation detail.

Main entry points: [`data/diamonds_engineered.csv`](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_engineered.csv) (Engineered Data), [`app/app.py`](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py) (Streamlit Application), [`notebooks/01_data_preprocessing.ipynb`](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/01_data_preprocessing.ipynb) (Preprocessing), [`data/diamonds_clean.csv`](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_clean.csv) (Clean Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data_workflow["Data Workflow"]
  node_raw_data["Raw Diamonds<br/>[diamonds.csv]"]
  node_preprocessing["Preprocessing"]
  node_clean_data["Clean Data<br/>[diamonds_clean.csv]"]
  node_exploration["Exploratory Analysis<br/>[02_eda.ipynb]"]
  node_engineering["Feature Engineering"]
  node_engineered_data["Engineered Data"]
end

subgraph group_modeling["Modeling"]
  node_regression["Regression Models"]
  node_ann["ANN Model<br/>[05_ann_model.ipynb]"]
  node_clustering["K-Means Segmentation"]
end

subgraph group_runtime["Streamlit App"]
  node_app["Streamlit Application<br/>[app.py]"]
  node_price_flow["Price Prediction<br/>[app.py]"]
  node_segment_flow["Segment Prediction<br/>[app.py]"]
  node_insights["Visual Insights<br/>[app.py]"]
end

subgraph group_artifacts["Runtime Data"]
  node_final_data["Segmented Data<br/>[diamonds_final.csv]"]
  node_reg_model["Price Model<br/>[xgb_model.pkl]"]
  node_cluster_model["Cluster Model<br/>[kmeans_model.pkl]"]
  node_scalers["Feature Scalers<br/>[scaler.pkl]"]
  node_cluster_scaler["Cluster Scaler<br/>[scaler_cluster.pkl]"]
  node_cluster_names["Segment Names<br/>[cluster_names.pkl]"]
end

node_analyst(("Analyst"))
node_shopper(("App User"))

node_raw_data -->|"cleans"| node_preprocessing
node_preprocessing -->|"produces"| node_clean_data
node_clean_data -->|"analyzes"| node_exploration
node_exploration -->|"informs"| node_engineering
node_engineering -->|"produces"| node_engineered_data
node_engineered_data -->|"trains"| node_regression
node_engineered_data -->|"trains"| node_ann
node_engineered_data -->|"clusters"| node_clustering
node_clustering -->|"labels"| node_final_data
node_shopper -->|"uses"| node_app
node_app -->|"shows"| node_price_flow
node_app -->|"shows"| node_segment_flow
node_app -->|"shows"| node_insights
node_price_flow -->|"transforms input"| node_scalers
node_price_flow -->|"predicts price"| node_reg_model
node_segment_flow -->|"transforms input"| node_cluster_scaler
node_segment_flow -->|"predicts cluster"| node_cluster_model
node_segment_flow -->|"names cluster"| node_cluster_names
node_insights -->|"reads summaries"| node_final_data

click node_raw_data "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds.csv"
click node_preprocessing "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/01_data_preprocessing.ipynb"
click node_clean_data "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_clean.csv"
click node_exploration "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/02_eda.ipynb"
click node_engineering "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/03_feature_engineering.ipynb"
click node_engineered_data "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_engineered.csv"
click node_regression "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/04_regression_models.ipynb"
click node_ann "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/05_ann_model.ipynb"
click node_clustering "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/06_clustering.ipynb"
click node_final_data "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_final.csv"
click node_reg_model "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/xgb_model.pkl"
click node_cluster_model "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/kmeans_model.pkl"
click node_scalers "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/scaler.pkl"
click node_cluster_scaler "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/scaler_cluster.pkl"
click node_cluster_names "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/cluster_names.pkl"
click node_app "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py"
click node_price_flow "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py"
click node_segment_flow "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py"
click node_insights "https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.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_raw_data,node_preprocessing,node_clean_data,node_exploration,node_engineering,node_engineered_data,node_shopper toneBlue
class node_regression,node_ann,node_clustering toneAmber
class node_app,node_price_flow,node_segment_flow,node_insights toneMint
class node_final_data,node_reg_model,node_cluster_model,node_scalers,node_cluster_scaler,node_cluster_names toneRose
class node_analyst toneIndigo
```

## Components

### Data Workflow

- [Raw Diamonds](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds.csv): `data/diamonds.csv`
- [Preprocessing](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/01_data_preprocessing.ipynb): `notebooks/01_data_preprocessing.ipynb`
- [Clean Data](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_clean.csv): `data/diamonds_clean.csv`
- [Exploratory Analysis](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/02_eda.ipynb): `notebooks/02_eda.ipynb`
- [Feature Engineering](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/03_feature_engineering.ipynb): `notebooks/03_feature_engineering.ipynb`
- [Engineered Data](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_engineered.csv): `data/diamonds_engineered.csv`

### Modeling

- [Regression Models](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/04_regression_models.ipynb): `notebooks/04_regression_models.ipynb`
- [ANN Model](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/05_ann_model.ipynb): `notebooks/05_ann_model.ipynb`
- [K-Means Segmentation](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/notebooks/06_clustering.ipynb): `notebooks/06_clustering.ipynb`

### Streamlit App

- [Streamlit Application](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py): `app/app.py`
- [Price Prediction](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py): `app/app.py`
- [Segment Prediction](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py): `app/app.py`
- [Visual Insights](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/app/app.py): `app/app.py`

### Runtime Data

- [Segmented Data](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/data/diamonds_final.csv): `data/diamonds_final.csv`
- [Price Model](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/xgb_model.pkl): `models/xgb_model.pkl`
- [Cluster Model](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/kmeans_model.pkl): `models/kmeans_model.pkl`
- [Feature Scalers](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/scaler.pkl): `models/scaler.pkl`
- [Cluster Scaler](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/scaler_cluster.pkl): `models/scaler_cluster.pkl`
- [Segment Names](https://github.com/mohamednihmath18/diamond-dynamics/blob/main/models/cluster_names.pkl): `models/cluster_names.pkl`

### Other components

- **Analyst**
- **App User**

## Connections

- Raw Diamonds → Preprocessing: cleans (evidence: `README.md`)
- Preprocessing → Clean Data: produces (evidence: `README.md`)
- Clean Data → Exploratory Analysis: analyzes (evidence: `README.md`)
- Exploratory Analysis → Feature Engineering: informs (evidence: `README.md`)
- Feature Engineering → Engineered Data: produces (evidence: `README.md`)
- Engineered Data → Regression Models: trains (evidence: `README.md`)
- Engineered Data → ANN Model: trains (evidence: `README.md`)
- Engineered Data → K-Means Segmentation: clusters (evidence: `README.md`)
- K-Means Segmentation → Segmented Data: labels (evidence: `README.md`)
- App User → Streamlit Application: uses (evidence: `README.md`)
- Streamlit Application → Price Prediction: shows (evidence: `app/app.py`)
- Streamlit Application → Segment Prediction: shows (evidence: `app/app.py`)
- Streamlit Application → Visual Insights: shows (evidence: `app/app.py`)
- Price Prediction → Feature Scalers: transforms input (evidence: `app/app.py`)
- Price Prediction → Price Model: predicts price (evidence: `app/app.py`)
- Segment Prediction → Cluster Scaler: transforms input (evidence: `app/app.py`)
- Segment Prediction → Cluster Model: predicts cluster (evidence: `app/app.py`)
- Segment Prediction → Segment Names: names cluster (evidence: `app/app.py`)
- Visual Insights → Segmented Data: reads summaries (evidence: `app/app.py`)
