← Back to Documentation Home

Architecture & Flow Diagrams

A technical and operational guide detailing how the Flutter Customer App, Laravel REST API, MySQL database, and Admin Web Portal interact across all primary platform workflows.

Architecture & Flow Diagrams

A technical and operational guide detailing how the Flutter Customer App, Laravel REST API, MySQL database, and Admin Web Portal interact across all primary platform workflows.

Table of Contents
  1. System Topography
  2. Authentication & OTP Registration
  3. Order Placement & Checkout Lifecycle
  4. Order Dispatch & Delivery Logistics
  5. Wallet Ledger & Vendor Withdrawal Lifecycle
  6. Compliance Penalty & Dispute Resolution
1 Overview

System Topography#

The Flutter Customer App and Admin Panel operate as distinct client interfaces that interact strictly through Laravel's secure, token-authenticated REST API layer.

[Flutter Customer App]  <--- HTTPS / Bearer Token --->  [Laravel REST API v1]  <--- PDO --->  [MySQL 8.0+ Database]
                                                                  ^
                                                                  | Session Auth
                                                        [Admin & Vendor Portal]
How to read flow diagrams in this section: Each diagram represents a major operational sequence. Follow the sequentially numbered badges (1, 2, 3...) from top to bottom. Decision diamonds represent logical forks where the system checks prerequisites (e.g., OTP validity, store operating status, or payment authorization) before proceeding.

2 Flow Diagram

Authentication & OTP Registration#

The customer onboarding, phone OTP dispatch, credential verification, and Sanctum session token issuance flow.

Authentication and OTP registration flow diagram
Figure 1: Authentication & OTP Verification Flow — Applies whenever a customer signs up or verifies their phone identity.
sequenceDiagram autonumber actor User as Customer participant App as Flutter App participant API as Laravel REST API participant SMS as SMS / SMTP Gateway participant DB as MySQL Database User->>App: 1. Enter Mobile Number / Email App->>API: 2. POST /api/sendRegistrationCode API->>DB: 3. Verify phone uniqueness & store hashed OTP alt Phone Already Registered API-->>App: 4a. Return 422: Phone already in use App-->>User: Show login suggestion else Phone Available API->>SMS: 4b. Dispatch 6-digit OTP code API-->>App: Return 200: OTP Sent User->>App: 5. Submit 6-digit OTP App->>API: 6. POST /api/verifyRegistrationCode alt Invalid or Expired Code API-->>App: Return 400: Invalid / expired OTP else Valid Code API->>DB: Create User record & generate Sanctum Token API-->>App: Return 200: Bearer Token + User Object App->>App: Store token securely & route to Home Screen end end

Numbered Callout Legend:

  • 1 Input Collection: Customer enters phone number and country prefix on Flutter registration screen.
  • 2 API Request: App triggers POST /api/sendRegistrationCode with input payload.
  • 3 Database Audit: Backend checks users table. If number is already registered, an error is returned; otherwise a random 6-digit OTP is generated with a 5-minute expiry.
  • 4 OTP Transmission: Verification code is dispatched via SMS/SMTP to customer's device.
  • 5 Code Verification: Customer enters code; app sends POST /api/verifyRegistrationCode.
  • 6 Session Creation: Upon successful match, backend creates user row, provisions personal wallet, and returns an encrypted Sanctum Bearer Token.

3 Flow Diagram

Order Placement & Checkout Lifecycle#

From cart validation through payment authorization (Wallet, COD, Stripe, PayPal) to order persistence and store notification.

Order placement and checkout flow diagram
Figure 2: Order Placement Flow — Applies during checkout across all payment options.
flowchart TD A([1. Customer Clicks Checkout]) --> B[2. Validate Cart & Delivery Address] B --> C{3. Restaurant Open & In Delivery Zone?} C -- No --> D[Return Error: Store Closed / Out of Range] C -- Yes --> E[4. Apply Coupon & Calculate Taxes] E --> F{5. Payment Method Selected} F -- Wallet Balance --> G[Check Wallet Funds] G -- Sufficient --> H[Deduct Wallet & Create Order] G -- Insufficient --> I[Prompt Customer to Top-Up] F -- Cash on Delivery --> J[Create Order with status=pending] F -- Stripe / PayPal --> K[6. Redirect to Payment Gateway] K -- Success --> L[Server Validates Webhook / Capture Token] L --> M[Mark Order Paid & status=confirmed] K -- Cancel / Fail --> N[Return to Checkout with Retry Option] H --> O([7. Broadcast FCM Notification to Store & Admin]) J --> O M --> O

Numbered Callout Legend:

  • 1 Checkout Trigger: Customer reviews basket and initiates checkout on Flutter mobile app.
  • 2 Item & Address Validation: App submits selected delivery address ID and cart item IDs to POST /api/checkout.
  • 3 Zone & Schedule Check: Backend verifies that the destination coordinates fall inside the store's assigned Google Maps polygon zone and the store is currently within working hours.
  • 4 Financial Calculation: Subtotal, base delivery fee, per-km surcharge, zone tax, and coupon discount are computed server-side.
  • 5 Payment Resolution:
    • Wallet: Atomic balance deduction in user_wallets table.
    • Cash on Delivery: Order stored immediately with payment_method='cod'.
    • Stripe / PayPal: Client redirected to secure webview; server verifies cryptographic payment intent/capture before confirming.
  • 6 Dispatch Alert: Database emits an order event triggering Firebase Cloud Messaging (FCM) notifications to the restaurant manager and platform admin dashboard.

4 Flow Diagram

Order Dispatch & Delivery Logistics#

How active orders are assigned to available deliverymen, accepted, picked up from the kitchen, and completed at customer doorstep.

Order dispatch and rider lifecycle flow diagram
Figure 3: Order Dispatch & Delivery Logistics Flow — Applies from kitchen prep to final customer handover.
stateDiagram-v2 [*] --> Pending: Customer Places Order Pending --> Confirmed: Store / Admin Accepts Order Confirmed --> Cooking: Kitchen Begins Preparation Cooking --> ReadyForPickup: Food Packed & Ready ReadyForPickup --> RiderAssigned: Admin Assigns Available Driver RiderAssigned --> OutForDelivery: Rider Collects Food & Verifies OutForDelivery --> Delivered: Drop-off Complete & COD Collected Delivered --> [*]

Numbered Callout Legend:

  • 1 Order Confirmation: Restaurant acknowledges order via web dashboard; status updates to confirmed.
  • 2 Kitchen Preparation: Kitchen prepares food; status updates to processing in customer app.
  • 3 Rider Assignment: Dispatcher assigns available deliveryman via Admin Console (/orders/unassigned).
  • 4 Pickup Verification: Rider arrives at store, collects package, and status transitions to out_for_delivery.
  • 5 Doorstep Delivery: Rider delivers package to customer, collects COD cash if applicable, and confirms completion.
  • 6 Wallet Settlement: System automatically credits delivery fee to rider wallet and commission to platform ledger.

5 Flow Diagram

Wallet Ledger & Vendor Withdrawal Lifecycle#

How merchant earnings accumulate in escrow, commission slabs are deducted, and withdrawal payout requests are processed.

Wallet, commission and withdrawal flow diagram
Figure 4: Wallet & Payout Lifecycle — Applies to vendor earnings and withdrawal audits.
flowchart LR A[Order Delivered] --> B[Calculate Gross Total] B --> C[Deduct Platform Commission] C --> D[Credit Vendor Escrow Wallet] D --> E{Vendor Requests Withdrawal} E --> F[Admin Reviews Bank / PayPal Details] F -- Approved --> G[Mark Paid & Deduct Wallet] F -- Rejected --> H[Restore Funds & Send Reason]

Numbered Callout Legend:

  • 1 Earnings Accrual: Upon order delivery, gross dish subtotal is registered in vendor_wallets table.
  • 2 Commission Deduction: Platform commission percentage (or commission slab rate) is routed to company account.
  • 3 Withdrawal Submission: Merchant requests payout to their registered bank account or PayPal email via Vendor Dashboard.
  • 4 Admin Audit: Super Admin inspects pending requests at /vendor-withdrawals.
  • 5 Payout Settlement: Upon manual bank transfer, admin marks request as approved, finalizing the transaction ledger.

6 Flow Diagram

Compliance Penalty & Dispute Resolution#

The administrative violation enforcement workflow for order delivery breaches, rider appeal submission, and supervisor arbitration.

Penalty and dispute resolution flow diagram
Figure 5: Penalty & Dispute Resolution Flow — Applies to driver disciplinary audits and appeals.
flowchart TD A[Rider Breach Detected: Late / Cancellation] --> B[System or Admin Logs Penalty] B --> C[Penalty Amount Deducted from Rider Wallet] C --> D{Rider Accepts or Appeals?} D -- Accepts --> E[Penalty Settled] D -- Submits Appeal --> F[Rider Uploads Proof & Explanation] F --> G[Admin Reviews Dispute at /disputes] G -- Dispute Approved --> H[Penalty Waived & Funds Refunded] G -- Dispute Rejected --> I[Penalty Upheld]

Numbered Callout Legend:

  • 1 Violation Event: Incident recorded (excessive delivery delay, unfulfilled order, or customer complaint).
  • 2 Penalty Assessment: Fixed fine or percentage deduction logged in penalty_applications table.
  • 3 Dispute Filing: Driver submits formal appeal via API with photographic evidence or timestamp logs.
  • 4 Administrative Hearing: Operations manager reviews explanation at Admin Panel /disputes.
  • 5 Resolution: If justified, penalty is waived and wallet balance refunded; otherwise penalty is permanently closed.
FoodFeast · Architecture & Flow Diagrams v1.0 · © FoodFeast