# ahad-2004/fraud-detection-using-dl architecture

> Architecture diagram of the GitHub repository ahad-2004/fraud-detection-using-dl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahad-2004/fraud-detection-using-dl
- Repository: https://github.com/ahad-2004/fraud-detection-using-dl

## Overview

##### Project type and purpose
- This is a full-stack, single-page web application for real-time insurance fraud detection.
- It consists of a modern HTML/Bootstrap frontend, a FastAPI backend, and an AI/ML component (Keras model + sklearn preprocessing).

##### File structure
- Top-level files:
- main.py – FastAPI server entrypoint
- index.html – Static dashboard UI
- professional_fraud_model.h5 – Trained Keras model
- professional_preprocessor.pkl – sklearn preprocessing pipeline
- test_preprocessor.py – Unit test for the preprocessing stage
- fix_preprocessor.py – (Presumed) utility to rebuild/fix the pipeline
- start_server.bat, upload_to_github.bat – Deployment scripts
- requirements.txt – Python dependencies
- No separate “frontend” or “backend” folders: components are co-located but logically separated.

##### README for additional insights
- Frontend: HTML5, Bootstrap 5, JavaScript, CSS3
- Backend: Python, FastAPI, Uvicorn
- AI/ML: TensorFlow/Keras, Scikit-Learn, Pandas
- Key workflow: user submits claim → backend loads preprocessor → transforms data → feeds model → returns risk score → frontend renders animated risk meter.

a. Main components (group into layers):
1) Client Layer
- Web Browser (UI)
- index.html + JS/CSS in browser
- User form for claim input, animated risk meter
2) API Layer
- FastAPI Server (main.py + Uvicorn)
- POST /predict endpoint
- Error handling, JSON request/response
3) ML Layer
- Preprocessor Module
- professional_preprocessor.pkl loaded via sklearn
- Prediction Model
- professional_fraud_model.h5 loaded via TensorFlow/Keras
4) Dev/Deploy Utilities
- test_preprocessor.py (CI/QA)
- fix_preprocessor.py (rebuild pipeline)
- start_server.bat, upload_to_github.bat (automation)

b. Relationships & interactions

c. Architectural patterns/design principles
- Separation of concerns: UI vs. API vs. ML pipeline
- Stateless REST API: each request loads pipeline + model (or could be cached)
- Pipeline abstraction: serialization of feature engineering
- Modular design: utilities/scripts decoupled from core runtime

d. Key technologies/frameworks
- Frontend: HTML5, Bootstrap 5, JavaScript, CSS3
- Backend: FastAPI, Uvicorn
- ML: TensorFlow/Keras (.h5), sklearn Pipeline (.pkl), Pandas
- Dev: Python scripts, Windows batch for automation

##### Final recommendations
- Be exhaustive but avoid clutter: group files into logical modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser UI<br>(HTML5, Bootstrap 5, JS)<br>index.html"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API["FastAPI Server<br>(Python + Uvicorn)<br>main.py"]:::api
    end

    %% ML Layer
    subgraph "ML Layer"
        Preprocessor["Preprocessor Module<br>(sklearn Pipeline)<br>professional_preprocessor.pkl"]:::ml
        Model["Prediction Model<br>(Keras .h5)<br>professional_fraud_model.h5"]:::ml
    end

    %% Dev/QA Utilities
    subgraph "Dev/QA Utilities"
        Test["test_preprocessor.py"]:::util
        Fix["fix_preprocessor.py"]:::util
    end

    %% Dev/Deploy Utilities
    subgraph "Dev/Deploy Utilities"
        Start["start_server.bat"]:::util
        Upload["upload_to_github.bat"]:::util
        Requirements["requirements.txt"]:::util
        Docs["README.md"]:::util
    end

    %% Runtime Flows
    Browser -->|"HTTP POST /predict (JSON)"| API
    API -->|"load & transform"| Preprocessor
    Preprocessor -->|"predict(features)"| Model
    Model -->|"risk score"| API
    API -->|"HTTP Response (JSON)"| Browser

    %% Dev/Test Flows
    Test --- Preprocessor
    Fix --- Preprocessor

    %% Deploy Flows
    Start --- API
    Upload --- API

    %% Documentation & Dependencies
    Requirements --- API
    Docs --- Browser

    %% Click Events
    click Browser "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/index.html"
    click API "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/main.py"
    click Preprocessor "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/professional_preprocessor.pkl"
    click Model "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/professional_fraud_model.h5"
    click Test "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/test_preprocessor.py"
    click Fix "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/fix_preprocessor.py"
    click Start "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/start_server.bat"
    click Upload "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/upload_to_github.bat"
    click Requirements "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/requirements.txt"
    click Docs "https://github.com/ahad-2004/fraud-detection-using-dl/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef api fill:#90EE90,stroke:#333,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#333,stroke-width:1px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:1px
```
