# 21mohit-dotcom/ecommerce-return-risk-analyzer architecture

> Architecture diagram of the GitHub repository 21mohit-dotcom/ecommerce-return-risk-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/21mohit-dotcom/ecommerce-return-risk-analyzer
- Repository: https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer

## Overview

Customer Return Risk Analyzer combines an ML risk-scoring API with a planned analytics dashboard and MongoDB-backed application. The visible ML workflow cleans order data, simulates repeat-customer histories, aggregates customer features, trains a model, then serves scores and recommendations. The README also names React/Recharts, FastAPI, and MongoDB, but the backend and frontend directories contain no implementation files in the supplied tree; their integration and data flow therefore remain unverified.

Main entry points: [`backend`](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/backend) (Application backend), [`ml/src/predict.py`](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/predict.py) (Prediction API), [`frontend`](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/frontend) (Analytics dashboard), [`ml/models/return_risk_model.pkl`](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/models/return_risk_model.pkl) (Risk model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ml_workflow["ML workflow"]
  node_source_data["Order data"]
  node_cleaning["Data cleaning<br/>[preprocess.py]"]
  node_customer_simulation["Customer simulation"]
  node_feature_aggregation["Feature aggregation"]
  node_training["Model training<br/>[train.py]"]
  node_model_artifact["Risk model"]
end

subgraph group_serving["Risk serving"]
  node_risk_api["Prediction API<br/>[predict.py]"]
  node_risk_result["Risk result"]
end

subgraph group_product_app["Application capabilities"]
  node_dashboard["Analytics dashboard"]
  node_backend["Application backend"]
end

subgraph group_persistence["Persistence"]
  node_mongodb[("MongoDB")]
end

node_analyst(("Dashboard user"))

node_training -->|"saves model"| node_model_artifact
node_risk_api -->|"loads model"| node_model_artifact
node_risk_api -->|"returns score"| node_risk_result
node_analyst -.->|"views insights"| node_dashboard
node_dashboard -.->|"uses services"| node_backend
node_backend -.->|"stores data"| node_mongodb
node_backend -.->|"requests predictions"| node_risk_api

click node_cleaning "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/preprocess.py"
click node_customer_simulation "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/simulate_customers.py"
click node_feature_aggregation "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/aggregate_features.py"
click node_training "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/train.py"
click node_model_artifact "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/models/return_risk_model.pkl"
click node_risk_api "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/predict.py"
click node_dashboard "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/frontend"
click node_backend "https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/backend"

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_source_data,node_cleaning,node_customer_simulation,node_feature_aggregation,node_training,node_model_artifact,node_analyst toneBlue
class node_risk_api,node_risk_result toneAmber
class node_dashboard,node_backend toneMint
class node_mongodb toneRose
```

## Components

### ML workflow

- **Order data**
- [Data cleaning](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/preprocess.py): `ml/src/preprocess.py`
- [Customer simulation](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/simulate_customers.py): `ml/src/simulate_customers.py`
- [Feature aggregation](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/aggregate_features.py): `ml/src/aggregate_features.py`
- [Model training](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/train.py): `ml/src/train.py`
- [Risk model](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/models/return_risk_model.pkl): `ml/models/return_risk_model.pkl`

### Risk serving

- [Prediction API](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/blob/main/ml/src/predict.py): `ml/src/predict.py`
- **Risk result**

### Application capabilities

- [Analytics dashboard](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/frontend): `frontend`
- [Application backend](https://github.com/21mohit-dotcom/ecommerce-return-risk-analyzer/tree/main/backend): `backend`

### Persistence

- **MongoDB**

### Other components

- **Dashboard user**

## Connections

- Model training → Risk model: saves model (evidence: `ml/src/train.py`)
- Prediction API → Risk model: loads model (evidence: `ml/src/predict.py`)
- Prediction API → Risk result: returns score (evidence: `ml/src/predict.py`)
- Dashboard user → Analytics dashboard: views insights (evidence: `README.md`)
- Analytics dashboard → Application backend: uses services (evidence: `README.md`)
- Application backend → MongoDB: stores data (evidence: `README.md`)
- Application backend → Prediction API: requests predictions
