# paco1127/pure-blur architecture

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

- Interactive diagram: https://gitdiagram.com/paco1127/pure-blur
- Repository: https://github.com/paco1127/pure-blur

## Overview

##### Main Components Identification
- User Interface & Client Side:
– A web UI built with HTML templates (in the “templates” folder) and static assets (in “static”) that provides pages (login, register, upload, report, etc.).
– A browser extension (“FYP_extension/Pure Blur Extension”) that integrates with Chrome to offer in-browser blurring of sensitive content.
- Backend / API Server:
– The central application entry-point (app.py in the project root and within the Face folder) that handles requests from the web UI.
– This layer coordinates file uploads (stored in “uploads”), user management (from CSV files like “users.csv” and “userFiles.csv”), and response rendering (templates).
- Media Processing Modules:
– Face Module: Contains several submodules (detection, alignment, recognition, and tracking) with multiple implementations (RetinaFace, SCRFD, YOLOv5 Face, and ArcFace). Each component is likely used in face detection, enrollment (add_persons.py), alignment, recognition, and tracking (tracker modules with Kalman filter, byte tracker, etc.).
– Blood Module: Incorporates a PyTorch model (blood.pt) and supporting scripts (blood.py, blood_class.py) that likely detect blood-related patterns in imagery.
– Foul Module: Handles censorship of potentially offensive content (like mute.py and CSV-based data such as DirtyWords.csv) used in processing audio content.
– Nude Module: Contains ONNX based detection (best.onnx) and associated detectors (nude_detector.py, video_detector.py) used to screen for explicit content.
– Video Module: Contains utilities such as video_converter.py to process incoming video files.
- Data Storage & Persistence:
– File system based storage for uploads (organized in “uploads” folders – original, censored, etc.).
– CSV files (e.g., users.csv, userFiles.csv, report.csv) used as lightweight databases for user information and file associations.
- External Dependencies & Tools:
– System dependencies such as Python 3.11, FFmpeg (installed via Scoop), and Git.
– Machine learning frameworks (PyTorch, ONNX Runtime) and supporting libraries for executing detection models.

##### Relationships & Interactions
- User interaction via the web interface (UI) triggers file uploads and account operations.
- The backend server’s API receives these requests and dispatches the files for processing:
– Uploaded content is sent to appropriate detection modules (face, blood, foul, nude) depending on the media type.
– Each processing component (running its own algorithms/models) analyzes the content and returns status or processed outputs.
– Results are stored in “uploads/censored” or similar directories and entry points (CSV logs) are updated.
- The Chrome extension functions as an independent client that taps into similar processing or presentation logic for real-time blurring.

##### Architectural Patterns and Design Principles
- Modular design: Each detection module is cleanly separated (Face, Blood, Foul, Nude, Video) and can be represented as individual services or library components.
- Separation of concerns: The UI layer (HTML/JS) is separated from the backend logic where business rules and processing occur.
- Integration of third-party libraries and ML models: Clearly indicate external ML frameworks (like ONNX models, PyTorch) and how they feed into the processing.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI1["HTML Templates"]:::frontend
        UI2["Static Assets"]:::frontend
        UI3["Chrome Extension"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["API Server (app.py)"]:::api
        FACE["Face Processing Module"]:::module
        BLOOD["Blood Processing Module"]:::module
        FOUL["Foul Processing Module"]:::module
        NUDE["Nude Processing Module"]:::module
        VIDEO["Video Processing Module"]:::module
        CSV["User Data (CSV Files)"]:::data
    end

    %% Storage Layer
    subgraph "Storage"
        STORAGE["File Uploads & Storage"]:::storage
    end

    %% External Dependencies
    EXTD["External Dependencies"]:::external

    %% Data Flows from Frontend to API Server
    UI1 -->|"triggers"| API
    UI2 -->|"triggers"| API
    UI3 -->|"triggers"| API

    %% External Dependencies support API Server
    EXTD -->|"provides support"| API

    %% API Server dispatches to Processing Modules
    API -->|"sends media"| FACE
    API -->|"sends media"| BLOOD
    API -->|"sends media"| FOUL
    API -->|"sends media"| NUDE
    API -->|"sends media"| VIDEO

    %% Processing Modules return results to API Server
    FACE -->|"returns output"| API
    BLOOD -->|"returns output"| API
    FOUL -->|"returns output"| API
    NUDE -->|"returns output"| API
    VIDEO -->|"returns output"| API

    %% API Server updates data repositories and storage
    API -->|"updates"| CSV
    API -->|"stores files"| STORAGE

    %% Click Events
    click UI1 "https://github.com/paco1127/pure-blur/tree/main/FYP/templates"
    click UI2 "https://github.com/paco1127/pure-blur/tree/main/FYP/static"
    click UI3 "https://github.com/paco1127/pure-blur/tree/main/FYP_extension/Pure Blur Extension"
    click API "https://github.com/paco1127/pure-blur/blob/main/FYP/app.py"
    click FACE "https://github.com/paco1127/pure-blur/tree/main/FYP/Face"
    click BLOOD "https://github.com/paco1127/pure-blur/tree/main/FYP/Blood"
    click FOUL "https://github.com/paco1127/pure-blur/tree/main/FYP/Foul"
    click NUDE "https://github.com/paco1127/pure-blur/tree/main/FYP/Nude"
    click VIDEO "https://github.com/paco1127/pure-blur/tree/main/FYP/Video"
    click CSV "https://github.com/paco1127/pure-blur/blob/main/FYP/users.csv"
    click CSV "https://github.com/paco1127/pure-blur/blob/main/FYP/userFiles.csv"
    click CSV "https://github.com/paco1127/pure-blur/blob/main/FYP/report.csv"
    click STORAGE "https://github.com/paco1127/pure-blur/tree/main/FYP/uploads"

    %% Styles
    classDef frontend fill:#AEE1F9,stroke:#0277BD,stroke-width:2px;
    classDef api fill:#FFF176,stroke:#F57F17,stroke-width:2px;
    classDef module fill:#C5E1A5,stroke:#558B2F,stroke-width:2px;
    classDef storage fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef data fill:#FFE082,stroke:#FFB300,stroke-width:2px;
    classDef external fill:#FFCC80,stroke:#F57C00,stroke-width:2px;
```
