# nourshili-debug/creditrisk architecture

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

- Interactive diagram: https://gitdiagram.com/nourshili-debug/creditrisk
- Repository: https://github.com/nourshili-debug/creditrisk

## Overview

This is a credit-risk platform spanning simulated event ingestion, data processing and storage, model development and evaluation, prediction serving, an interactive dashboard, and an AI assistant. The documented primary user workflow is dashboard/API access to application and model information, with predictions and explanations served by the API; dashboard chat uses the LangGraph agent. Several pipeline and model relationships are documented in the README but their runtime wiring was not sampled, so those edges cite the README and avoid implying more specific calls.

Main entry points: [`src/api/main.py`](https://github.com/nourshili-debug/creditrisk/blob/main/src/api/main.py) (FastAPI service), [`src/lambda_processing/handler.py`](https://github.com/nourshili-debug/creditrisk/blob/main/src/lambda_processing/handler.py) (Cloud processing), [`src/processing/preprocessing.py`](https://github.com/nourshili-debug/creditrisk/blob/main/src/processing/preprocessing.py) (Training preprocessing), [`src/api/service.py`](https://github.com/nourshili-debug/creditrisk/blob/main/src/api/service.py) (Prediction service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Data pipeline"]
  node_applicant_data[("Home Credit data")]
  node_kafka["Kafka replay<br/>[kafka_producer.py]"]
  node_event_validation["Event validation<br/>[event_validator.py]"]
  node_kafka_consumer["Kafka consumer<br/>[kafka_consumer.py]"]
  node_lambda_processing["Cloud processing<br/>[handler.py]"]
  node_processing["Data processing"]
  node_local_storage[("Local event storage<br/>[local_storage.py]")]
  node_s3_storage[("S3 storage<br/>[s3_storage.py]")]
end

subgraph group_models["Modeling and explainability"]
  node_preprocessing["Training preprocessing<br/>[preprocessing.py]"]
  node_xgboost["XGBoost training<br/>[train_xgboost.py]"]
  node_lstm["LSTM training<br/>[train_lstm.py]"]
  node_evaluation["Model evaluation"]
  node_explainability["SHAP explanations<br/>[shap_explainer.py]"]
end

subgraph group_serving["Prediction API"]
  node_api["FastAPI service<br/>[main.py]"]
  node_application_repository[("Application repository<br/>[repository.py]")]
  node_prediction_service["Prediction service<br/>[service.py]"]
  node_predictor["Risk predictor<br/>[predictor.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_app["Streamlit dashboard<br/>[app.py]"]
  node_dashboard_pages["Dashboard views"]
  node_dashboard_data["Dashboard data access<br/>[data_access.py]"]
end

subgraph group_assistant["AI assistant"]
  node_agent["LangGraph agent<br/>[graph.py]"]
  node_agent_tools["Project data tools<br/>[tools.py]"]
  node_reports["Analytical reports"]
end

node_api_user(("Dashboard user"))
node_llm["LLM provider"]

node_applicant_data -->|"replays records"| node_kafka
node_kafka -->|"sends events"| node_event_validation
node_event_validation -.->|"validates events"| node_kafka_consumer
node_kafka_consumer -.->|"dispatches events"| node_lambda_processing
node_lambda_processing -->|"validates payloads"| node_event_validation
node_lambda_processing -.->|"stores events"| node_local_storage
node_processing -->|"stores processed data"| node_s3_storage
node_applicant_data -->|"provides training data"| node_preprocessing
node_preprocessing -->|"prepares features"| node_xgboost
node_preprocessing -->|"prepares sequences"| node_lstm
node_xgboost -->|"evaluates model"| node_evaluation
node_lstm -->|"compares model"| node_evaluation
node_evaluation -.->|"publishes model results"| node_api
node_api_user -->|"uses dashboard"| node_dashboard_app
node_dashboard_app -->|"routes pages"| node_dashboard_pages
node_dashboard_pages -->|"requests data"| node_dashboard_data
node_dashboard_data -->|"calls API"| node_api
node_api -->|"routes predictions"| node_prediction_service
node_prediction_service -->|"loads application"| node_application_repository
node_prediction_service -->|"generates prediction"| node_predictor
node_api -->|"serves application data"| node_application_repository
node_predictor -->|"requests explanations"| node_explainability
node_dashboard_pages -->|"offers assistant"| node_agent
node_agent -->|"dispatches tools"| node_agent_tools
node_agent_tools -->|"retrieves dashboard data"| node_dashboard_data
node_agent_tools -->|"generates reports"| node_reports
node_agent -->|"invokes provider"| node_llm

click node_kafka "https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/kafka_producer.py"
click node_event_validation "https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/event_validator.py"
click node_kafka_consumer "https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/kafka_consumer.py"
click node_lambda_processing "https://github.com/nourshili-debug/creditrisk/blob/main/src/lambda_processing/handler.py"
click node_processing "https://github.com/nourshili-debug/creditrisk/tree/main/src/processing"
click node_local_storage "https://github.com/nourshili-debug/creditrisk/blob/main/src/storage/local_storage.py"
click node_s3_storage "https://github.com/nourshili-debug/creditrisk/blob/main/src/storage/s3_storage.py"
click node_preprocessing "https://github.com/nourshili-debug/creditrisk/blob/main/src/processing/preprocessing.py"
click node_xgboost "https://github.com/nourshili-debug/creditrisk/blob/main/src/training/train_xgboost.py"
click node_lstm "https://github.com/nourshili-debug/creditrisk/blob/main/src/training/train_lstm.py"
click node_evaluation "https://github.com/nourshili-debug/creditrisk/tree/main/src/evaluation"
click node_explainability "https://github.com/nourshili-debug/creditrisk/blob/main/src/explainability/shap_explainer.py"
click node_api "https://github.com/nourshili-debug/creditrisk/blob/main/src/api/main.py"
click node_application_repository "https://github.com/nourshili-debug/creditrisk/blob/main/src/api/repository.py"
click node_prediction_service "https://github.com/nourshili-debug/creditrisk/blob/main/src/api/service.py"
click node_predictor "https://github.com/nourshili-debug/creditrisk/blob/main/src/inference/predictor.py"
click node_dashboard_app "https://github.com/nourshili-debug/creditrisk/blob/main/src/dashboard/app.py"
click node_dashboard_pages "https://github.com/nourshili-debug/creditrisk/tree/main/src/dashboard/pages"
click node_dashboard_data "https://github.com/nourshili-debug/creditrisk/blob/main/src/dashboard/data_access.py"
click node_agent "https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/graph.py"
click node_agent_tools "https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/tools.py"
click node_reports "https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/report_generator.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_applicant_data,node_kafka,node_event_validation,node_kafka_consumer,node_lambda_processing,node_processing,node_local_storage,node_s3_storage,node_api_user toneBlue
class node_preprocessing,node_xgboost,node_lstm,node_evaluation,node_explainability toneAmber
class node_api,node_application_repository,node_prediction_service,node_predictor toneMint
class node_dashboard_app,node_dashboard_pages,node_dashboard_data toneRose
class node_agent,node_agent_tools,node_reports,node_llm toneIndigo
```

## Components

### Data pipeline

- **Home Credit data**
- [Kafka replay](https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/kafka_producer.py): `src/ingestion/kafka_producer.py`
- [Event validation](https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/event_validator.py): `src/ingestion/event_validator.py`
- [Kafka consumer](https://github.com/nourshili-debug/creditrisk/blob/main/src/ingestion/kafka_consumer.py): `src/ingestion/kafka_consumer.py`
- [Cloud processing](https://github.com/nourshili-debug/creditrisk/blob/main/src/lambda_processing/handler.py): `src/lambda_processing/handler.py`
- [Data processing](https://github.com/nourshili-debug/creditrisk/tree/main/src/processing): `src/processing`
- [Local event storage](https://github.com/nourshili-debug/creditrisk/blob/main/src/storage/local_storage.py): `src/storage/local_storage.py`
- [S3 storage](https://github.com/nourshili-debug/creditrisk/blob/main/src/storage/s3_storage.py): `src/storage/s3_storage.py`

### Modeling and explainability

- [Training preprocessing](https://github.com/nourshili-debug/creditrisk/blob/main/src/processing/preprocessing.py): `src/processing/preprocessing.py`
- [XGBoost training](https://github.com/nourshili-debug/creditrisk/blob/main/src/training/train_xgboost.py): `src/training/train_xgboost.py`
- [LSTM training](https://github.com/nourshili-debug/creditrisk/blob/main/src/training/train_lstm.py): `src/training/train_lstm.py`
- [Model evaluation](https://github.com/nourshili-debug/creditrisk/tree/main/src/evaluation): `src/evaluation`
- [SHAP explanations](https://github.com/nourshili-debug/creditrisk/blob/main/src/explainability/shap_explainer.py): `src/explainability/shap_explainer.py`

### Prediction API

- [FastAPI service](https://github.com/nourshili-debug/creditrisk/blob/main/src/api/main.py): `src/api/main.py`
- [Application repository](https://github.com/nourshili-debug/creditrisk/blob/main/src/api/repository.py): `src/api/repository.py`
- [Prediction service](https://github.com/nourshili-debug/creditrisk/blob/main/src/api/service.py): `src/api/service.py`
- [Risk predictor](https://github.com/nourshili-debug/creditrisk/blob/main/src/inference/predictor.py): `src/inference/predictor.py`

### Dashboard

- [Streamlit dashboard](https://github.com/nourshili-debug/creditrisk/blob/main/src/dashboard/app.py): `src/dashboard/app.py`
- [Dashboard views](https://github.com/nourshili-debug/creditrisk/tree/main/src/dashboard/pages): `src/dashboard/pages`
- [Dashboard data access](https://github.com/nourshili-debug/creditrisk/blob/main/src/dashboard/data_access.py): `src/dashboard/data_access.py`

### AI assistant

- [LangGraph agent](https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/graph.py): `src/agent/graph.py`
- [Project data tools](https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/tools.py): `src/agent/tools.py`
- [Analytical reports](https://github.com/nourshili-debug/creditrisk/blob/main/src/agent/report_generator.py): `src/agent/report_generator.py`

### Other components

- **Dashboard user**
- **LLM provider**

## Connections

- Home Credit data → Kafka replay: replays records (evidence: `README.md`)
- Kafka replay → Event validation: sends events (evidence: `README.md`)
- Event validation → Kafka consumer: validates events
- Kafka consumer → Cloud processing: dispatches events
- Cloud processing → Event validation: validates payloads (evidence: `src/lambda_processing/handler.py`)
- Cloud processing → Local event storage: stores events
- Data processing → S3 storage: stores processed data (evidence: `README.md`)
- Home Credit data → Training preprocessing: provides training data (evidence: `README.md`)
- Training preprocessing → XGBoost training: prepares features (evidence: `src/training/train_xgboost.py`)
- Training preprocessing → LSTM training: prepares sequences (evidence: `README.md`)
- XGBoost training → Model evaluation: evaluates model (evidence: `README.md`)
- LSTM training → Model evaluation: compares model (evidence: `README.md`)
- Model evaluation → FastAPI service: publishes model results
- Dashboard user → Streamlit dashboard: uses dashboard (evidence: `README.md`)
- Streamlit dashboard → Dashboard views: routes pages (evidence: `src/dashboard/app.py`)
- Dashboard views → Dashboard data access: requests data (evidence: `src/dashboard/pages/application_explorer.py`)
- Dashboard data access → FastAPI service: calls API (evidence: `src/dashboard/data_access.py`)
- FastAPI service → Prediction service: routes predictions
- Prediction service → Application repository: loads application (evidence: `src/api/service.py`)
- Prediction service → Risk predictor: generates prediction (evidence: `src/api/service.py`)
- FastAPI service → Application repository: serves application data
- Risk predictor → SHAP explanations: requests explanations (evidence: `src/inference/predictor.py`)
- Dashboard views → LangGraph agent: offers assistant (evidence: `README.md`)
- LangGraph agent → Project data tools: dispatches tools (evidence: `src/agent/graph.py`)
- Project data tools → Dashboard data access: retrieves dashboard data (evidence: `src/agent/tools.py`)
- Project data tools → Analytical reports: generates reports (evidence: `src/agent/tools.py`)
- LangGraph agent → LLM provider: invokes provider (evidence: `README.md`)
