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
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]
Authentication & OTP Registration#
The customer onboarding, phone OTP dispatch, credential verification, and Sanctum session token issuance flow.
Numbered Callout Legend:
- 1 Input Collection: Customer enters phone number and country prefix on Flutter registration screen.
- 2 API Request: App triggers
POST /api/sendRegistrationCodewith input payload. - 3 Database Audit: Backend checks
userstable. 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.
Order Placement & Checkout Lifecycle#
From cart validation through payment authorization (Wallet, COD, Stripe, PayPal) to order persistence and store notification.
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 inuser_walletstable.
• Cash on Delivery: Order stored immediately withpayment_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.
Order Dispatch & Delivery Logistics#
How active orders are assigned to available deliverymen, accepted, picked up from the kitchen, and completed at customer doorstep.
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
processingin 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.
Wallet Ledger & Vendor Withdrawal Lifecycle#
How merchant earnings accumulate in escrow, commission slabs are deducted, and withdrawal payout requests are processed.
Numbered Callout Legend:
- 1 Earnings Accrual: Upon order delivery, gross dish subtotal is registered in
vendor_walletstable. - 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.
Compliance Penalty & Dispute Resolution#
The administrative violation enforcement workflow for order delivery breaches, rider appeal submission, and supervisor arbitration.
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_applicationstable. - 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.