# rojasantino/explainable_ai architecture

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

- Interactive diagram: https://gitdiagram.com/rojasantino/explainable_ai
- Repository: https://github.com/rojasantino/explainable_ai

## Overview

This repository implements an explainable customer-analytics product: users view dashboard metrics or look up an individual customer, while a Flask API serves predictions, segments, recommendations, explanations, profiles, and product data. Its Angular frontend calls the API for dashboard statistics and customer profiles. The ML directory and SHAP explainer provide distinct pipeline stages, but their runtime ordering and data handoffs are not established by the excerpts; those stages are shown without invented connections.

Main entry points: [`api/app.py`](https://github.com/rojasantino/explainable_ai/blob/main/api/app.py) (Flask API), [`customer-ai-frontend/src/app/app.routes.ts`](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/app.routes.ts) (Page routes), [`customer-ai-frontend/src/app/dashboard/dashboard.component.ts`](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/dashboard/dashboard.component.ts) (Dashboard view), [`customer-ai-frontend/src/app/personalization/personalization.component.ts`](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/personalization/personalization.component.ts) (Customer profile view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Customer interface"]
  node_dashboard["Dashboard view"]
  node_personalization["Customer profile view"]
  node_api_service["API client<br/>[api.service.ts]"]
  node_routes["Page routes<br/>[app.routes.ts]"]
  node_app_shell["Application shell<br/>[app.ts]"]
end

subgraph group_backend["Analytics API"]
  node_api["Flask API<br/>[app.py]"]
end

subgraph group_ml["ML pipeline"]
  node_recommendation["Collaborative filtering<br/>[models_classes.py]"]
  node_cleaning["Data cleaning"]
  node_features["Feature engineering"]
  node_segmentation["Customer segmentation"]
  node_prediction["Purchase prediction"]
  node_recs_pipeline["Recommendation pipeline"]
  node_shap["SHAP explanations"]
end

subgraph group_assets["Data and models"]
  node_datasets[("Customer datasets")]
  node_model_artifacts[("Serialized models")]
end

node_customer(("Customer"))

node_customer -->|"views"| node_dashboard
node_customer -->|"looks up"| node_personalization
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_personalization
node_app_shell -.->|"hosts outlet"| node_routes
node_app_shell -->|"shows navbar"| node_customer
node_dashboard -->|"requests stats"| node_api_service
node_personalization -->|"requests profile"| node_api_service
node_api_service -.->|"calls API"| node_api
node_api -->|"calls recommend"| node_recommendation
node_api -->|"loads and reads"| node_datasets
node_api -->|"loads models"| node_model_artifacts

click node_dashboard "https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/dashboard/dashboard.component.ts"
click node_personalization "https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/personalization/personalization.component.ts"
click node_api_service "https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/services/api.service.ts"
click node_routes "https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/app.routes.ts"
click node_app_shell "https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/app.ts"
click node_api "https://github.com/rojasantino/explainable_ai/blob/main/api/app.py"
click node_recommendation "https://github.com/rojasantino/explainable_ai/blob/main/ml/models_classes.py"
click node_cleaning "https://github.com/rojasantino/explainable_ai/blob/main/ml/phase02_data_cleaning.py"
click node_features "https://github.com/rojasantino/explainable_ai/blob/main/ml/phase03_feature_engineering.py"
click node_segmentation "https://github.com/rojasantino/explainable_ai/blob/main/ml/phase04_segmentation.py"
click node_prediction "https://github.com/rojasantino/explainable_ai/blob/main/ml/phase05_prediction.py"
click node_recs_pipeline "https://github.com/rojasantino/explainable_ai/blob/main/ml/phase06_recommendation.py"
click node_shap "https://github.com/rojasantino/explainable_ai/blob/main/explain/phase07_shap_explain.py"
click node_datasets "https://github.com/rojasantino/explainable_ai/tree/main/data"
click node_model_artifacts "https://github.com/rojasantino/explainable_ai/tree/main/models"

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_dashboard,node_personalization,node_api_service,node_routes,node_app_shell toneBlue
class node_api toneAmber
class node_recommendation,node_cleaning,node_features,node_segmentation,node_prediction,node_recs_pipeline,node_shap toneMint
class node_datasets,node_model_artifacts toneRose
class node_customer toneIndigo
```

## Components

### Customer interface

- [Dashboard view](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/dashboard/dashboard.component.ts): `customer-ai-frontend/src/app/dashboard/dashboard.component.ts`
- [Customer profile view](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/personalization/personalization.component.ts): `customer-ai-frontend/src/app/personalization/personalization.component.ts`
- [API client](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/services/api.service.ts): `customer-ai-frontend/src/app/services/api.service.ts`
- [Page routes](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/app.routes.ts): `customer-ai-frontend/src/app/app.routes.ts`
- [Application shell](https://github.com/rojasantino/explainable_ai/blob/main/customer-ai-frontend/src/app/app.ts): `customer-ai-frontend/src/app/app.ts`

### Analytics API

- [Flask API](https://github.com/rojasantino/explainable_ai/blob/main/api/app.py): `api/app.py`

### ML pipeline

- [Collaborative filtering](https://github.com/rojasantino/explainable_ai/blob/main/ml/models_classes.py): `ml/models_classes.py`
- [Data cleaning](https://github.com/rojasantino/explainable_ai/blob/main/ml/phase02_data_cleaning.py): `ml/phase02_data_cleaning.py`
- [Feature engineering](https://github.com/rojasantino/explainable_ai/blob/main/ml/phase03_feature_engineering.py): `ml/phase03_feature_engineering.py`
- [Customer segmentation](https://github.com/rojasantino/explainable_ai/blob/main/ml/phase04_segmentation.py): `ml/phase04_segmentation.py`
- [Purchase prediction](https://github.com/rojasantino/explainable_ai/blob/main/ml/phase05_prediction.py): `ml/phase05_prediction.py`
- [Recommendation pipeline](https://github.com/rojasantino/explainable_ai/blob/main/ml/phase06_recommendation.py): `ml/phase06_recommendation.py`
- [SHAP explanations](https://github.com/rojasantino/explainable_ai/blob/main/explain/phase07_shap_explain.py): `explain/phase07_shap_explain.py`

### Data and models

- [Customer datasets](https://github.com/rojasantino/explainable_ai/tree/main/data): `data`
- [Serialized models](https://github.com/rojasantino/explainable_ai/tree/main/models): `models`

### Other components

- **Customer**

## Connections

- Customer → Dashboard view: views
- Customer → Customer profile view: looks up
- Page routes → Dashboard view: routes to (evidence: `customer-ai-frontend/src/app/app.routes.ts`)
- Page routes → Customer profile view: routes to (evidence: `customer-ai-frontend/src/app/app.routes.ts`)
- Application shell → Page routes: hosts outlet
- Application shell → Customer: shows navbar (evidence: `customer-ai-frontend/src/app/app.ts`)
- Dashboard view → API client: requests stats (evidence: `customer-ai-frontend/src/app/dashboard/dashboard.component.ts`)
- Customer profile view → API client: requests profile (evidence: `customer-ai-frontend/src/app/personalization/personalization.component.ts`)
- API client → Flask API: calls API
- Flask API → Collaborative filtering: calls recommend (evidence: `api/app.py`)
- Flask API → Customer datasets: loads and reads (evidence: `api/app.py`)
- Flask API → Serialized models: loads models (evidence: `api/app.py`)
