# mehulcode12/advance_credit_risk_model_loan_prediction architecture

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

- Interactive diagram: https://gitdiagram.com/mehulcode12/advance_credit_risk_model_loan_prediction
- Repository: https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction

## Overview

##### Project type and purpose
- This is a full-cycle credit-risk modeling application that trains an ML model on borrower/loan CSV data and then serves predictions via a Streamlit web UI.
- Key use case: ingest raw data → clean/engineer features → train & tune a logistic-regression model → serialize it → deploy as an interactive web app prioritizing recall for defaulters.

##### File structure
Top level:
- .devcontainer/… : development environment (VS Code + Docker)
- datasets/ : raw CSV data (bureau_data.csv, customers.csv, loans.csv)
- artifacts/ : serialized model artifact (model_data.joblib)
- main.py & prediction_helper.py : Streamlit app and inference logic
- requirements.txt : Python dependencies
- Untitled.ipynb : exploratory/training notebook
- images/ : screenshots & evaluation plots

Patterns & components:
– An offline “training pipeline” run in notebooks or scripts that reads from datasets/ → does EDA → feature engineering → Optuna tuning → saves model to artifacts/
– A “serving pipeline” in main.py + prediction_helper.py that loads model_data.joblib, accepts user inputs, applies same preprocessing, and runs inference in Streamlit.
– Devcontainer defines a reproducible environment for both training & serving.

##### README for additional insights
- Architecture described implicitly: data ingestion → preprocessing → modeling → deployment.
- Tech stack: Python, pandas, scikit-learn, imbalanced-learn (SMOTE-Tomek), Optuna, Streamlit, Docker/.devcontainer.
- Deployment target: Streamlit Cloud (external hosting service).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        Datasets["datasets/"]:::data
    end

    %% Training Pipeline
    subgraph "Training Pipeline"
        Notebook["Pipeline Notebook"]:::pipeline
        EDA["EDA & Preprocessing"]:::pipeline
        FE["Feature Engineering"]:::pipeline
        HT["Hyperparameter Tuning"]:::pipeline
        Eval["Evaluation & Metrics"]:::pipeline
        Serialize["Model Serialization"]:::pipeline
    end

    %% Model Artifact Storage
    subgraph "Model Artifact Storage"
        ModelArtifact["model_data.joblib"]:::storage
    end

    %% Serving Pipeline
    subgraph "Serving Pipeline"
        StreamlitApp["Streamlit App"]:::ui
        Helper["Inference Utility"]:::pipeline
    end

    %% Environment & Reproducibility
    subgraph "Environment"
        Devcontainer["devcontainer.json"]:::env
        Requirements["requirements.txt"]:::env
    end

    %% Assets & Evaluation Plots
    subgraph "Assets"
        Assets["images/"]:::storage
    end

    %% External Services
    Browser["User (Browser)"]:::external
    Cloud(("Streamlit Cloud")):::external
    Github(("GitHub (optional)")):::external

    %% Connections
    Datasets --> Notebook --> EDA --> FE --> HT --> Eval --> Serialize --> ModelArtifact
    Eval --> Assets
    ModelArtifact --> Helper --> StreamlitApp
    Browser <--> StreamlitApp
    Cloud --> StreamlitApp
    Devcontainer --> Notebook
    Devcontainer --> StreamlitApp
    Requirements --> Notebook
    Requirements --> StreamlitApp
    Github --> Devcontainer
    Github --> Notebook
    Github --> StreamlitApp

    %% Click Events
    click Datasets "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/tree/main/datasets/"
    click Notebook "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/Untitled.ipynb"
    click ModelArtifact "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/artifacts/model_data.joblib"
    click StreamlitApp "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/main.py"
    click Helper "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/prediction_helper.py"
    click Devcontainer "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/.devcontainer/devcontainer.json"
    click Requirements "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/blob/main/requirements.txt"
    click Assets "https://github.com/mehulcode12/advance_credit_risk_model_loan_prediction/tree/main/images/"

    %% Styles
    classDef data fill:#a2d2ff,stroke:#000
    classDef pipeline fill:#b7e4c7,stroke:#000
    classDef storage fill:#cdb4db,stroke:#000
    classDef ui fill:#ffb4a2,stroke:#000
    classDef env fill:#ffe066,stroke:#000
    classDef external fill:#e0e0e0,stroke:#000,stroke-dasharray: 5 5
```
