# snehranjan/custome-retention-intelligence-system architecture

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

- Interactive diagram: https://gitdiagram.com/snehranjan/custome-retention-intelligence-system
- Repository: https://github.com/snehranjan/custome-retention-intelligence-system

## Overview

RetainIQ is an Indian e-commerce customer-retention intelligence product: employee-facing web portals use a FastAPI service to inspect customers, churn predictions, segments, analytics, and retention actions. The intended domain flow spans customer data preparation and feature engineering, churn modeling and segmentation, serving results through the API, persistence, and employee exploration. The README documents these capabilities, while the excerpts directly verify app routing, API setup, auth state, and repository selection/storage. Several backend route-to-service links and unsampled ML runtime details are therefore left unasserted or marked unverified.

Main entry points: [`frontend/src/App.jsx`](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/App.jsx) (Web app routing), [`backend/app/main.py`](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/routes/api.py`](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/routes/api.py) (API route registry), [`backend/app/repositories/__init__.py`](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/__init__.py) (Repository selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web app routing<br/>[App.jsx]"]
  node_employee_login["Employee login"]
  node_dashboard["Employee dashboard"]
  node_admin_portal["Admin portal"]
  node_auth_state["Auth session state<br/>[AuthContext.jsx]"]
  node_api_client["REST API client<br/>[apiClient.js]"]
end

subgraph group_api["API and operations"]
  node_backend_app["FastAPI application<br/>[main.py]"]
  node_api_routes["API route registry<br/>[api.py]"]
  node_customer_routes["Customer and analytics routes"]
  node_auth_routes["Auth and employee routes"]
  node_ml_routes["ML and recommendations routes"]
  node_employee_service["Employee registration service"]
end

subgraph group_intelligence["Customer intelligence"]
  node_ml_boundary["ML runtime boundary<br/>[ml_boundary.py]"]
  node_model_loader["Model loading<br/>[model_loader.py]"]
  node_features["Feature engineering"]
  node_advanced_features["Advanced features"]
  node_training["Churn model training<br/>[train_models.py]"]
  node_segmentation["Customer segmentation"]
  node_retention["Retention recommendations"]
end

subgraph group_persistence["Persistence and identity"]
  node_repository_factory["Repository selector<br/>[__init__.py]"]
  node_repository_contract["Repository contract<br/>[base_repository.py]"]
  node_sqlite[("SQLite storage")]
  node_supabase_repo[("Supabase storage")]
  node_supabase_auth["Supabase Auth<br/>[supabase.js]"]
end

node_employee(("Employee"))
node_admin(("Administrator"))

node_employee -->|"uses portal"| node_webapp
node_admin -->|"uses portal"| node_webapp
node_webapp -->|"routes to"| node_employee_login
node_webapp -->|"routes to"| node_dashboard
node_webapp -->|"routes to"| node_admin_portal
node_employee_login -.->|"uses session"| node_auth_state
node_dashboard -.->|"requests data"| node_api_client
node_admin_portal -->|"requests data"| node_api_client
node_auth_state -->|"reads session"| node_supabase_auth
node_api_client -->|"HTTP requests"| node_backend_app
node_backend_app -->|"registers routes"| node_api_routes
node_api_routes -->|"includes routes"| node_customer_routes
node_api_routes -->|"includes routes"| node_auth_routes
node_api_routes -->|"includes routes"| node_ml_routes
node_auth_routes -.->|"delegates registration"| node_employee_service
node_backend_app -->|"sets up runtime"| node_ml_boundary
node_backend_app -.->|"loads models"| node_model_loader
node_features -.->|"prepares features"| node_training
node_advanced_features -.->|"feeds modeling"| node_training
node_training -.->|"serves predictions"| node_ml_boundary
node_segmentation -.->|"provides segments"| node_ml_boundary
node_ml_routes -.->|"requests strategies"| node_retention
node_customer_routes -.->|"reads customer data"| node_repository_factory
node_repository_factory -->|"selects SQLite"| node_sqlite
node_repository_factory -->|"selects Supabase"| node_supabase_repo
node_sqlite -->|"implements contract"| node_repository_contract
node_supabase_repo -->|"implements contract"| node_repository_contract
node_employee_service -.->|"creates auth identity"| node_supabase_auth

click node_webapp "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/App.jsx"
click node_employee_login "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/EmployeeLoginPage.jsx"
click node_dashboard "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/EmployeeDashboardPage.jsx"
click node_admin_portal "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/AdminPortalPage.jsx"
click node_auth_state "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/lib/apiClient.js"
click node_backend_app "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/routes/api.py"
click node_customer_routes "https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes"
click node_auth_routes "https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes"
click node_ml_routes "https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes"
click node_employee_service "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/employee_service.py"
click node_ml_boundary "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/ml_boundary.py"
click node_model_loader "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/model_loader.py"
click node_features "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/feature_engineering.py"
click node_advanced_features "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/advanced_feature_engineering.py"
click node_training "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/train_models.py"
click node_segmentation "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/customer_segmentation.py"
click node_retention "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/retention_service.py"
click node_repository_factory "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/__init__.py"
click node_repository_contract "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/base_repository.py"
click node_sqlite "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/sqlite_repository.py"
click node_supabase_repo "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/supabase_repository.py"
click node_supabase_auth "https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/lib/supabase.js"

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_webapp,node_employee_login,node_dashboard,node_admin_portal,node_auth_state,node_api_client toneBlue
class node_backend_app,node_api_routes,node_customer_routes,node_auth_routes,node_ml_routes,node_employee_service toneAmber
class node_ml_boundary,node_model_loader,node_features,node_advanced_features,node_training,node_segmentation,node_retention toneMint
class node_repository_factory,node_repository_contract,node_sqlite,node_supabase_repo,node_supabase_auth toneRose
class node_employee,node_admin toneIndigo
```

## Components

### Web experience

- [Web app routing](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Employee login](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/EmployeeLoginPage.jsx): `frontend/src/pages/EmployeeLoginPage.jsx`
- [Employee dashboard](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/EmployeeDashboardPage.jsx): `frontend/src/pages/EmployeeDashboardPage.jsx`
- [Admin portal](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/pages/AdminPortalPage.jsx): `frontend/src/pages/AdminPortalPage.jsx`
- [Auth session state](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [REST API client](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/lib/apiClient.js): `frontend/src/lib/apiClient.js`

### API and operations

- [FastAPI application](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/main.py): `backend/app/main.py`
- [API route registry](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/routes/api.py): `backend/app/routes/api.py`
- [Customer and analytics routes](https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes): `backend/app/routes`
- [Auth and employee routes](https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes): `backend/app/routes`
- [ML and recommendations routes](https://github.com/snehranjan/custome-retention-intelligence-system/tree/main/backend/app/routes): `backend/app/routes`
- [Employee registration service](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/employee_service.py): `backend/app/services/employee_service.py`

### Customer intelligence

- [ML runtime boundary](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/ml_boundary.py): `backend/app/services/ml_boundary.py`
- [Model loading](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/model_loader.py): `backend/app/services/model_loader.py`
- [Feature engineering](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/feature_engineering.py): `backend/ml/feature_engineering.py`
- [Advanced features](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/advanced_feature_engineering.py): `backend/ml/advanced_feature_engineering.py`
- [Churn model training](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/train_models.py): `backend/ml/train_models.py`
- [Customer segmentation](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/ml/customer_segmentation.py): `backend/ml/customer_segmentation.py`
- [Retention recommendations](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/services/retention_service.py): `backend/app/services/retention_service.py`

### Persistence and identity

- [Repository selector](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/__init__.py): `backend/app/repositories/__init__.py`
- [Repository contract](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/base_repository.py): `backend/app/repositories/base_repository.py`
- [SQLite storage](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/sqlite_repository.py): `backend/app/repositories/sqlite_repository.py`
- [Supabase storage](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/backend/app/repositories/supabase_repository.py): `backend/app/repositories/supabase_repository.py`
- [Supabase Auth](https://github.com/snehranjan/custome-retention-intelligence-system/blob/main/frontend/src/lib/supabase.js): `frontend/src/lib/supabase.js`

### Other components

- **Employee**
- **Administrator**

## Connections

- Employee → Web app routing: uses portal (evidence: `frontend/src/App.jsx`)
- Administrator → Web app routing: uses portal (evidence: `frontend/src/App.jsx`)
- Web app routing → Employee login: routes to (evidence: `frontend/src/App.jsx`)
- Web app routing → Employee dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Web app routing → Admin portal: routes to (evidence: `frontend/src/App.jsx`)
- Employee login → Auth session state: uses session
- Employee dashboard → REST API client: requests data
- Admin portal → REST API client: requests data (evidence: `frontend/src/pages/AdminPortalPage.jsx`)
- Auth session state → Supabase Auth: reads session (evidence: `frontend/src/context/AuthContext.jsx`)
- REST API client → FastAPI application: HTTP requests
- FastAPI application → API route registry: registers routes (evidence: `backend/app/main.py`)
- API route registry → Customer and analytics routes: includes routes (evidence: `backend/app/routes/api.py`)
- API route registry → Auth and employee routes: includes routes (evidence: `backend/app/routes/api.py`)
- API route registry → ML and recommendations routes: includes routes (evidence: `backend/app/routes/api.py`)
- Auth and employee routes → Employee registration service: delegates registration
- FastAPI application → ML runtime boundary: sets up runtime (evidence: `backend/app/main.py`)
- FastAPI application → Model loading: loads models (evidence: `backend/app/main.py`)
- Feature engineering → Churn model training: prepares features
- Advanced features → Churn model training: feeds modeling
- Churn model training → ML runtime boundary: serves predictions
- Customer segmentation → ML runtime boundary: provides segments
- ML and recommendations routes → Retention recommendations: requests strategies
- Customer and analytics routes → Repository selector: reads customer data (evidence: `backend/app/routes/database.py`)
- Repository selector → SQLite storage: selects SQLite (evidence: `backend/app/repositories/__init__.py`)
- Repository selector → Supabase storage: selects Supabase (evidence: `backend/app/repositories/__init__.py`)
- SQLite storage → Repository contract: implements contract (evidence: `backend/app/repositories/sqlite_repository.py`)
- Supabase storage → Repository contract: implements contract (evidence: `backend/app/repositories/supabase_repository.py`)
- Employee registration service → Supabase Auth: creates auth identity
