# SMART FOOD ORDERING SYSTEM ## Complete Production-Ready Food Ordering Platform --- ## 📋 PROJECT OVERVIEW **Smart Food Ordering System** is a complete, modern, and production-ready food ordering platform consisting of: 1. **Admin Web Dashboard** - PHP, MySQL, Tailwind CSS 2. **Mobile Application** - Flutter, Dart 3. **REST API Backend** - PHP with PDO ### Key Features - Real-time order management - Secure authentication system - Modern responsive UI/UX - Complete CRUD operations - Order tracking system - Payment management - Reports and analytics - Push notifications - Cart management - Category and food management --- ## 🎯 SYSTEM ARCHITECTURE ### Technology Stack #### Admin Web System - **Backend**: PHP 7.4+ - **Database**: MySQL 5.7+ - **Frontend**: Tailwind CSS 3.x - **JavaScript**: Vanilla JS - **Server**: Apache (XAMPP) #### Mobile Application - **Framework**: Flutter 3.x - **Language**: Dart 3.x - **State Management**: Provider - **HTTP Client**: http package - **Local Storage**: SharedPreferences #### API Backend - **Language**: PHP - **Database Access**: PDO (Prepared Statements) - **Response Format**: JSON - **Authentication**: Session-based (Admin), Token-based (Mobile) --- ## 📁 PROJECT STRUCTURE ### PHP Backend Structure ``` food/ ├── config/ │ ├── config.php # Application configuration │ └── database.php # Database connection ├── includes/ │ ├── functions.php # Helper functions │ └── auth.php # Authentication middleware ├── admin/ │ ├── login.php # Admin login │ ├── index.php # Dashboard │ ├── logout.php # Logout handler │ ├── includes/ │ │ ├── sidebar.php # Sidebar navigation │ │ └── topbar.php # Top navigation │ └── pages/ │ ├── categories.php # Category management │ ├── foods.php # Food management │ ├── orders.php # Order management │ ├── customers.php # Customer management │ ├── payments.php # Payment management │ ├── promos.php # Promo management │ ├── reports.php # Reports │ └── settings.php # Settings ├── api/ │ ├── login.php # User login API │ ├── register.php # User registration API │ ├── categories.php # Categories API │ ├── foods.php # Foods API │ ├── food_details.php # Food details API │ ├── cart.php # Cart management API │ ├── place_order.php # Place order API │ ├── orders.php # Orders API │ ├── order_details.php # Order details API │ ├── update_profile.php # Update profile API │ ├── notifications.php # Notifications API │ ├── promos.php # Promos API │ └── settings.php # Settings API ├── uploads/ │ ├── categories/ # Category images │ ├── foods/ # Food images │ ├── promos/ # Promo images │ ├── payments/ # Payment proofs │ └── profiles/ # Profile images ├── assets/ │ ├── css/ # Custom CSS │ ├── js/ # Custom JavaScript │ └── images/ # Static images └── database/ └── schema.sql # Database schema ``` ### Flutter App Structure ``` flutter_app/ ├── lib/ │ ├── main.dart # App entry point │ ├── constants/ │ │ └── app_constants.dart # App constants │ ├── models/ │ │ ├── user.dart # User model │ │ ├── food.dart # Food model │ │ ├── category.dart # Category model │ │ ├── cart_item.dart # Cart item model │ │ └── order.dart # Order model │ ├── providers/ │ │ ├── auth_provider.dart # Authentication state │ │ └── cart_provider.dart # Cart state │ ├── services/ │ │ └── api_service.dart # API service │ ├── screens/ │ │ ├── splash_screen.dart # Splash screen │ │ ├── login_screen.dart # Login screen │ │ ├── register_screen.dart # Register screen │ │ ├── home_screen.dart # Home screen │ │ ├── food_details_screen.dart │ │ ├── cart_screen.dart │ │ ├── checkout_screen.dart │ │ ├── orders_screen.dart │ │ ├── order_tracking_screen.dart │ │ └── profile_screen.dart │ ├── widgets/ │ │ ├── food_card.dart │ │ ├── category_chip.dart │ │ └── order_card.dart │ └── utils/ │ └── helpers.dart └── pubspec.yaml # Dependencies ``` --- ## 🗄️ DATABASE SCHEMA ### Tables Overview 1. **admins** - Admin user accounts 2. **users** - Customer accounts 3. **categories** - Food categories 4. **foods** - Food items 5. **orders** - Customer orders 6. **order_items** - Order line items 7. **payments** - Payment records 8. **promos** - Promotional offers 9. **notifications** - User notifications 10. **settings** - Application settings 11. **reviews** - Food reviews 12. **cart** - Shopping cart 13. **order_status_history** - Order status tracking ### Key Relationships - `foods.category_id` → `categories.id` - `orders.user_id` → `users.id` - `order_items.order_id` → `orders.id` - `order_items.food_id` → `foods.id` - `payments.order_id` → `orders.id` - `cart.user_id` → `users.id` - `cart.food_id` → `foods.id` --- ## 🔌 API ENDPOINTS ### Authentication - `POST /api/login.php` - User login - `POST /api/register.php` - User registration ### Categories - `GET /api/categories.php` - Fetch all categories ### Foods - `GET /api/foods.php` - Fetch foods (with filters) - `GET /api/food_details.php?id={id}` - Fetch food details ### Cart - `GET /api/cart.php?user_id={id}` - Fetch cart items - `POST /api/cart.php` - Add to cart - `PUT /api/cart.php` - Update cart item - `DELETE /api/cart.php?cart_id={id}` - Remove from cart ### Orders - `POST /api/place_order.php` - Place new order - `GET /api/orders.php?user_id={id}` - Fetch user orders - `GET /api/order_details.php?order_id={id}` - Fetch order details ### Profile - `POST /api/update_profile.php` - Update user profile ### Notifications - `GET /api/notifications.php?user_id={id}` - Fetch notifications ### Promos - `GET /api/promos.php` - Fetch active promos ### Settings - `GET /api/settings.php` - Fetch app settings --- ## 🚀 INSTALLATION GUIDE ### Prerequisites - XAMPP (Apache + MySQL + PHP 7.4+) - Flutter SDK 3.x - Android Studio / VS Code - Git ### Backend Setup 1. **Install XAMPP** - Download from https://www.apachefriends.org/ - Install and start Apache and MySQL 2. **Setup Project** ```bash cd C:\xampp\htdocs\ # Copy the 'food' folder here ``` 3. **Create Database** - Open phpMyAdmin: http://localhost/phpmyadmin - Create database: `smart_food_ordering` - Import: `database/schema.sql` 4. **Configure Database** - Edit `config/database.php` - Update credentials if needed 5. **Set Permissions** - Ensure `uploads/` folder is writable 6. **Access Admin Panel** - URL: http://localhost/food/admin/ - Username: `admin` - Password: `admin123` ### Flutter App Setup 1. **Install Flutter** ```bash # Download Flutter SDK # Add to PATH flutter doctor ``` 2. **Setup Project** ```bash cd C:\xampp\htdocs\food\flutter_app flutter pub get ``` 3. **Configure API URL** - Edit `lib/constants/app_constants.dart` - Update `baseUrl` to your server IP - For Android Emulator: `http://10.0.2.2/food/` - For Physical Device: `http://YOUR_IP/food/` 4. **Run Application** ```bash flutter run ``` --- ## 👥 USER ROLES ### Admin - Full system access - Manage categories, foods, orders - View reports and analytics - Manage customers - Configure settings ### Customer (Mobile App) - Browse foods - Add to cart - Place orders - Track orders - Manage profile - View notifications --- ## 🔐 SECURITY FEATURES 1. **Password Security** - Bcrypt hashing (cost: 10) - Minimum 6 characters 2. **SQL Injection Prevention** - PDO prepared statements - Parameter binding 3. **XSS Prevention** - Input sanitization - HTML special chars encoding 4. **Session Security** - HTTP-only cookies - Session timeout - CSRF protection ready 5. **File Upload Security** - File type validation - File size limits (5MB) - Unique filename generation 6. **API Security** - Input validation - Error handling - Rate limiting ready --- ## 📊 ADMIN FEATURES ### Dashboard - Total orders count - Pending orders - Completed orders - Total sales - Today's sales - Recent orders list - Best-selling foods - Sales charts ### Category Management - Add/Edit/Delete categories - Upload category images - Set display order - Active/Inactive status ### Food Management - Add/Edit/Delete foods - Upload food images - Set price and description - Mark as featured - Set availability - Preparation time - Calorie information ### Order Management - View all orders - Order details - Update order status: - Pending - Accepted - Preparing - Ready for Pickup - Out for Delivery - Completed - Cancelled - Customer information - Order items list ### Customer Management - View all customers - Customer details - Order history - Account status - Search and filter ### Payment Management - View all payments - Payment status - Payment method - Transaction details - Proof of payment ### Reports - Daily sales - Weekly sales - Monthly sales - Best-selling products - Order statistics - Revenue reports ### Promo Management - Add/Edit/Delete promos - Upload promo images - Set discount value - Promo code - Start/End dates - Usage limits ### Settings - Restaurant name - Logo upload - Contact information - Address - Operating hours - Delivery fee - Minimum order amount --- ## 📱 MOBILE APP FEATURES ### Authentication - User registration - Login - Forgot password - Auto-login ### Home Screen - Search foods - Browse categories - Featured foods - Popular foods - Promo banners ### Food Details - Food image - Name and description - Price - Preparation time - Calories - Rating and reviews - Quantity selector - Add to cart ### Cart - View cart items - Update quantity - Remove items - Subtotal calculation - Delivery fee - Total amount ### Checkout - Delivery address - Contact number - Payment method selection - Order summary - Place order ### Orders - My orders list - Filter by status - Order details - Order tracking ### Order Tracking - Real-time status - Status timeline: - Pending - Accepted - Preparing - Out for Delivery - Completed ### Profile - View profile - Edit profile - Change password - Logout ### Notifications - Order updates - Promo announcements - System notifications --- ## 🎨 UI/UX DESIGN ### Admin Web Design - **Framework**: Tailwind CSS - **Layout**: Sidebar + Topbar - **Color Scheme**: Orange/Red gradient - **Components**: - Dashboard cards - Data tables - Modal forms - Status badges - Charts - **Responsive**: Mobile, Tablet, Desktop ### Mobile App Design - **Style**: Modern Material Design - **Color Scheme**: Orange (#FF6B35) primary - **Components**: - Bottom navigation - Food cards - Category chips - Order cards - Status badges - **Animations**: Smooth transitions - **Typography**: Clean and readable --- ## 🔄 SYSTEM FLOW ### Order Flow 1. Customer browses foods 2. Adds items to cart 3. Proceeds to checkout 4. Enters delivery details 5. Selects payment method 6. Places order 7. Admin receives notification 8. Admin accepts order 9. Admin updates status (Preparing → Ready → Out for Delivery) 10. Customer receives notifications 11. Order completed 12. Customer can review ### Payment Flow 1. Customer selects payment method 2. For COD: Order placed directly 3. For GCash: Upload proof of payment 4. Admin verifies payment 5. Updates payment status 6. Processes order --- ## 📈 DEVELOPMENT ROADMAP ### Phase 1: Core Features ✅ - User authentication - Food browsing - Cart management - Order placement - Admin dashboard - Order management ### Phase 2: Enhanced Features - Real-time notifications (Firebase) - Order tracking with map - Multiple addresses - Favorites/Wishlist - Food reviews and ratings - Promo code application ### Phase 3: Advanced Features - Online payment integration (PayMongo, PayPal) - Delivery tracking (GPS) - Chat support - Loyalty points - Referral system - Multi-restaurant support ### Phase 4: Analytics & Optimization - Advanced analytics - Customer insights - Inventory management - Staff management - Performance optimization - SEO optimization --- ## 🛡️ BEST PRACTICES ### Code Quality - Follow PSR standards (PHP) - Use meaningful variable names - Comment complex logic - Consistent code formatting - Error handling ### Security - Never store plain passwords - Validate all inputs - Use prepared statements - Implement CSRF tokens - Regular security audits ### Performance - Optimize database queries - Use indexes - Implement caching - Compress images - Minify CSS/JS ### Testing - Unit testing - Integration testing - User acceptance testing - Load testing - Security testing --- ## 🐛 TROUBLESHOOTING ### Common Issues **Database Connection Error** - Check MySQL is running - Verify database credentials - Ensure database exists **API Not Working** - Check Apache is running - Verify API URL in Flutter app - Check CORS settings - Enable error reporting **Images Not Uploading** - Check folder permissions - Verify file size limits - Check allowed file types **Flutter Build Errors** - Run `flutter clean` - Run `flutter pub get` - Check Flutter version --- ## 📞 SUPPORT & CONTACT For issues, questions, or contributions: - Email: support@smartfood.com - Documentation: /docs - GitHub: [repository-url] --- ## 📄 LICENSE This project is proprietary software developed for Smart Food Ordering System. All rights reserved © 2024 --- ## 🙏 ACKNOWLEDGMENTS - Tailwind CSS for beautiful UI components - Flutter team for amazing framework - PHP community for robust backend - Open source contributors --- **Version**: 1.0.0 **Last Updated**: 2024 **Status**: Production Ready ✅