Skip to content

UNIIIIK/MealDeal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ MealDeal - Food Surplus Redistribution Platform

Flutter Firebase PHP License

MealDeal is a comprehensive food surplus redistribution platform that connects food providers (restaurants, cafes, bakeries) with consumers to reduce food waste and provide affordable meals. The platform includes a Flutter mobile app, PHP backend services, and a web admin dashboard.

🌟 Key Features

πŸ“± Mobile App (Flutter)

  • Dual Role System: Food providers and consumers with role-based interfaces
  • Real-time Messaging: In-app chat system for communication
  • Location Services: GPS-based pickup location management
  • Image Upload: Photo capture for food listings
  • Push Notifications: Real-time updates and alerts
  • Order Management: Complete order lifecycle tracking
  • Analytics Dashboard: Provider performance metrics

🌐 Web Admin Dashboard

  • User Management: Comprehensive user account administration
  • Report System: Content moderation and user reporting
  • Leaderboard: Gamified ranking system for top performers
  • Impact Tracking: Food waste reduction metrics
  • Pricing Control: Automated discount enforcement (50% minimum)
  • Analytics: Real-time statistics and insights

πŸ”§ Backend Services (PHP)

  • Firebase Integration: Cloud Firestore database
  • Authentication: Secure user authentication and authorization
  • API Endpoints: RESTful services for mobile and web clients
  • Validation: Input validation and security measures
  • File Management: Image upload and storage handling

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Flutter App   β”‚    β”‚  Web Admin      β”‚    β”‚  PHP Backend    β”‚
β”‚   (Mobile)      │◄──►│  Dashboard      │◄──►│  Services       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Firebase      β”‚
                    β”‚   (Database)    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

MealDeal/
β”œβ”€β”€ flutter_application_1/          # Flutter mobile application
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ features/              # Feature-based architecture
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication screens & logic
β”‚   β”‚   β”‚   β”œβ”€β”€ consumer/          # Consumer-specific features
β”‚   β”‚   β”‚   β”œβ”€β”€ provider/          # Provider-specific features
β”‚   β”‚   β”‚   β”œβ”€β”€ messaging/         # Chat and messaging system
β”‚   β”‚   β”‚   └── welcome/           # Onboarding screens
β”‚   β”‚   β”œβ”€β”€ services/             # Business logic services
β”‚   β”‚   β”‚   β”œβ”€β”€ firestore_helper.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ geo_service.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ location_service.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ messaging_service.dart
β”‚   β”‚   β”‚   └── routing_service.dart
β”‚   β”‚   β”œβ”€β”€ models/               # Data models
β”‚   β”‚   β”‚   └── message.dart
β”‚   β”‚   β”œβ”€β”€ providers/            # State management providers
β”‚   β”‚   β”œβ”€β”€ screens/              # Screen components
β”‚   β”‚   β”œβ”€β”€ theme/                # App theming
β”‚   β”‚   β”‚   └── app_theme.dart
β”‚   β”‚   β”œβ”€β”€ widgets/              # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ firebase_options.dart  # Firebase configuration
β”‚   β”‚   └── main.dart             # App entry point
β”‚   β”œβ”€β”€ android/                  # Android platform configuration
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ build.gradle
β”‚   β”‚   β”‚   β”œβ”€β”€ google-services.json
β”‚   β”‚   β”‚   └── src/              # Android source files
β”‚   β”‚   └── gradle/                # Gradle wrapper
β”‚   β”œβ”€β”€ ios/                      # iOS platform configuration
β”‚   β”‚   β”œβ”€β”€ Runner/
β”‚   β”‚   β”‚   β”œβ”€β”€ AppDelegate.swift
β”‚   β”‚   β”‚   └── Assets.xcassets/
β”‚   β”‚   └── Runner.xcodeproj/
β”‚   β”œβ”€β”€ web/                      # Web platform files
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   └── manifest.json
β”‚   β”œβ”€β”€ backend/                  # PHP backend services (legacy)
β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication services
β”‚   β”‚   β”‚   └── validate_role.php
β”‚   β”‚   β”œβ”€β”€ cart/                 # Shopping cart logic
β”‚   β”‚   β”‚   └── validate_checkout.php
β”‚   β”‚   β”œβ”€β”€ listings/             # Food listing management
β”‚   β”‚   β”‚   β”œβ”€β”€ report.php
β”‚   β”‚   β”‚   β”œβ”€β”€ safety_check.php
β”‚   β”‚   β”‚   └── validate.php
β”‚   β”‚   β”œβ”€β”€ config/               # Firebase configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ firebase_config.php
β”‚   β”‚   β”‚   └── mealdeal-10385-firebase-adminsdk-*.json
β”‚   β”‚   └── test/                 # Backend tests
β”‚   β”œβ”€β”€ php_auth/                 # PHP authentication module
β”‚   β”‚   β”œβ”€β”€ public/              # Public API endpoints
β”‚   β”‚   β”œβ”€β”€ src/                 # Source files
β”‚   β”‚   β”‚   └── AuthHandler.php
β”‚   β”‚   └── config/              # Configuration
β”‚   β”œβ”€β”€ docs/                     # Documentation
β”‚   β”œβ”€β”€ backups/                  # Backup files
β”‚   β”œβ”€β”€ firebase.json             # Firebase hosting config
β”‚   β”œβ”€β”€ firestore.rules           # Firestore security rules
β”‚   β”œβ”€β”€ firestore.indexes.json    # Firestore indexes
β”‚   β”œβ”€β”€ pubspec.yaml              # Flutter dependencies
β”‚   β”œβ”€β”€ BUILD_APK_GUIDE.md        # Build instructions
β”‚   β”œβ”€β”€ FIREBASE_VERIFICATION_SETUP.md
β”‚   β”œβ”€β”€ HOT_RELOAD_GUIDE.md
β”‚   └── TROUBLESHOOTING.md
β”‚
β”œβ”€β”€ web_admin/                     # Web admin dashboard
β”‚   β”œβ”€β”€ assets/                   # Static assets
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”‚   └── admin.css         # Centralized admin styles
β”‚   β”‚   └── js/
β”‚   β”‚       β”œβ”€β”€ admin.js
β”‚   β”‚       β”œβ”€β”€ leaderboard.js    # Leaderboard charts
β”‚   β”‚       └── reports.js
β”‚   β”œβ”€β”€ api/                      # API endpoints
β”‚   β”‚   β”œβ”€β”€ dashboard_stats.php
β”‚   β”‚   β”œβ”€β”€ get_ai_analysis.php
β”‚   β”‚   β”œβ”€β”€ get_comprehensive_stats.php
β”‚   β”‚   β”œβ”€β”€ get_disputes.php
β”‚   β”‚   β”œβ”€β”€ get_listings.php
β”‚   β”‚   β”œβ”€β”€ get_pricing_alerts.php
β”‚   β”‚   β”œβ”€β”€ get_recent_flags.php
β”‚   β”‚   β”œβ”€β”€ get_report_details.php
β”‚   β”‚   β”œβ”€β”€ get_user_contributions.php
β”‚   β”‚   └── get_users.php
β”‚   β”œβ”€β”€ config/                   # Configuration files
β”‚   β”‚   β”œβ”€β”€ database.php          # Database configuration
β”‚   β”‚   └── firebase-credentials.json
β”‚   β”œβ”€β”€ includes/                 # Shared PHP includes
β”‚   β”‚   β”œβ”€β”€ auth.php              # Authentication helpers
β”‚   β”‚   β”œβ”€β”€ cache.php             # Caching functions
β”‚   β”‚   β”œβ”€β”€ data_functions.php     # Data manipulation
β”‚   β”‚   β”œβ”€β”€ firestore_rest_adapter.php
β”‚   β”‚   β”œβ”€β”€ refresh_cache.php
β”‚   β”‚   └── stats.php             # Statistics functions
β”‚   β”œβ”€β”€ partials/                 # Reusable partials
β”‚   β”‚   └── header.php            # Header navigation
β”‚   β”œβ”€β”€ cron/                      # Scheduled tasks
β”‚   β”‚   β”œβ”€β”€ build_stats.php
β”‚   β”‚   β”œβ”€β”€ update_leaderboard_aggregates.php
β”‚   β”‚   └── stats_cache.json
β”‚   β”œβ”€β”€ index.php                 # Main dashboard
β”‚   β”œβ”€β”€ dashboard.php             # Dashboard page
β”‚   β”œβ”€β”€ login.php                  # Admin login
β”‚   β”œβ”€β”€ logout.php                 # Logout handler
β”‚   β”œβ”€β”€ users.php                  # User management
β”‚   β”œβ”€β”€ listings.php               # Content moderation
β”‚   β”œβ”€β”€ reports.php                # Report management
β”‚   β”œβ”€β”€ leaderboard.php            # Leaderboard page
β”‚   β”œβ”€β”€ impact.php                 # Impact tracking
β”‚   β”œβ”€β”€ pricing.php                # Pricing control
β”‚   β”œβ”€β”€ create_admin.php           # Admin account creation
β”‚   β”œβ”€β”€ composer.json              # PHP dependencies
β”‚   └── README.md                   # Admin documentation
β”‚
β”œβ”€β”€ CLEANUP_SUMMARY.md             # Project cleanup notes
└── README.md                      # This file

πŸš€ Getting Started

Prerequisites

  • Flutter SDK (3.6.0 or higher)
  • Dart SDK (3.0.0 or higher)
  • PHP (7.4 or higher)
  • Composer (for PHP dependencies)
  • Firebase Project with Firestore enabled
  • Android Studio or Xcode (for mobile development)

Installation

1. Clone the Repository

git clone https://github.com/UNIIIIK/MealDeal.git
cd MealDeal

2. Flutter Mobile App Setup

cd flutter_application_1

# Install Flutter dependencies
flutter pub get

# Configure Firebase
# 1. Create a Firebase project at https://console.firebase.google.com/
# 2. Enable Authentication and Firestore
# 3. Download google-services.json (Android) and GoogleService-Info.plist (iOS)
# 4. Place them in android/app/ and ios/Runner/ respectively

# Run the app
flutter run

3. Web Admin Dashboard Setup

cd web_admin

# Install PHP dependencies
composer install

# Configure Firebase
# 1. Download Firebase service account key from Firebase Console
# 2. Save as config/firebase-credentials.json
# 3. Update config/database.php with your Firebase project ID

# Start local server
php -S localhost:8000

4. Backend Services Setup

cd backend

# Install PHP dependencies
composer install

# Configure Firebase credentials
# Copy your Firebase service account key to config/firebase-credentials.json

πŸ”§ Configuration

Firebase Setup

  1. Create Firebase Project:

    • Go to Firebase Console
    • Create a new project named "MealDeal"
    • Enable Authentication (Email/Password)
    • Enable Firestore Database
  2. Configure Authentication:

    • Enable Email/Password authentication
    • Set up custom claims for user roles
    • Configure security rules
  3. Firestore Security Rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users can read/write their own data
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
    
    // Listings are readable by all authenticated users
    match /listings/{listingId} {
      allow read: if request.auth != null;
      allow write: if request.auth != null && 
        request.auth.uid == resource.data.provider_id;
    }
    
    // Cart items are user-specific
    match /cart/{cartId} {
      allow read, write: if request.auth != null && 
        request.auth.uid == resource.data.consumer_id;
    }
  }
}

Environment Variables

Create a .env file in the root directory:

FIREBASE_PROJECT_ID=your-project-id
FIREBASE_API_KEY=your-api-key
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_STORAGE_BUCKET=your-project.appspot.com

πŸ“± Mobile App Features

For Food Providers

  • Create Listings: Upload photos and details of surplus food
  • Manage Orders: Track and fulfill customer orders
  • Analytics: View performance metrics and earnings
  • Location Management: Set up pickup locations
  • Messaging: Communicate with customers

For Food Consumers

  • Browse Listings: Discover available food deals
  • Place Orders: Add items to cart and checkout
  • Track Orders: Monitor order status and pickup details
  • Messaging: Chat with food providers
  • Order History: View past purchases

🌐 Web Admin Features

Dashboard

  • Real-time Statistics: User counts, active listings, reports
  • Quick Actions: Review reports, manage users, moderate content

User Management

  • Account Administration: View, edit, suspend user accounts
  • Role Management: Assign provider/consumer roles
  • Dispute Resolution: Handle user conflicts

Content Moderation

  • Report Review: Process user-generated reports
  • Warning System: Issue warnings and bans
  • Content Verification: Manual and automated checks

Analytics

  • Impact Metrics: Track food waste reduction
  • User Engagement: Monitor platform usage
  • Performance Reports: Generate insights and reports

πŸ” Security Features

  • Authentication: Firebase Auth with custom claims
  • Authorization: Role-based access control
  • Input Validation: XSS and injection prevention
  • File Upload Security: Image validation and virus scanning
  • API Security: Rate limiting and request validation
  • Data Encryption: Secure data transmission and storage

πŸ§ͺ Testing

Flutter App Testing

cd flutter_application_1

# Run unit tests
flutter test

# Run integration tests
flutter test integration_test/

# Run widget tests
flutter test test/

PHP Backend Testing

cd backend

# Run PHP unit tests
vendor/bin/phpunit

# Test API endpoints
php test/firebase_test.php

πŸš€ Deployment

Mobile App Deployment

Android

cd flutter_application_1

# Build APK
flutter build apk --release

# Build App Bundle
flutter build appbundle --release

iOS

cd flutter_application_1

# Build iOS app
flutter build ios --release

Web Admin Deployment

  1. Upload files to web server
  2. Configure web server (Apache/Nginx)
  3. Set up SSL certificate
  4. Configure environment variables
  5. Test all functionality

Backend Services Deployment

  1. Deploy PHP files to web server
  2. Configure PHP settings
  3. Set up cron jobs for scheduled tasks
  4. Monitor logs and performance

πŸ“Š Performance Optimization

Mobile App

  • Image Optimization: Compress and resize images
  • Lazy Loading: Load content on demand
  • Caching: Implement local caching strategies
  • Code Splitting: Reduce app bundle size

Web Admin

  • CDN: Use CDN for static assets
  • Caching: Implement Redis/Memcached
  • Database: Optimize Firestore queries
  • Compression: Enable gzip compression

🀝 Contributing

  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

Development Guidelines

  • Follow Flutter/Dart style guidelines
  • Write comprehensive tests
  • Update documentation
  • Follow semantic versioning
  • Use conventional commits

πŸ“ˆ Roadmap

Phase 1 (Current)

  • βœ… Basic mobile app functionality
  • βœ… Web admin dashboard
  • βœ… Firebase integration
  • βœ… User authentication

Phase 2 (Planned)

  • πŸ”„ Push notifications
  • πŸ”„ Payment integration
  • πŸ”„ Advanced analytics
  • πŸ”„ Multi-language support

Phase 3 (Future)

  • πŸ“… AI-powered recommendations
  • πŸ“… Social features
  • πŸ“… API for third-party integrations
  • πŸ“… Advanced reporting tools

πŸ› Known Issues

  • Image upload may fail on slow connections
  • Push notifications require device registration
  • Some UI elements may not be fully responsive
  • Offline functionality is limited

πŸ“ž Support

πŸ“„ License

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

πŸ™ Development Team

  • Project Lead: Heinz Khervie Tobias
  • Backend Development: Elizar James MuΓ±ez Sanchez
  • Frontend Development: Emarie Dosdos Tulod
  • System Analyst: Joshua Daligdig Cortes

πŸ“Š Project Statistics

  • Languages: Dart (65.6%), PHP (24.3%), C++ (3.2%), JavaScript (1.4%)
  • Lines of Code: 15,000+ lines
  • Features: 25+ major features
  • Platforms: Android, iOS, Web
  • Database: Firebase Firestore

Built with ❀️ for reducing food waste and helping the environment

MealDeal - Making surplus food accessible to everyone

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published