Back to Fleetonomy

Developer documentation

Setup guide

Node 20+ · port 3001

Run Fleetonomy on your machine for development or evaluation. This guide covers dependencies, .env.local, Firebase Admin credentials, seeding pricing data, and your first tenant workspace.

On this page
  1. Prerequisites
  2. Install & run
  3. Environment
  4. Firebase
  5. First run
  6. Platform admin
  7. Verify
  8. Optional services
  9. Next steps

Prerequisites

  • Node.js 20+ and npm (or compatible package manager)
  • A Firebase project with Authentication (email/password), Firestore, Realtime Database, and Storage enabled
  • Git to clone the repository

Install & run

From the project root:

Terminal
npm install
cp .env.local.example .env.local
# Edit .env.local — see sections below
npm run seed
npm run dev

Open http://localhost:3001 after npm run dev reports Ready.

Environment

Copy .env.local.example to .env.local and fill in at least these values before signing in:

.env.local (minimal)
# App URL (invite links, QR codes, callbacks)
NEXT_PUBLIC_APP_URL=http://localhost:3001

# Firebase client (Firebase Console → Web app)
NEXT_PUBLIC_FIREBASE_API_KEY=...
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=...
NEXT_PUBLIC_FIREBASE_APP_ID=...
NEXT_PUBLIC_FIREBASE_DATABASE_URL=https://your-project-default-rtdb.firebaseio.com

# Server session (generate a random 32+ char secret in production)
SESSION_SECRET=dev-only-change-me-in-production

Full reference: .env.local.example in the repo root. Never commit .env.local — it is gitignored.

Firebase

  1. 1

    Client SDK (browser)

    Firebase Console → Project settings → Your apps → Web app. Copy values into NEXT_PUBLIC_FIREBASE_*.

  2. 2

    Admin SDK (server)

    Service accounts → Generate new private key. Use npm run firebase:service-account or place *-firebase-adminsdk-*.json in the project root for auto-discovery.

  3. 3

    Deploy rules & indexes

    Deploy firestore.rules, firestore.indexes.json, and storage rules from the repo when you connect a real project.

Service account helpers
# From a downloaded service-account JSON file:
npm run firebase:service-account -- "C:\path\to\key.json"

# Or repair a corrupted .env.local:
npm run env:repair

First run

  1. 1

    Seed defaults

    npm run seed creates pricing tiers and ad marketplace slots in Firestore.

  2. 2

    Sign up

    Visit /sign-up, create an account, and complete onboarding to create your first tenant. You become owner of that workspace.

  3. 3

    Invite your team

    Dashboard → Settings → Team — issue invite codes or QR links for dispatchers and finance.

Demo data
# After sign-up, copy your Firebase Auth UID from the console or session cookie
npm run populate:demo -- --owner-uid YOUR_FIREBASE_UID

# Or attach to an existing demo tenant
node scripts/populate-demo-data.mjs --tenant-slug savannah-haulage-demo --owner-uid YOUR_UID

# Preview without writes
node scripts/populate-demo-data.mjs --dry-run --create-tenant

# Remove demo tenant data (slug savannah-haulage-demo only)
node scripts/populate-demo-data.mjs --wipe --tenant-slug savannah-haulage-demo

Platform admin

The first user in an empty project may be promoted automatically. To grant platform administration manually, set on your user document in Firestore users/{uid}:

Firestore users/{uid}
{
  "platformRole": "platform_admin"
}

Valid values: platform_admin, platform_support, none. Then open /admin for tenants, pricing, ads, and platform webhooks.

Verify

Confirm the server and Firebase Admin credentials:

Health check
curl -s http://localhost:3001/api/health | jq

Expect ok: true and a credentialSource field. Firebase client config for sign-in is exposed at /api/config/public (no secrets).

Optional services

Valkey / Redis

Set REDIS_URL or VALKEY_URL for Firestore read caching. In-memory fallback applies if unreachable.

M-Pesa (Daraja)

Configure MPESA_* in .env.local and a public MPESA_CALLBACK_BASE_URL for STK/C2B webhooks.

Web push (VAPID)

npm run vapid:generate — then set NEXT_PUBLIC_VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY.

MCP dev tokens

MCP_API_TOKENS=comma-separated keys for local /api/mcp testing only. Never in production.

Next steps