DocHub
How to build, run, and deploy MaxTracks Web and Cloud Functions

Build & Deployment

Prerequisites

  • Flutter SDK installed and on PATH
  • Node.js (for Cloud Functions)
  • Firebase CLI installed globally (npm install -g firebase-tools)
  • Access to the Firebase project (authenticated via firebase login)

Firebase Project Setup

Switch to Production

firebase use --add max-production

This sets the active project to max-inventory-scanner-b0b53 (production).

Project Aliases

Defined in .firebaserc:

Alias Project ID Use
default max-inventory-scanner-b0b53 Production
maxshipping max-shipping-development Development
max-production max-inventory-scanner-b0b53 Production (explicit)

Building the Web App

1. Navigate to the Flutter project

cd maxshipping-main-sub/maxshipping-pages

2. Get dependencies

flutter pub get

3. Build for web

flutter build web

This outputs to build/web/ which is the Firebase Hosting public directory.

4. Deploy hosting

firebase deploy --only hosting

Deploying Cloud Functions

1. Install function dependencies

cd functions
npm install

2. Deploy all functions

firebase deploy --only functions

3. Deploy a specific function

firebase deploy --only functions:functionName

For example:

firebase deploy --only functions:onPackageCheckIn

Local Development

Run Flutter web locally

cd maxshipping-main-sub/maxshipping-pages
flutter run -d chrome

Run Firebase Emulators

firebase emulators:start

Emulator ports (configured in firebase.json):

Service Port
Functions 5001
Hosting 5000
Emulator UI Enabled

View function logs

firebase functions:log

Or via npm script:

cd functions
npm run logs

Full Deployment Workflow

A typical production deployment:

# 1. Ensure you are on the production project
firebase use max-production

# 2. Build the Flutter web app
cd maxshipping-main-sub/maxshipping-pages
flutter build web
cd ../..

# 3. Deploy everything
firebase deploy --only hosting
firebase deploy --only functions

# Or deploy both at once
firebase deploy --only hosting,functions

Project Structure

maxtracksweb/
├── firebase.json              # Hosting config, rewrites, emulators
├── .firebaserc                # Project aliases
├── functions/                 # Cloud Functions (Node.js)
│   ├── index.js              # All function exports (11,000+ lines)
│   ├── package.json          # Node dependencies
│   └── serviceAccountKey.json # Firebase admin auth
├── maxshipping-main-sub/      # Flutter application
│   └── maxshipping-pages/
│       ├── pubspec.yaml      # Flutter dependencies
│       ├── lib/              # Dart source (screens, models, utils)
│       ├── assets/           # Images
│       ├── fonts/            # Montserrat font files
│       └── build/web/        # Build output (hosting public dir)
└── node_modules/

Firebase Hosting Configuration

From firebase.json:

  • Public directory: maxshipping-main-sub/maxshipping-pages/build/web
  • SPA rewrite: All routes redirect to /index.html (Flutter handles routing)
  • Service worker: Auto-reload on controller change for progressive caching

Important Notes

  • Always run firebase use max-production before deploying to production
  • The functions/index.js file contains all 31+ cloud functions in a single file
  • Cloud Functions use Node.js runtime with Firebase Admin SDK
  • The Flutter app initializes Firebase in main.dart with hardcoded config for the production project