# anuragaryanyt/upifrauddetection architecture

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

- Interactive diagram: https://gitdiagram.com/anuragaryanyt/upifrauddetection
- Repository: https://github.com/anuragaryanyt/upifrauddetection

## Overview

##### Project type and purpose
- This is a full-stack web application for UPI fraud detection.
- Purpose: ingest UPI transaction data, train/evaluate ML models, and provide an interactive dashboard for real-time detection and visualization of fraud.

##### File structure
- Top-level files:
- `app.py` – Flask web server & routing
- `requirements.txt` – Python dependencies
- `README.md` – project overview
- Directories:
- `dataset/` – raw CSV data used for training & evaluation
- `filesuse/` – persisted trained model (`project_model1.h5`)
- `src/` – Jupyter notebooks & scripts for data processing, feature engineering, model training
- `static/` – CSS, JS, images for the front end
- `templates/` – HTML templates rendered by Flask
- Patterns:
- MVC-like separation – templates (View), `app.py` controllers (Controller), model files & dataset (Model)
- Machine learning pipeline separated from runtime inference

##### README for additional insights
- ML workflow: data cleaning → feature engineering → model training → prediction
- Interactive dashboard: upload data, view charts, alerts on fraud
- Tech stack: Python, Flask, scikit-learn (or TF/Keras for `.h5`), Jupyter, HTML/CSS/JS

##### Detail
- Every folder’s role: static assets vs. templates vs. notebooks
- External dependencies (requirements.txt)
- Where model files live and when they are loaded
- Both real-time inference flow and offline training flow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["Web Client (Browser)"]:::frontend
        subgraph "Front-end Assets"
            direction TB
            CSS["CSS Files"]:::frontend
            JS["JS Files"]:::frontend
            IMG["Image Assets"]:::frontend
            Vendor["Vendor Assets"]:::frontend
            Style["Style.css"]:::frontend
        end
        Templates["HTML Templates"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Flask["Flask Application (app.py)"]:::backend
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        ML["ML Inference Engine\n(loads project_model1.h5)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Dataset["UPI CSV Dataset"]:::storage
        ModelStore["Trained Model Store"]:::storage
    end

    %% Offline Pipeline
    subgraph "Offline ML Pipeline"
        direction TB
        BM["build_model.ipynb"]:::offline
        UD["update_dataset.ipynb"]:::offline
        CP[".ipynb_checkpoints"]:::offline
    end

    %% External & Documentation
    Requirements["requirements.txt"]:::external
    README["README.md"]:::external

    %% Connections
    Browser -->|"loads pages"| Flask
    Flask -->|"serves HTML"| Templates
    Flask -->|"serves assets"| CSS
    Flask -->|"serves assets"| JS
    Flask -->|"serves assets"| IMG
    Flask -->|"serves assets"| Vendor
    Flask -->|"serves assets"| Style
    Flask -->|"calls predict()"| ML
    ML -->|"reads model"| ModelStore
    Flask -->|"reads CSV"| Dataset
    Dataset -->|batch data| BM
    BM -->|writes model| ModelStore
    UD -->|updates data| Dataset
    CP -.-> UD

    Requirements --> Flask
    README --> Browser

    %% Styling
    classDef frontend fill:#D0E6FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#DFFFE0,stroke:#228B22,stroke-width:1px
    classDef storage fill:#FFE5B4,stroke:#FF8C00,stroke-width:1px
    classDef offline fill:#F0F0F0,stroke:#A9A9A9,stroke-width:1px,stroke-dasharray: 5 5
    classDef external fill:#F7F7F7,stroke:#666666,stroke-width:1px,stroke-dasharray: 2 2

    %% Click Events
    click CSS "https://github.com/anuragaryanyt/upifrauddetection/tree/main/static/css/"
    click JS "https://github.com/anuragaryanyt/upifrauddetection/tree/main/static/js/"
    click IMG "https://github.com/anuragaryanyt/upifrauddetection/tree/main/static/img/"
    click Vendor "https://github.com/anuragaryanyt/upifrauddetection/tree/main/static/vendor/"
    click Style "https://github.com/anuragaryanyt/upifrauddetection/blob/main/static/style.css"
    click Templates "https://github.com/anuragaryanyt/upifrauddetection/tree/main/templates/"
    click Flask "https://github.com/anuragaryanyt/upifrauddetection/blob/main/app.py"
    click ModelStore "https://github.com/anuragaryanyt/upifrauddetection/blob/main/filesuse/project_model1.h5"
    click Dataset "https://github.com/anuragaryanyt/upifrauddetection/blob/main/dataset/upi_fraud_dataset.csv"
    click BM "https://github.com/anuragaryanyt/upifrauddetection/blob/main/src/build_model.ipynb"
    click UD "https://github.com/anuragaryanyt/upifrauddetection/blob/main/src/update_dataset.ipynb"
    click CP "https://github.com/anuragaryanyt/upifrauddetection/tree/main/src/.ipynb_checkpoints/"
    click Requirements "https://github.com/anuragaryanyt/upifrauddetection/blob/main/requirements.txt"
    click README "https://github.com/anuragaryanyt/upifrauddetection/blob/main/README.md"
```
