# ivanalexo/xception-final-project architecture

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

- Interactive diagram: https://gitdiagram.com/ivanalexo/xception-final-project
- Repository: https://github.com/ivanalexo/xception-final-project

## Overview

##### Project type and purpose
- This is a full-stack deepfake-detection system comprised of three parts:
a. An offline model-training pipeline using the Xception architecture (“xception_project”).
b. A Flask-based REST API for serving model inference (“backend_deepfake”).
c. A React/Vite frontend web app (“deepfake-detection”) that lets users upload media and view prediction results.

##### File structure
- Top-level directories:
- backend_deepfake/ – contains `main.py`, the Flask entrypoint.
- deepfake-detection/ – React source under `src/`, public assets in `public/`, configs for Tailwind, Vite, ESLint, etc.
- xception project/ – Python scripts for data extraction (`scripts/`), training (`xception_train.py`), evaluation (`evaluate_xception.py`), and inference (`image_predict.py`).
- Patterns:
- Clear separation of concerns: ML training vs. API vs. UI.
- API layer in Flask exposing endpoints for uploading files and returning predictions.
- React hooks (`usePredict.js`) handling API calls.
- Config/deployment files:
- `package.json`, `vite.config.js`, `tailwind.config.js` in frontend.
- No obvious Docker or Kubernetes manifests, but one could add them.

##### README for additional insights
- The README confirms the three-component division and intended roles.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Offline ML Training Pipeline
    subgraph "Offline ML Training Pipeline"
        direction TB
        extract_images_from_image["Extract Images from Image"]:::script
        extract_images_from_video["Extract Images from Video"]:::script
        pipeline_orchestrator["Pipeline Orchestrator"]:::script
        training_script["Training Script"]:::script
        evaluation_script["Evaluation Script"]:::script
        image_predict["Inference Script"]:::script
    end

    ModelArtifacts["Model Artifacts Store"]:::storage

    extract_images_from_image -->|"feeds data"| pipeline_orchestrator
    extract_images_from_video -->|"feeds data"| pipeline_orchestrator
    pipeline_orchestrator -->|"runs training"| training_script
    training_script -->|"saves weights"| ModelArtifacts
    evaluation_script -->|"evaluates model"| ModelArtifacts
    ModelArtifacts -->|"inference"| image_predict

    %% Inference API
    subgraph "Inference API (Flask)"
        direction TB
        flask_app["Flask App (main.py)"]:::service
    end

    %% Frontend Web App
    subgraph "Frontend Web App (React/Vite)"
        direction TB
        index_html["index.html"]:::script
        main_jsx["main.jsx"]:::script
        app_jsx["App.jsx"]:::script
        index_css["index.css"]:::script
        header["Header.jsx"]:::script
        formulario["Formulario.jsx"]:::script
        preview["Preview.jsx"]:::script
        error["Error.jsx"]:::script
        usePredict["usePredict.js"]:::script
        assets["assets/"]:::storage
        public["public/"]:::storage
        package_json["package.json"]:::script
        package_lock["package-lock.json"]:::script
        vite_config["vite.config.js"]:::script
        tailwind_config["tailwind.config.js"]:::script
        postcss_config["postcss.config.js"]:::script
        eslint[".eslintrc.cjs"]:::script
        gitignore[".gitignore"]:::script
    end

    %% Runtime Data Flow
    usePredict -->|"POST /predict"| flask_app
    flask_app -->|"loads weights"| ModelArtifacts
    flask_app -->|"returns JSON"| usePredict

    %% Click Events for Offline Pipeline
    click extract_images_from_image "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/scripts/extract_images_from_image.py"
    click extract_images_from_video "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/scripts/extract_images_from_video.py"
    click pipeline_orchestrator "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/pipeline.py"
    click training_script "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/xception_train.py"
    click evaluation_script "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/evaluate_xception.py"
    click image_predict "https://github.com/ivanalexo/xception-final-project/blob/main/xception project/image_predict.py"

    %% Click Event for Flask API
    click flask_app "https://github.com/ivanalexo/xception-final-project/blob/main/backend_deepfake/main.py"

    %% Click Events for Frontend Web App
    click index_html "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/index.html"
    click main_jsx "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/main.jsx"
    click app_jsx "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/App.jsx"
    click index_css "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/index.css"
    click header "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/components/Header.jsx"
    click formulario "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/components/Formulario.jsx"
    click preview "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/components/Preview.jsx"
    click error "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/components/Error.jsx"
    click usePredict "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/src/hooks/usePredict.js"
    click assets "https://github.com/ivanalexo/xception-final-project/tree/main/deepfake-detection/src/assets/"
    click public "https://github.com/ivanalexo/xception-final-project/tree/main/deepfake-detection/public/"
    click package_json "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/package.json"
    click package_lock "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/package-lock.json"
    click vite_config "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/vite.config.js"
    click tailwind_config "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/tailwind.config.js"
    click postcss_config "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/postcss.config.js"
    click eslint "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/.eslintrc.cjs"
    click gitignore "https://github.com/ivanalexo/xception-final-project/blob/main/deepfake-detection/.gitignore"

    %% Styles
    classDef service fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px
    classDef script fill:#D3D3D3,stroke:#000,stroke-width:1px
```
