# slainteee/jatayu-contentmoderation architecture

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

- Interactive diagram: https://gitdiagram.com/slainteee/jatayu-contentmoderation
- Repository: https://github.com/slainteee/jatayu-contentmoderation

## Overview

##### Main Components
- API Server & Core Engine – This is encapsulated by the “app.py” file that launches the Flask API. It acts as the gateway for incoming moderation requests.
- Content Moderation Modules – These represent the various specialized pipelines/algorithms:
– Text moderation (e.g., hate speech, phishing detection in text)
– Image moderation (using OCR with Tesseract for extracting text and models for violence detection)
– Audio/Video moderation (using speech-to-text features with libraries like Sphinx or Google Speech Recognition)
– Spam Classification – found in the “Spam Classifier” directory (with its own notebook and saved models).
– Violence Detection – provided via both PyTorch and TensorFlow implementations in the “Violence-Detection” directory.
– Phishing Detection – found in the “PhishingWebsite” section, with feature extraction scripts, dataset, and trained model files.
– Hate/Content Analysis – the “hatespeech” directory supports additional content moderation modalities.
- Frontend/Client Interfaces – There are two:
– Mobile demonstration (Android app under “App/app”)
– Web demo via Flask (in the “Web-Frontend” directory, which includes “server.py”, static assets, templates, etc.)
- Data & Model Artifacts – Look at dataset directories, saved models (e.g., “model_logistic_regression.pkl”, “NB_model.pkl”), and supporting files used to train and operationalize ML models.

##### Relationships and Interactions
- Client Interaction Layer: Mobile apps (Android) and web browser frontends send requests (including media or text content) to the API server.
- API Gateway: The central “app.py” Flask script listens for incoming requests, then routes them to the appropriate AI/ML module based on the content type.
- Processing Pipelines: Once a request is received:
– Text data might be sent for NLP processing using NLTK/spaCy.
– Images pass through an OCR engine (Tesseract) and possibly a violence detection model.
– Audio/video content undergoes speech recognition and subsequent analysis.
– Dedicated modules for phishing detection, spam classification, and hate speech analysis get invoked as needed.
- Data Flow & Model Inference: The API calls extract features and uses pre-trained models (loaded from the “trainedmodel”, “saved_models”, or similar directories) to decide the level of moderation required.
- Storage/Static Assets: Files related to static images, CSS for the interface, and model outputs may be stored in defined folders.

##### Architectural Patterns and Design Principles
- Modular Design: Each content moderation function is separated into its own component (or service module) so that the API can delegate processing.
- Separation of Concerns: The Android app and web frontend are distinct from the backend API service, and ML pipelines are isolated from the API layer.
- Extensibility: The structure (with separate directories for each type of analysis) indicates that new moderation modules could be added with clear interfaces.
- Standard Communication: RESTful calls (or similar API calls) connect the UI to backend processing.

##### Relevant Technologies
- Python with Flask for the API.
- ML/DL Frameworks: TensorFlow, PyTorch, and Scikit-Learn for different moderation models.
- Natural Language Processing: NLTK and spaCy.
- OCR: Tesseract via pytesseract.
- Speech Recognition: Sphinx/Google Speech Recognition libraries for audio.
- Frontend Technologies: Flask templating for the web demo and Android (Java) for the mobile demo, with corresponding Gradle configurations.
- Version Control (Git), CI/CD (GitHub workflows), and requirements management (requirements.txt, gradle build files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        AC["Android Client"]:::client
        WC["Web Client"]:::client
    end

    %% API Layer
    subgraph "API Layer"
        API["API Server (Flask - app.py)"]:::api
    end

    %% Processing Pipelines
    subgraph "Processing Pipelines"
        TME["Text Moderation Engine (NLP)"]:::pipeline
        IME["Image Moderation (OCR & Violence)"]:::pipeline
        AVME["Audio/Video Moderation (Speech Recognition)"]:::pipeline
    end

    %% ML Model Hub
    subgraph "ML Model Hub"
        SC["Spam Classifier Module"]:::ml
        VD["Violence Detection Module"]:::ml
        PD["Phishing Detection Module"]:::ml
        HS["Hate Speech Analysis Module"]:::ml
    end

    %% Connections from Clients to API
    AC -->|"sends moderation request"| API
    WC -->|"sends moderation request"| API

    %% Connections from API to Processing Pipelines
    API -->|"routes text"| TME
    API -->|"routes images"| IME
    API -->|"routes audio/video"| AVME

    %% Connections from API to ML Modules
    API -->|"invokes"| SC
    API -->|"invokes"| VD
    API -->|"invokes"| PD
    API -->|"invokes"| HS

    %% Click Events
    click API "https://github.com/slainteee/jatayu-contentmoderation/blob/master/app.py"
    click AC "https://github.com/slainteee/jatayu-contentmoderation/tree/master/App/app"
    click WC "https://github.com/slainteee/jatayu-contentmoderation/tree/master/Web-Frontend"
    click SC "https://github.com/slainteee/jatayu-contentmoderation/tree/master/Spam Classifier"
    click VD "https://github.com/slainteee/jatayu-contentmoderation/tree/master/Violence-Detection"
    click PD "https://github.com/slainteee/jatayu-contentmoderation/tree/master/PhishingWebsite"
    click HS "https://github.com/slainteee/jatayu-contentmoderation/tree/master/hatespeech"

    %% Styles
    classDef client fill:#a2d2ff,stroke:#037ffc,stroke-width:2px;
    classDef api fill:#ffb3ba,stroke:#ff477e,stroke-width:2px;
    classDef pipeline fill:#caffbf,stroke:#66ff66,stroke-width:2px;
    classDef ml fill:#ffffba,stroke:#f1c40f,stroke-width:2px;
```
