An Intelligent AI-Powered Parental Control & Child Safety Platform for Arabic Digital Content
With the rapid adoption of smartphones and social media among children in the Arabic-speaking world, major safety challenges have emergedβincluding exposure to Cyberbullying, Inappropriate/Sexual Content, Violence & Self-Harm, and Hate Speech. Arabic content presents distinct linguistic hurdles, including spoken colloquial dialects, unvocalized text (omitted Tashkeel), letter stretching (Tatweel), and Arabizi (Latin-script Arabic).
Safe Kids Guard addresses this challenge through an integrated, three-tier architecture:
- Android Child Monitoring App (
client/child_monitoring_app/): Observes on-screen text in real time using Android'sAccessibilityServicewith a 1.5-second debounce and deduplication window to prevent battery drain, plus a 10-second live policy synchronization loop. It protects privacy by ignoring password fields, bounds payloads safely (<= 4,500chars), normalizes URL domains and regional app package aliases, rotates JWT tokens automatically on expiration, logs local policy violations (POST /activity), and takes immediate protective action (returning to home viaGLOBAL_ACTION_HOMEwith a block & appeal overlay) upon detecting harmful content or blocked apps/URLs. - AI & Mediation Backend (
server/): Processes Arabic text through an advanced preprocessing pipeline and evaluates it with a dual-tier NLP architecture (AraBERT v2 + CAMeLBERT) executed off the event loop viaasyncio.to_thread. It features SlowAPI rate limiting and flexible database support (SQLite by default with zero configuration, XAMPP MySQL, or PostgreSQL). - Parent & Administrator Dashboard (
client/Dashboard/): A responsive Progressive Web App (PWA) built with Next.js 16, React 19, and Tailwind CSS v4 using the Arabic Cairo typography and standardized English numerals (0β9) for dates and times. Connected to live backend APIs (with automaticlocalhostand LAN IP resolution) for device pairing, real-time 4-second browser push notifications & Web Audio chimes, live activity logs, instant-save protection policies, and 100% Arabic RTL executive PDF reports.
[ Child Device - Android Kotlin App ]
(MonitoringAccessibilityService + 1.5s Debounce)
β
β 1. Real-time on-screen text inspection
βΌ (POST /api/v1/classification/predict)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend Server (FastAPI + SlowAPI) β
β β
β [1. Preprocessing] ββββΆ [2. Redis Cache] βββββΆ [3. AI Engine] ββββββΆ [4. Policies] β
β β’ Tashkeel removal β’ SHA-256 fingerprint β’ AraBERT v2 (MSA) β’ Sensitivity β
β β’ Tatweel removal β’ Latency < 1ms β’ CAMeLBERT (Dialect) β’ Category blockβ
β β’ Arabizi conversion β’ TTL: 24 hours β’ Fast-Path Regex β’ App blacklist β
β β’ HTML / password filter β’ Graceful fallback β’ Async thread worker β’ URL blacklist β
βββββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββ΄ββββββββββββββββββββββββ
βΌ (When harmful content is detected) βΌ (Audit logging & state update)
[ Real-Time Alert Dispatch ] [ Database (SQLAlchemy 2.0 Async) ]
β’ Firebase Cloud Messaging (Web Push) β’ SQLite (safekids_dev.db - local default)
β’ Instant Browser & In-App Security Alerts β’ XAMPP MySQL or PostgreSQL
β’ Immediate local app dismissal on child device β’ Users, Families, Policies, Members
β β’ Alerts & Child Activity Logs
βΌ β
[ Parent Device / Browser ] β
(Instant Security Push Alert) βΌ
[ Parent Dashboard (Next.js) ]
β’ Live activity feed & alerts review
β’ Child policy configuration & schedules
β’ Analytics charts & Arabic PDF exports
The repository is organized into three decoupled, complementary components:
SafeKidsGuard/
βββ server/ # FastAPI AI engine, database models, and RESTful APIs
β βββ app/ # Application source (auth, ai_engine, content_filter, alerts, policies, activity, reports, admin)
β βββ alembic/ # Database schema migrations
β βββ tests/ # Automated pytest suite (50/50 passing tests, 100%)
β βββ README.md # π Comprehensive server documentation & environment variables
β
βββ client/
β βββ Dashboard/ # Parent & Admin web portal (Next.js 16 + React 19 + Tailwind v4 + Cairo)
β β βββ src/app/ # App routes ((parent): dashboard, alerts, children, activity, policies, reports, notifications | (admin): users, models, flagged, settings)
β β βββ src/proxy.ts # Role-Based Access Control (RBAC) route proxy (Next.js 16)
β β βββ public/ # Static assets, PWA manifest, and Firebase service worker
β β βββ README.md # π Dashboard documentation, theming & route structure
β β
β βββ child_monitoring_app/ # Native Android protection client (Kotlin + Jetpack Compose M3)
β βββ app/src/main/ # Application code, AccessibilityService, PolicyEvaluator, EncryptedSharedPreferences, Retrofit
β βββ app/src/test/ # JUnit 4 automated unit test suite (6/6 passing tests, 100%)
β βββ README.md # π Android app documentation, permissions & pairing flow
β
βββ docs/ # Project documentation, academic requirements, and system diagrams
βββ docker-compose.yml # Container orchestration (FastAPI + PostgreSQL + Redis + Dashboard)
βββ .github/workflows/ci.yml # Continuous Integration (CI) automated testing workflow
You can run the system locally using either a lightweight local setup or full Docker orchestration:
A fresh clone requires Python 3.11 and Node.js 20+ (with npm). SQLite is the default database and requires zero installation.
Windows (PowerShell) β Backend:
cd server
py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txt
# 1. Initialize environment configuration
Copy-Item .env.example .env
# 2. Apply database migrations & seed default admin
alembic upgrade head
python create_admin.py
# 3. Start the FastAPI server
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadNote
If PowerShell blocks virtual environment script execution, run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
In a second terminal β Dashboard:
cd client/Dashboard
npm install
npm run devmacOS / Linux:
# Terminal 1 β Backend:
cd server
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
cp .env.example .env
alembic upgrade head
python create_admin.py
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# Terminal 2 β Dashboard:
cd client/Dashboard
npm install
npm run devTip
The backend supports instant switching to XAMPP MySQL by updating one line in server/.env:
DATABASE_URL=mysql+aiomysql://root:@localhost:3306/safekidsguard
Launches the complete production stack (FastAPI + PostgreSQL + Redis + Dashboard):
# 1. Clone repository and enter directory
git clone https://github.com/AzizAlAdny/SafeKidsGuard.git
cd SafeKidsGuard
# 2. Build and start all services including the Next.js Dashboard:
docker compose --profile full up --build- Parent & Admin Dashboard (Next.js): http://localhost:3000
- Interactive API Documentation (Swagger): http://localhost:8000/docs
- Standard API Base Path (v1): http://localhost:8000/api/v1/health
- Backend Health Check: http://localhost:8000/health
| Role | Password | Post-Login Landing Page | |
|---|---|---|---|
| System Administrator (Admin) | [email protected] |
Admin@123456 |
/admin (User management, AI metrics, content moderation) |
Note
To create an additional administrator or promote any existing registered user:
cd server && python create_admin.py
All system modules are backed by automated tests covering functionality, edge cases, and security:
- 50 out of 50 tests passing (100%):
test_unit_suite.py(10 tests): Dedicated unit test suite (UT-01βUT-10) covering password hashing & verification, JWT validation, Arabic preprocessing, Arabizi normalization, safe & inappropriate content classification, dialect detection, backend policy evaluation, and Android local policy evaluation.test_auth.py(11 tests): Registration, login, international E.164 & Saudi phone format validation, JWT token rotation, child device queries,/api/v1/compatibility, and SlowAPI rate limiting (HTTP 429).test_preprocessing.py(6 tests): Arabic text normalization, HTML stripping, Tashkeel/Tatweel removal, Arabizi parsing (preserving standalone digits), and elongation reduction.test_classification.py(6 tests): Five-category classification accuracy, automated Web Push alert triggering, and UUID validation.test_notifications.py(3 tests): Notification preferences and instant security push notification testing.test_policies.py(2 tests): Sensitivity thresholds, category blocking rules, and access authorization.test_activity.py(1 test): Activity stream recording and custom policy bypass exceptions.test_reports.py(1 test): Summary analytics aggregation and valid binary Arabic PDF generation (%PDF-).test_security_and_admin.py(10 tests): Safe handling of long Arabic passwords (>72 bytes), IDOR prevention, 6-digit PIN device pairing and unpairing, false-positive prevention for benign Arabic roots (e.g.ΩΨ±Ψ© Ψ§ΩΩΨ―Ω,Ψ§ΩΩΨ§Ψ―Ω,ΨͺΨ¨Ψ±ΨΉ Ψ¨Ψ§ΩΨ―Ω), child access appeals (UC-C5), and the administrator control lifecycle (FR10βFR13).
- 18 distinct routes verified across
(parent)and(admin)layouts with server-side RBAC protection via src/proxy.ts.
- 6 out of 6 JUnit tests passing (100%) in
PolicyEvaluatorTest.kt:- Screen text payload truncation (
<= 4,500chars) under FastAPI'smax_length=5000limit. - Cross-midnight (
21:00β06:00) and same-day (13:00β15:30) bedtime window evaluation. - Case-insensitive blacklisted domain matching with
https://,www.,m., and path normalization (normalizeDomain). - Blocked application matching across exact package names, regional package variants (e.g., TikTok
com.zhiliaoapp.musically/com.ss.android.ugc.trill), and custom app keywords (isAppBlocked). - 6-digit pairing PIN sanitization and validation.
- Screen text payload truncation (
- π Backend & AI Engine Guide (Server README)
- π» Parent Dashboard Guide (Dashboard README)
- π± Android Child Monitoring Client Guide (Android App README)
- π§ͺ Complete Real-World Testing Guide (Phone, Server & Dashboard)