Skip to content

nabil24024004/prevention

Repository files navigation

πŸ›‘οΈ Prevention - Islamic Accountability App

Flutter Supabase License

A comprehensive Islamic mobile app for fighting pornography addiction through accountability, motivation, and DNS-based content blocking.
Current Version: 5.0 (February 9, 2026)


πŸ“± Overview

Prevention is a privacy-first, security-hardened Android application designed to help Muslims overcome pornography addiction through:

  • DNS-based VPN blocking of explicit content
  • Streak tracking with mandatory daily check-ins
  • Islamic motivational content from Quran and Hadith
  • Relapse accountability with trigger analysis and reflection
  • Enterprise-grade security to prevent circumvention

✨ Key Features

πŸ”’ Content Blocking

  • VPN-based DNS filtering using Cloudflare Family DNS (1.1.1.3)
  • Always-on protection with automatic restart
  • Bypass prevention with external VPN detection
  • Tamper-resistant design

πŸ“Š Accountability System

  • Streak Tracking: Daily check-ins to maintain sobriety streak
  • Server-side validation: All streak logic runs in Supabase (tamper-proof)
  • Relapse Flow: Mandatory 3-step process (shame reminder, trigger selection, reflection)
  • Historical logs: Complete audit trail of check-ins and relapses

πŸ•Œ Islamic Motivation

  • Curated Quranic verses about purity and taqwa
  • Hadith collections on guarding chastity
  • Daily reminders and duas
  • Community stories of recovery

πŸ›‘οΈ Enterprise Security

  • Row Level Security (RLS) on all database tables
  • Rate limiting (5 check-ins/hour, 3 syncs/30min)
  • Anti-tampering: Emulator, root, and debug detection
  • VPN enforcement: Blocks check-ins if external VPN active
  • Offline integrity: Device fingerprinting + timestamp validation
  • Audit logging: Immutable security events table

πŸ—οΈ Architecture

Tech Stack

Frontend:

  • Flutter 3.x - Cross-platform UI framework
  • Riverpod - State management
  • Go Router - Navigation

Backend:

  • Supabase - PostgreSQL database + Auth + Real-time
  • PostgreSQL Functions - Server-side business logic (streak calculation, validation)

Native Layer (Android):

  • Kotlin - VPN service, tamper detection, network utilities
  • VpnService API - DNS-based content filtering

Security Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Flutter App                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Dashboard  β”‚  Islamic Corner  β”‚  Relapse Flow  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                          β”‚                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚         DashboardRepository (Dart)              β”‚   β”‚
β”‚  β”‚  β€’ VPN Enforcement                              β”‚   β”‚
β”‚  β”‚  β€’ Security Logging                             β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                β–Ό                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Native (VPN)  β”‚ β”‚  Supabase    β”‚ β”‚  Native         β”‚
β”‚  β€’ BlockerVPN  β”‚ β”‚  β€’ RLS       β”‚ β”‚  β€’ TamperCheck  β”‚
β”‚  β€’ NetworkUtil β”‚ β”‚  β€’ RPCs      β”‚ β”‚  β€’ Root Detect  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β€’ Rate Limitβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

  • Flutter SDK 3.x
  • Android Studio / VS Code
  • Android device (API 21+)
  • Supabase account

Installation

  1. Clone repository:
git clone https://github.com/yourusername/prevention.git
cd prevention
  1. Install dependencies:
flutter pub get
  1. Configure Supabase:

    • Create project at supabase.com
    • Apply SQL migrations (in order):
      1. complete_security_migration.sql
      2. security_logging.sql
      3. rate_limiting.sql
      4. input_validation.sql
      
    • Update lib/core/config.dart with your Supabase URL and anon key
  2. Run app:

flutter run

πŸ“¦ Deployment

Production Build

# Clean build
flutter clean
flutter pub get

# Release APK
flutter build apk --release

# Output: build/app/outputs/flutter-apk/app-release.apk

Distribution Options

  1. Google Play Internal Testing (Recommended)
  2. Firebase App Distribution
  3. Direct APK sharing

See deployment_guide.md for detailed instructions.


πŸ” Security Features

Implemented Protections

Feature Status Description
RLS Policies βœ… All tables secured with auth.uid() scoping
VPN Enforcement βœ… Blocks external VPNs during check-ins
Rate Limiting βœ… 5 check-ins/hour, 3 syncs/30min
Input Validation βœ… Mood enums, length checks, field validation
Offline Integrity βœ… Device fingerprinting + timestamp validation
Anti-Tampering βœ… Emulator, root, debug detection
Security Logging βœ… Immutable audit trail in security_events
Server-side Logic βœ… All streak calculations in PostgreSQL

Threat Model

Prevents:

  • βœ… Client-side streak manipulation
  • βœ… Offline data tampering
  • βœ… VPN bypassing of blocker
  • βœ… Rate limit abuse
  • βœ… Emulator/rooted device usage
  • βœ… Future-dated check-ins

πŸ“Š Project Structure

prevention/
β”œβ”€β”€ android/
β”‚   └── app/src/main/kotlin/
β”‚       └── com/prevention/prevention/
β”‚           β”œβ”€β”€ BlockerVpnService.kt    # VPN implementation
β”‚           β”œβ”€β”€ TamperDetector.kt       # Security checks
β”‚           β”œβ”€β”€ NetworkUtils.kt         # VPN detection
β”‚           └── MainActivity.kt         # Platform channels
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ core/                           # Config, themes, utils
β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”œβ”€β”€ auth/                       # Login, signup
β”‚   β”‚   β”œβ”€β”€ dashboard/                  # Main screen, check-ins
β”‚   β”‚   β”œβ”€β”€ blocking/                   # VPN control
β”‚   β”‚   └── islamic_corner/             # Motivational content
β”‚   └── main.dart
└── supabase/migrations/                # SQL files

πŸ§ͺ Testing

Local Testing

# Run unit tests
flutter test

# Run on device
flutter run

Beta Testing

See testing_instructions.md for 1-week testing protocol.


πŸ“– Documentation


🀝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Standards

  • Follow Flutter style guide
  • Add tests for new features
  • Update documentation
  • Ensure security best practices

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file.


πŸ™ Acknowledgments

  • Cloudflare Family DNS for content filtering
  • Supabase for backend infrastructure
  • Flutter community for amazing packages

πŸ“ž Support


Built with ❀️ to help the Muslim community stay pure in the digital age

About

A comprehensive Islamic mobile app for fighting pornography addiction through accountability, motivation, and DNS-based content blocking.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors