# meysouro/ai-driven-corporate-credit-rating-prediction architecture

> Architecture diagram of the GitHub repository meysouro/ai-driven-corporate-credit-rating-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meysouro/ai-driven-corporate-credit-rating-prediction
- Repository: https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction

## Overview

##### Main Components
- Data Sources & Storage: Represent the raw datasets (found in the Datasets folder) coming from external APIs (Financial Modeling Prep API) and internal CSV/Excel files.
- Data Preprocessing & Feature Engineering: Capture the process (documented in the README and implemented in the Jupyter notebooks) that cleans, aggregates, and creates financial ratio features.
- Model Training & Validation: Highlight the model training, which includes using algorithms (such as a random forest classifier) and model validation using performance metrics (precision, recall, and F1 score). Indicate that checkpoints and different notebooks (e.g., Credit rating predictions-checkpoint.ipynb) are used during this stage.
- Model Persistence: This focuses on saving the trained model components (model_LR.pkl, encoder.pkl, transformer.pkl stored in the Pickles folder) for later use.
- Deployment/UI Layer: Emphasize the Streamlit application (app.py located in the Notebook folder) that serves as the user-facing interface for making credit rating predictions by accepting inputs and displaying outputs.

##### Relationships and Interactions
- Data Flow Start: Raw financial datasets (CSV/Excel) are ingested and then preprocessed/feature engineered as part of the model training pipeline.
- Model Training: The cleaned data feeds into model training and evaluation processes done within Jupyter Notebooks. From this phase, trained artifacts are stored (via the Pickles folder).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separate data ingestion/preprocessing, model training/validation, and deployment. This indicates modular responsibilities.
- Persistence and Reusability: Use of pickle files for saving models and transformers emphasizes reusability and efficient deployment.
- User-Centric Deployment: The use of Streamlit represents a clear separation of the user interface from the core ML logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Sources & Storage"
        DS1["corporate_rating.csv"]:::storage
        DS2["corporate_rating.xlsx"]:::storage
        DS3["corporate_ratings.xlsx"]:::storage
        DS4["validation_data.csv"]:::storage
    end

    subgraph "Data Preprocessing & Feature Engineering"
        DP1["README.md"]:::document
        DP2["Credit rating predictions.ipynb"]:::notebook
    end

    subgraph "Model Training & Validation"
        MT1["Credit rating predictions-checkpoint.ipynb"]:::notebook
        MT2["Credit rating predictions.ipynb"]:::notebook
    end

    subgraph "Model Persistence"
        MP1["model_LR.pkl"]:::pickle
        MP2["encoder.pkl"]:::pickle
        MP3["transformer.pkl"]:::pickle
    end

    subgraph "Deployment/UI Layer"
        UI1["app.py"]:::streamlit
    end

    AP["Financial Modeling Prep API"]:::external

    AP --> DS1
    DS1 --> DP1
    DP1 --> MT1
    MT1 --> MP1
    MP1 --> UI1

    %% Click Events
    click DS1 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Datasets/corporate_rating.csv"
    click DS2 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Datasets/corporate_rating.xlsx"
    click DS3 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Datasets/corporate_ratings.xlsx"
    click DS4 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Datasets/validation_data.csv"

    click DP1 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/README.md"
    click DP2 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Notebook/Credit rating predictions.ipynb"

    click MT1 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/.ipynb_checkpoints/Credit rating predictions-checkpoint.ipynb"
    click MT2 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Notebook/Credit rating predictions.ipynb"

    click MP1 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Pickles/model_LR.pkl"
    click MP2 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Pickles/encoder.pkl"
    click MP3 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Pickles/transformer.pkl"

    click UI1 "https://github.com/meysouro/ai-driven-corporate-credit-rating-prediction/blob/main/Notebook/app.py"

    %% Styles
    classDef external fill:#FFEE99,stroke:#333,stroke-width:2px;
    classDef storage fill:#B3E6FF,stroke:#333,stroke-width:2px;
    classDef document fill:#D1E8E2,stroke:#333,stroke-width:2px;
    classDef notebook fill:#F7C2FF,stroke:#333,stroke-width:2px;
    classDef pickle fill:#FFE6E6,stroke:#333,stroke-width:2px;
    classDef streamlit fill:#E6FFE6,stroke:#333,stroke-width:2px;
```
