API & Integration

27. API & Integration Points

This section maps the external services Foodie integrates with and where each one is configured, so developers can extend or replace them. Every client — the mobile apps, the Admin Panel, the Restaurant Panel and the Website Panel — talks to the same Google Firebase backend.

27.1. Architecture at a glance

  • Flutter apps → Firebase directly (Firestore, Auth, Storage, FCM, Realtime Database for live tracking).
  • Website Panel → Firebase JS SDK in the browser, with Laravel verifying the Firebase ID token to create the server session.
  • Admin & Restaurant Panels → Firebase JS SDK in the browser plus the Firebase Admin SDK on the server (via credentials.json) for privileged operations and push notifications.
  • Cloud Functions → the deliveryDispatch Firestore trigger that assigns orders to drivers, and the deleteUser callable that removes an account from Firebase Authentication.
  • Payment gateways → handled server-side by the Laravel panels, which hold the secret keys and verify each transaction.
  • Laravel scheduler → the recurring Node scripts (auto-cancel, scheduled-order reminders).

There is no separate REST API layer to configure: Firestore is the API, and every client reads and writes the same collections in real time.

27.2. Firebase Firestore (primary data store)

All platform data lives in Firestore. The main collections are:

  • users — customers, vendors, drivers and admins, each with a role.
  • vendors, vendor_categories, vendor_products, vendor_attributes, vendor_filters — restaurants and their menus.
  • restaurant_orders, order_transactions, booked_table — orders, payments and dine-in bookings.
  • coupons, gift_cards, cashback, cashback_redeem, advertisements — promotions.
  • subscription_plans, subscription_history, payouts, driver_payouts, withdraw_method, wallet — money movement.
  • zone, tax, currencies, documents, documents_verify — operational configuration.
  • settings — every configurable option, one document per settings screen.
  • chat, notifications, dynamic_notification, email_templates — communication.
  • cms_pages, menu_items, on_boarding, story — content.

Configured by the FIREBASE_* keys in each panel’s .env. Access is governed by the security rules you publish (see Create Firebase Project), and multi-field queries need composite indexes (see Deploy Firestore Indexes).

27.3. Firebase Authentication

Handles email/password, phone (OTP), Google and Apple sign-in for every client. Providers are enabled in the Firebase console; the web panels additionally need the domain listed under Authorized domains and a matching OAuth 2.0 client for Google login.

27.4. Firebase Storage

Holds every uploaded file — restaurant and food images, banners, avatars and verification documents. Upload quality is controlled by IMAGE_COMPRESSOR_QUALITY in each panel’s .env.

27.5. Cloud Messaging (FCM — push notifications)

Delivers order, chat and status notifications to customers, restaurants and drivers. Configured by uploading the service-account JSON and Sender ID under Settings → Notification Settings; the notification text itself comes from Dynamic Notifications.

27.6. Firebase Realtime Database

Used for live driver location, which changes far more often than order state. It powers the customer’s tracking map and the admin’s God’s Eye view.

27.7. Payment gateways

18 gateways plus COD and the wallet. Public keys are read by the clients; secret-key operations run server-side in the Laravel panels, which read the credentials from the settings document the Admin Panel manages. See Payment Gateway Setup.

27.8. Google Maps

Restaurant search, address selection, zone drawing, delivery distance and live tracking. One key, configured in Settings → Map Settings and in each mobile app.

27.9. OpenAI

The Modules/AI module in the Admin and Restaurant panels. Given a food image, title and short description it drafts the full listing — description, specifications, variations and attributes. Configured under Settings → AI Settings; billed by OpenAI per request.

27.10. Email (SMTP)

Order receipts, password resets, vendor approvals and campaign mail. Set the SMTP host, port, username, password and encryption in .env (or under Settings → Email Settings); the message bodies come from Email Templates.

27.11. Where each integration is configured

  • .env (each panel) — database, all FIREBASE_* keys, FIREBASE_PROJECT_DB, GOOGLE_CLIENT_ID, NODE_PATH, SMTP.
  • storage/app/firebase/credentials.json — the Firebase service account.
  • Admin Panel → Settings — branding, map key, notifications, AI key, delivery charge, business model, feature toggles, taxes and payment gateways.
  • Firebase console — auth providers, authorised domains, security rules, indexes and Cloud Functions.
  • Google Cloud console — Maps APIs, the API key restrictions and the OAuth 2.0 client.

27.12. Extending Foodie (developer guide)

  • Add a settings screen. The settings pages are data-driven: most are a short Blade file declaring a Firestore document name and a field list, rendered by a shared form partial. Add your screen, then add one line to the settings hub array in resources/views/settings/index.blade.php.
  • Add a menu item. Add the route in routes/web.php wrapped in the permission: middleware, add the entry to
    resources/views/layouts/menu.blade.php, and grant the permission to the roles that need it. Route names double as permission keys, so keep them stable.
  • Add a language. Copy resources/lang/en to a new locale folder, translate lang.php, and register the language under Languages in the admin panel.
  • Add a payment gateway. Follow an existing gateway end to end: its tab under Payment Methods, its keys in the settings document, and its init/return routes plus the server-side handler in each panel’s checkout controller.
  • Change business rules. Prefer the admin settings over code edits — commission, delivery charge, radius, taxes, order assignment and the feature toggles are all configurable, so upgrades stay painless.

Recent Posts

    Archives

    No archives to show.

    Categories

    • No categories

    Blog Categories

    • No categories

    Archives

      Categories

      • No categories