# dev-s-t/frauddetectionsystem architecture

> Architecture diagram of the GitHub repository dev-s-t/frauddetectionsystem, 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/dev-s-t/frauddetectionsystem
- Repository: https://github.com/dev-s-t/frauddetectionsystem

## Overview

##### Main Components
- Frontend Web Pages:
- FSD Landing Page (FSD_landing-main): The central starting page of the platform.
- User Input Form (form-fsd-main): A form designed for users to input data, including CSV mapping files for categories, jobs, merchants, and states.
- API Documentation Page (api_page-main): A dedicated page that documents the API endpoints.
- Prediction Results Page (results-main): A page to display the outcomes of predictions.

- Backend API:
- Prediction API (fsd-v2-main): Contains the main entry point (main.py running with uvicorn) that processes incoming requests, loads models (from the resources directory), and generates prediction results. This component also includes some testing scripts and additional modules.

- Model Development:
- Model Creation (Model_creation): Jupyter notebooks for building and refining the machine learning/deep learning models used for fraud detection. While not part of the live system, they are an essential component for developing and updating your models.

##### Relationships and Interactions
- The Landing Page to the Input Form and API Documentation.
- The Input Form to the Backend API, representing that user data is submitted via the form.
- Data Flow: From the Backend API to the Results Page, showing that predictions are returned and displayed.
- Internal Processing: Within the Backend API component (fsd-v2-main), highlight that the prediction service loads various pre-trained model files (e.g., knn_model.pkl, neural_network_model.h5, random_forest_model.pkl, scaler.pkl, xgboost_model.pkl) from the resources folder.
- Model Creation: Indicate that the Jupyter notebooks (Model_creation) are used for experimental development and training of models that eventually get deployed to the API server.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Clearly delineate the presentation (frontend web pages), business logic (backend prediction API), and data/model development (Jupyter notebooks) layers.
- API-Driven Architecture: The backend is built to serve predictions via API endpoints (noted by the uvicorn command for FastAPI or similar), which the frontend utilizes.
- Modular Design: Each folder (landing page, form input, API docs, results, model creation, and prediction server) is its own module, allowing independent development and testing.

##### Relevant Technologies and Frameworks
- Frontend: Standard web technologies (HTML, CSS) are used in the landing, form page, API documentation, and results pages.
- Backend: Python-based service utilizing uvicorn (likely via FastAPI given the command structure “uvicorn main:app --reload”) that handles API requests.
- Machine Learning: Multiple models are loaded (e.g., KNN, neural network, random forest, XGBoost) with corresponding file formats (pickle for most and .h5 for neural network models). The notebooks in Model_creation likely use typical Python ML libraries (e.g., scikit-learn, TensorFlow/Keras).

##### Specific Elements
- Each component should be clearly labeled with its folder name (e.g., FSD_landing-main, fsd-v2-main, form-fsd-main, etc.).
- From “User” to “Input Form” to “Backend API”.
- From “Backend API” to “Results Page”.
- Web interfaces (landing, forms, docs, results)
- API/backend service
- Model training environment
- Optionally, insert a note indicating that certain folders (like Model_creation) are used primarily for development/training while fsd-v2-main represents the live API that utilizes these models.

##### Final Assembly
- This user to the “Landing Page” interface.
- Branch out to the “Form for User Input” and “API Documentation” components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("External User"):::external

    subgraph "Frontend Components"
        FSDLanding("FSD Landing Page"):::frontend
        UserInput("User Input Form"):::frontend
        APIDocs("API Documentation Page"):::frontend
        PredictionResults("Prediction Results Page"):::frontend
    end

    subgraph "Backend Services"
        BackendAPI("Backend Prediction API"):::backend
        ModelLoader("Model Loader (Resources)"):::backend
    end

    subgraph "Model Development"
        ModelCreation("Model Creation"):::model
    end

    User -->|"navigates"| FSDLanding
    FSDLanding -->|"navigate"| UserInput
    FSDLanding -->|"navigate"| APIDocs
    UserInput -->|"DataSubmission"| BackendAPI
    BackendAPI -->|"ModelLoading"| ModelLoader
    BackendAPI -->|"PredictionResult"| PredictionResults
    ModelCreation -->|"ModelDeployment"| ModelLoader

    click FSDLanding "https://github.com/dev-s-t/frauddetectionsystem/tree/main/FSD_landing-main"
    click UserInput "https://github.com/dev-s-t/frauddetectionsystem/tree/main/form-fsd-main"
    click APIDocs "https://github.com/dev-s-t/frauddetectionsystem/tree/main/api_page-main"
    click PredictionResults "https://github.com/dev-s-t/frauddetectionsystem/tree/main/results-main"
    click BackendAPI "https://github.com/dev-s-t/frauddetectionsystem/tree/main/fsd-v2-main"
    click ModelLoader "https://github.com/dev-s-t/frauddetectionsystem/tree/main/fsd-v2-main/resources"
    click ModelCreation "https://github.com/dev-s-t/frauddetectionsystem/tree/main/Model_creation"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef model fill:#F4A460,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:2px;
```
