# wissalkabous/credit_approval_system architecture

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

- Interactive diagram: https://gitdiagram.com/wissalkabous/credit_approval_system
- Repository: https://github.com/wissalkabous/credit_approval_system

## Overview

Credit Approval System serves applicant credit decisions through a FastAPI API and embedded web form, returning an approval decision, confidence, and risk band. The documented flow validates requests, preprocesses features, predicts, formats results, and logs prediction events in the background. Training is a separate product stage that prepares data, fits and evaluates the classifier, and persists model artifacts. Source excerpts show the core ML and dependency-injection relationships; some API and training wiring is documented in the README rather than shown in full.

Main entry points: [`src/predictor.py`](https://github.com/wissalkabous/credit_approval_system/blob/main/src/predictor.py) (Prediction orchestration), [`src/container.py`](https://github.com/wissalkabous/credit_approval_system/blob/main/src/container.py) (Dependency container), [`api/main.py`](https://github.com/wissalkabous/credit_approval_system/blob/main/api/main.py) (FastAPI routes), [`src/model.py`](https://github.com/wissalkabous/credit_approval_system/blob/main/src/model.py) (Credit classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Applicant access"]
  node_webform["Web form<br/>[main.py]"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_serving["Prediction service"]
  node_preprocess["Feature preprocessing<br/>[data_loader.py]"]
  node_predictor["Prediction orchestration<br/>[predictor.py]"]
  node_classifier["Credit classifier<br/>[model.py]"]
  node_result["Decision and risk<br/>[predictor.py]"]
  node_eventlog["Prediction logging<br/>[logger.py]"]
end

subgraph group_training["Model training"]
  node_trainer["Training entry point<br/>[train.py]"]
  node_dataset["Applicant dataset<br/>[credit_data.csv]"]
  node_modelinfo["Model metadata"]
end

subgraph group_foundation["Shared infrastructure"]
  node_repository[("Model persistence<br/>[repository.py]")]
  node_container["Dependency container<br/>[container.py]"]
  node_interfaces["Layer contracts<br/>[interfaces.py]"]
  node_logger["Logging implementations<br/>[logger.py]"]
  node_decorators["Timing and validation<br/>[decorators.py]"]
  node_functional["Functional utilities<br/>[functional.py]"]
end

node_applicant(("Applicant"))
node_externalclient(("API client"))

node_applicant -->|"enters details"| node_webform
node_webform -->|"submits request"| node_api
node_externalclient -->|"posts prediction"| node_api
node_api -->|"validates request"| node_schemas
node_api -.->|"requests prediction"| node_predictor
node_predictor -->|"scales features"| node_preprocess
node_predictor -->|"requests prediction"| node_classifier
node_predictor -->|"formats decision"| node_result
node_api -->|"returns response"| node_result
node_api -->|"logs asynchronously"| node_eventlog
node_trainer -->|"creates services"| node_container
node_trainer -->|"loads data"| node_dataset
node_trainer -->|"prepares features"| node_preprocess
node_trainer -->|"trains and evaluates"| node_classifier
node_classifier -->|"saves model"| node_repository
node_repository -->|"persists metadata"| node_modelinfo
node_container -->|"creates processor"| node_preprocess
node_container -->|"creates model"| node_classifier
node_container -->|"creates predictor"| node_predictor
node_container -->|"registers repository"| node_repository
node_container -->|"registers logger"| node_logger
node_preprocess -->|"uses decorators"| node_decorators
node_classifier -->|"uses decorators"| node_decorators
node_predictor -->|"uses decorators"| node_decorators
node_preprocess -->|"implements contract"| node_interfaces
node_classifier -->|"implements contract"| node_interfaces
node_predictor -->|"implements contract"| node_interfaces
node_repository -->|"implements contract"| node_interfaces

click node_webform "https://github.com/wissalkabous/credit_approval_system/blob/main/api/main.py"
click node_api "https://github.com/wissalkabous/credit_approval_system/blob/main/api/main.py"
click node_schemas "https://github.com/wissalkabous/credit_approval_system/blob/main/api/schemas.py"
click node_preprocess "https://github.com/wissalkabous/credit_approval_system/blob/main/src/data_loader.py"
click node_predictor "https://github.com/wissalkabous/credit_approval_system/blob/main/src/predictor.py"
click node_classifier "https://github.com/wissalkabous/credit_approval_system/blob/main/src/model.py"
click node_result "https://github.com/wissalkabous/credit_approval_system/blob/main/src/predictor.py"
click node_eventlog "https://github.com/wissalkabous/credit_approval_system/blob/main/src/logger.py"
click node_trainer "https://github.com/wissalkabous/credit_approval_system/blob/main/train.py"
click node_dataset "https://github.com/wissalkabous/credit_approval_system/blob/main/data/raw/credit_data.csv"
click node_modelinfo "https://github.com/wissalkabous/credit_approval_system/blob/main/models/credit_model_info.json"
click node_repository "https://github.com/wissalkabous/credit_approval_system/blob/main/src/repository.py"
click node_container "https://github.com/wissalkabous/credit_approval_system/blob/main/src/container.py"
click node_interfaces "https://github.com/wissalkabous/credit_approval_system/blob/main/src/interfaces.py"
click node_logger "https://github.com/wissalkabous/credit_approval_system/blob/main/src/logger.py"
click node_decorators "https://github.com/wissalkabous/credit_approval_system/blob/main/src/decorators.py"
click node_functional "https://github.com/wissalkabous/credit_approval_system/blob/main/src/functional.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_webform,node_api,node_schemas,node_externalclient toneBlue
class node_preprocess,node_predictor,node_classifier,node_result,node_eventlog toneAmber
class node_trainer,node_dataset,node_modelinfo toneMint
class node_repository,node_container,node_interfaces,node_logger,node_decorators,node_functional toneRose
class node_applicant toneIndigo
```

## Components

### Applicant access

- [Web form](https://github.com/wissalkabous/credit_approval_system/blob/main/api/main.py): `api/main.py`
- [FastAPI routes](https://github.com/wissalkabous/credit_approval_system/blob/main/api/main.py): `api/main.py`
- [Request schemas](https://github.com/wissalkabous/credit_approval_system/blob/main/api/schemas.py): `api/schemas.py`

### Prediction service

- [Feature preprocessing](https://github.com/wissalkabous/credit_approval_system/blob/main/src/data_loader.py): `src/data_loader.py`
- [Prediction orchestration](https://github.com/wissalkabous/credit_approval_system/blob/main/src/predictor.py): `src/predictor.py`
- [Credit classifier](https://github.com/wissalkabous/credit_approval_system/blob/main/src/model.py): `src/model.py`
- [Decision and risk](https://github.com/wissalkabous/credit_approval_system/blob/main/src/predictor.py): `src/predictor.py`
- [Prediction logging](https://github.com/wissalkabous/credit_approval_system/blob/main/src/logger.py): `src/logger.py`

### Model training

- [Training entry point](https://github.com/wissalkabous/credit_approval_system/blob/main/train.py): `train.py`
- [Applicant dataset](https://github.com/wissalkabous/credit_approval_system/blob/main/data/raw/credit_data.csv): `data/raw/credit_data.csv`
- [Model metadata](https://github.com/wissalkabous/credit_approval_system/blob/main/models/credit_model_info.json): `models/credit_model_info.json`

### Shared infrastructure

- [Model persistence](https://github.com/wissalkabous/credit_approval_system/blob/main/src/repository.py): `src/repository.py`
- [Dependency container](https://github.com/wissalkabous/credit_approval_system/blob/main/src/container.py): `src/container.py`
- [Layer contracts](https://github.com/wissalkabous/credit_approval_system/blob/main/src/interfaces.py): `src/interfaces.py`
- [Logging implementations](https://github.com/wissalkabous/credit_approval_system/blob/main/src/logger.py): `src/logger.py`
- [Timing and validation](https://github.com/wissalkabous/credit_approval_system/blob/main/src/decorators.py): `src/decorators.py`
- [Functional utilities](https://github.com/wissalkabous/credit_approval_system/blob/main/src/functional.py): `src/functional.py`

### Other components

- **Applicant**
- **API client**

## Connections

- Applicant → Web form: enters details (evidence: `README.md`)
- Web form → FastAPI routes: submits request (evidence: `README.md`)
- API client → FastAPI routes: posts prediction (evidence: `README.md`)
- FastAPI routes → Request schemas: validates request (evidence: `api/main.py`)
- FastAPI routes → Prediction orchestration: requests prediction
- Prediction orchestration → Feature preprocessing: scales features (evidence: `src/predictor.py`)
- Prediction orchestration → Credit classifier: requests prediction (evidence: `src/predictor.py`)
- Prediction orchestration → Decision and risk: formats decision (evidence: `src/predictor.py`)
- FastAPI routes → Decision and risk: returns response (evidence: `README.md`)
- FastAPI routes → Prediction logging: logs asynchronously (evidence: `README.md`)
- Training entry point → Dependency container: creates services (evidence: `train.py`)
- Training entry point → Applicant dataset: loads data (evidence: `README.md`)
- Training entry point → Feature preprocessing: prepares features (evidence: `README.md`)
- Training entry point → Credit classifier: trains and evaluates (evidence: `README.md`)
- Credit classifier → Model persistence: saves model (evidence: `src/model.py`)
- Model persistence → Model metadata: persists metadata (evidence: `src/repository.py`)
- Dependency container → Feature preprocessing: creates processor (evidence: `src/container.py`)
- Dependency container → Credit classifier: creates model (evidence: `src/container.py`)
- Dependency container → Prediction orchestration: creates predictor (evidence: `src/container.py`)
- Dependency container → Model persistence: registers repository (evidence: `src/container.py`)
- Dependency container → Logging implementations: registers logger (evidence: `src/container.py`)
- Feature preprocessing → Timing and validation: uses decorators (evidence: `src/data_loader.py`)
- Credit classifier → Timing and validation: uses decorators (evidence: `src/model.py`)
- Prediction orchestration → Timing and validation: uses decorators (evidence: `src/predictor.py`)
- Feature preprocessing → Layer contracts: implements contract (evidence: `src/data_loader.py`)
- Credit classifier → Layer contracts: implements contract (evidence: `src/model.py`)
- Prediction orchestration → Layer contracts: implements contract (evidence: `src/predictor.py`)
- Model persistence → Layer contracts: implements contract (evidence: `src/repository.py`)
