SafeGuard is an all-in-one, secure messaging platform designed to give kids a unified inbox while giving parents peace of mind. It aggregates messages from platforms like Discord, Instagram, Twitter, and WhatsApp into a single application. Behind the scenes, a powerful, custom-built AI filtering engine scans both text and images in real-time to blur and censor harmful content, cyberbullying, and NSFW media before the child ever sees it.
Parents have access to a dedicated dashboard featuring data visualizations, stranger-danger approval queues, and a "Privacy Mode" that respects the child's privacy by only showing flagged content.
The frontend is built for speed and responsiveness using React, TypeScript, and Vite. Styling is handled via Tailwind CSS.
- Child View (
/child-chat): A unified chat interface resembling popular messaging apps where kids can talk to approved contacts across multiple platforms. - Parent Dashboard (
/parent-dashboard): A monitoring hub equipped with statistics (Safe Rate, 7-Day Activity), a queue for pending contact approvals, and real-time alerts for censored messages. - Content Checker: A lightweight, in-browser regex checker runs on the child's input to warn them before sending sensitive information (like addresses or SSNs) or profanity.
The backend is a fast, asynchronous REST API powered by Python and FastAPI.
- Platform Integrations: It runs background tasks to poll and listen to platforms like Instagram (via
instagrapi) and Discord (viadiscord.py-self). - Message Processing: It ingests incoming messages, passes them through the AI filtering pipeline, uploads media attachments securely, and saves the final processed data to the database.
SafeGuard uses a robust, in-house, multi-layered machine learning pipeline for real-time moderation:
- Text Censoring: A custom-trained sequence classification model (using PyTorch and HuggingFace Transformers) detects nuanced inappropriate content, threats, harassment, profanity, slurs, and other harmful phrases.
- Image Moderation: An approach using a SigLIP2 classifier. This pipeline accurately detects any harmful images or NSFW content.
The application relies on Firebase for its real-time database and storage needs:
- Cloud Firestore: Stores all messages, user settings, blocked users, and approved contacts. Messages are saved with detailed metadata, including whether they were censored and the specific words flagged.
- Firebase Storage: Securely hosts intercepted media attachments and profile pictures, allowing the frontend to load them safely.
- Node.js (v16+) & npm
- Dependencies:
react,react-dom,react-router-dom,firebase,@phosphor-icons/react,tailwindcss
- Python (3.8+)
- Core Packages:
fastapi,uvicorn,python-dotenv,firebase-admin. - Platform Packages:
discord.py-self,instagrapi. - Machine Learning Packages:
torch,transformers,numpy,pandas,scikit-learn,opencv-python,joblib,Pillow. - Local LLM: Ollama installed locally with the
llama3.2:3bmodel downloaded.
Clone the project to your local machine and navigate into the root directory.
- Go to the Firebase Console and create a new project with Firestore and Storage enabled.
- Generate a service account private key (JSON) and save it in the
backend/directory asserviceAccountKey.json. - Get your Firebase Web App configuration keys.
Create .env files in both the root/frontend and backend/ directories.
- Frontend (
/.env): Add your Vite Firebase config (VITE_FIREBASE_API_KEY,VITE_FIREBASE_PROJECT_ID, etc.). - Backend (
backend/.env): Add your Discord Token, Instagram credentials, and Firebase paths.
Open a terminal in the root directory:
# Install frontend dependencies
npm install
# Start the Vite development server
npm run dev