# imposterbharathkumarburugu15-cpu/credit-risk architecture

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

- Interactive diagram: https://gitdiagram.com/imposterbharathkumarburugu15-cpu/credit-risk
- Repository: https://github.com/imposterbharathkumarburugu15-cpu/credit-risk

## Overview

CreditRisk-X is a credit-default risk platform with a dashboard and FastAPI service. The main workflow takes customer data through validation and feature engineering, model scoring, and a threshold-based decision, then presents risk and cost analysis. The API also exposes model comparison, threshold optimization, explainability, analytics, and chatbot features; authenticated application workflows support customer accounts, application updates, and email notifications. The tree and README establish both backend variants, but sampled evidence is concentrated in `backend/`; relationships for unsampled capabilities are limited to documented or indexed references.

Main entry points: [`backend/routes.py`](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/routes.py) (FastAPI routes), [`backend/database.py`](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/database.py) (Persistence layer), [`backend/model.py`](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/model.py) (Model artifacts), [`backend/prediction.py`](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/prediction.py) (Input and scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Dashboard and API"]
  node_dashboard["Risk dashboard<br/>[app.js]"]
  node_api["FastAPI routes<br/>[routes.py]"]
  node_app["API application<br/>[main.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_risk["Risk Scoring"]
  node_features["Feature engineering<br/>[features.py]"]
  node_prediction["Input and scoring<br/>[prediction.py]"]
  node_models["Model artifacts<br/>[model.py]"]
  node_decision["Risk decision<br/>[decision.py]"]
  node_training["Model training<br/>[train.py]"]
end

subgraph group_analysis["Cost and Insights"]
  node_service["Scoring analysis<br/>[service.py]"]
  node_costs["Cost evaluation<br/>[costs.py]"]
  node_cost["Policy cost comparison<br/>[cost.py]"]
  node_optimization["Threshold optimization<br/>[optimization.py]"]
  node_analytics["Risk analytics<br/>[analytics.py]"]
  node_explain["Decision explanations<br/>[explainability.py]"]
  node_chatbot["FAQ chatbot<br/>[chatbot.py]"]
end

subgraph group_operations["Application Operations"]
  node_workflows["Customer workflows<br/>[workflows.py]"]
  node_database[("Persistence layer<br/>[database.py]")]
  node_email["Email notifications<br/>[email_service.py]"]
end

node_user(("Credit analyst"))
node_mysql[("MySQL")]
node_smtp["SMTP service"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests analysis"| node_api
node_app -->|"mounts routes"| node_api
node_app -->|"loads artifacts"| node_models
node_app -->|"initializes connection"| node_database
node_api -->|"scores customers"| node_prediction
node_api -->|"classifies risk"| node_decision
node_api -->|"serves analysis"| node_service
node_api -->|"compares policy costs"| node_cost
node_api -->|"optimizes thresholds"| node_optimization
node_api -->|"serves analytics"| node_analytics
node_api -->|"serves chatbot"| node_chatbot
node_api -->|"serves explanations"| node_explain
node_api -->|"routes workflows"| node_workflows
node_prediction -->|"builds features"| node_features
node_prediction -->|"uses model"| node_models
node_service -->|"engineers inputs"| node_features
node_service -->|"evaluates thresholds"| node_costs
node_optimization -->|"uses model"| node_models
node_optimization -->|"evaluates costs"| node_costs
node_analytics -->|"reads model data"| node_models
node_explain -->|"uses model"| node_models
node_explain -->|"uses predictions"| node_prediction
node_training -->|"engineers training data"| node_features
node_training -->|"evaluates models"| node_costs
node_workflows -->|"reads and writes"| node_database
node_workflows -->|"sends notifications"| node_email
node_email -.->|"logs delivery"| node_database
node_database -->|"persists records"| node_mysql
node_email -.->|"delivers email"| node_smtp
node_config -.->|"configures connection"| node_database

click node_dashboard "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/frontend/app.js"
click node_api "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/routes.py"
click node_app "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/main.py"
click node_config "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/config.py"
click node_features "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/features.py"
click node_prediction "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/prediction.py"
click node_models "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/model.py"
click node_decision "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/decision.py"
click node_training "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/train.py"
click node_service "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/service.py"
click node_costs "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/costs.py"
click node_cost "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/cost.py"
click node_optimization "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/optimization.py"
click node_analytics "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/analytics.py"
click node_explain "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/explainability.py"
click node_chatbot "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/chatbot.py"
click node_workflows "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/workflows.py"
click node_database "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/database.py"
click node_email "https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/email_service.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_dashboard,node_api,node_app,node_config toneBlue
class node_features,node_prediction,node_models,node_decision,node_training,node_mysql toneAmber
class node_service,node_costs,node_cost,node_optimization,node_analytics,node_explain,node_chatbot toneMint
class node_workflows,node_database,node_email toneRose
class node_user,node_smtp toneIndigo
```

## Components

### Dashboard and API

- [Risk dashboard](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/frontend/app.js): `frontend/app.js`
- [FastAPI routes](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/routes.py): `backend/routes.py`
- [API application](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/main.py): `backend/main.py`
- [Runtime configuration](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/config.py): `backend/config.py`

### Risk Scoring

- [Feature engineering](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/features.py): `backend/features.py`
- [Input and scoring](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/prediction.py): `backend/prediction.py`
- [Model artifacts](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/model.py): `backend/model.py`
- [Risk decision](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/decision.py): `backend/decision.py`
- [Model training](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/train.py): `backend/train.py`

### Cost and Insights

- [Scoring analysis](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/service.py): `backend/service.py`
- [Cost evaluation](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/costs.py): `backend/costs.py`
- [Policy cost comparison](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/cost.py): `backend/cost.py`
- [Threshold optimization](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/optimization.py): `backend/optimization.py`
- [Risk analytics](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/analytics.py): `backend/analytics.py`
- [Decision explanations](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/explainability.py): `backend/explainability.py`
- [FAQ chatbot](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/chatbot.py): `backend/chatbot.py`

### Application Operations

- [Customer workflows](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/workflows.py): `backend/workflows.py`
- [Persistence layer](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/database.py): `backend/database.py`
- [Email notifications](https://github.com/imposterbharathkumarburugu15-cpu/credit-risk/blob/main/backend/email_service.py): `backend/email_service.py`

### Other components

- **Credit analyst**
- **MySQL**
- **SMTP service**

## Connections

- Credit analyst → Risk dashboard: uses
- Risk dashboard → FastAPI routes: requests analysis
- API application → FastAPI routes: mounts routes (evidence: `backend/main.py`)
- API application → Model artifacts: loads artifacts (evidence: `backend/main.py`)
- API application → Persistence layer: initializes connection (evidence: `backend/main.py`)
- FastAPI routes → Input and scoring: scores customers (evidence: `backend/routes.py`)
- FastAPI routes → Risk decision: classifies risk (evidence: `backend/routes.py`)
- FastAPI routes → Scoring analysis: serves analysis (evidence: `backend/routes.py`)
- FastAPI routes → Policy cost comparison: compares policy costs (evidence: `backend/routes.py`)
- FastAPI routes → Threshold optimization: optimizes thresholds (evidence: `backend/routes.py`)
- FastAPI routes → Risk analytics: serves analytics (evidence: `backend/routes.py`)
- FastAPI routes → FAQ chatbot: serves chatbot (evidence: `backend/routes.py`)
- FastAPI routes → Decision explanations: serves explanations (evidence: `backend/routes.py`)
- FastAPI routes → Customer workflows: routes workflows (evidence: `backend/routes.py`)
- Input and scoring → Feature engineering: builds features (evidence: `backend/prediction.py`)
- Input and scoring → Model artifacts: uses model (evidence: `backend/prediction.py`)
- Scoring analysis → Feature engineering: engineers inputs (evidence: `backend/service.py`)
- Scoring analysis → Cost evaluation: evaluates thresholds (evidence: `backend/service.py`)
- Threshold optimization → Model artifacts: uses model (evidence: `backend/optimization.py`)
- Threshold optimization → Cost evaluation: evaluates costs (evidence: `backend/optimization.py`)
- Risk analytics → Model artifacts: reads model data (evidence: `backend/analytics.py`)
- Decision explanations → Model artifacts: uses model (evidence: `backend/explainability.py`)
- Decision explanations → Input and scoring: uses predictions (evidence: `backend/explainability.py`)
- Model training → Feature engineering: engineers training data (evidence: `backend/train.py`)
- Model training → Cost evaluation: evaluates models (evidence: `backend/train.py`)
- Customer workflows → Persistence layer: reads and writes (evidence: `backend/workflows.py`)
- Customer workflows → Email notifications: sends notifications (evidence: `backend/workflows.py`)
- Email notifications → Persistence layer: logs delivery
- Persistence layer → MySQL: persists records (evidence: `backend/database.py`)
- Email notifications → SMTP service: delivers email
- Runtime configuration → Persistence layer: configures connection (evidence: `backend/database.py`)
