Skip to content

Andrew-A-A/Content_Filter_Extension_Backend

Repository files navigation

Content Guard 🛡️

AI-powered real-time content filtering for the web — browser extension + Flask API backend.

Python Flask JavaScript Accuracy


Overview

Content Guard is a full-stack content moderation system built as a graduation project at Ain Shams University (Faculty of Computer and Information Sciences). It combines a fine-tuned machine learning classification model with a lightweight Flask API and a Chrome browser extension to automatically detect and blur/block sensitive or inappropriate content — in real time, as users browse.

The system was designed around the challenge of making AI-driven content moderation accessible at the client level, without requiring server-side infrastructure on the part of websites being visited.


Architecture

┌─────────────────────────┐         ┌──────────────────────────────┐
│   Chrome Extension      │         │   Flask Classification API   │
│  (JavaScript/HTML/CSS)  │──POST──▶│   (Python / ML Model)        │
│                         │◀──JSON──│                              │
│  • Intercepts page text │         │  • Receives text payload     │
│  • Blurs/blocks content │         │  • Runs inference            │
│  • User toggle controls │         │  • Returns label + confidence│
└─────────────────────────┘         └──────────────────────────────┘

Repos:


Key Features

  • 98% classification accuracy on the test set across sensitive content categories
  • Real-time inference — content is evaluated and filtered on page load without perceptible lag
  • Automatic blur/block — the extension blurs flagged content and gives the user the option to reveal or permanently dismiss
  • Configurable thresholds — confidence threshold for triggering blur can be tuned via extension settings
  • Large-scale training data — model trained on a curated, merged dataset assembled from multiple public sources to maximize generalization

Tech Stack

Layer Technology
ML Model Python, scikit-learn / TensorFlow (see model notes)
API Server Flask, REST
Data Pipeline Pandas, NumPy
Browser Extension Vanilla JavaScript, HTML, CSS, Chrome Extensions API (Manifest V3)
Deployment Deployable on any WSGI-compatible host (e.g., Render, Railway, Heroku)

Getting Started

Prerequisites

  • Python 3.10+
  • pip
  • Google Chrome (for the extension)

1. Clone and set up the backend

git clone https://github.com/Andrew-A-A/Content_Filter_Extension_Backend.git
cd Content_Filter_Extension_Backend

pip install -r requirements.txt

2. Run the Flask API

python app.py

The API will start on http://localhost:5000 by default.

3. API Endpoint

POST /classify

// Request
{
  "text": "Content string to classify"
}

// Response
{
  "label": "safe",         // or "sensitive"
  "confidence": 0.97
}

4. Load the Chrome Extension

  1. Clone the extension repo
  2. Open Chrome and navigate to chrome://extensions
  3. Enable Developer Mode (top right)
  4. Click Load unpacked and select the cloned extension folder
  5. Ensure the backend API is running and the extension points to the correct API URL

Model Details

The classification model was built to detect sensitive/inappropriate content in text. Key decisions in the pipeline:

  • Data curation: Multiple public datasets were merged and deduplicated to improve coverage across content domains and writing styles
  • Preprocessing: Standard NLP pipeline — tokenization, stopword removal, and vectorization
  • Evaluation: Achieved 98% accuracy on the held-out test set, with balanced performance across classes

For full training notebooks and dataset sources, see the /notebooks directory.


Project Background

This project was developed as the graduation project for the Bachelor's in Computer Science at Ain Shams University (Oct 2023 – Jul 2024). The goal was to explore practical, client-side deployment of content moderation AI — a real problem faced by parents, educators, and organizations who want protection without relying on platform-level filtering.

About

API used to deploy our classifiers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors