One platform.
Every fleet.
Strict boundaries.
Meridian operates many independent logistics companies from a single application and a single database — each with its own branded website, public package tracking, and admin console, enforced by server-side tenant isolation. This build ships Phase 11 — reliability, tested: a three-layer suite with a production-refusal guard, an IDOR matrix proving tenant isolation, HTTP hardening, and a release gate: 156 tests, all green, zero exceptions.
- Hardened & verified
- 11 / 12
- Package statuses — locked
- 05
- Tests — all green
- 156
- Customer accounts — by design
- 00
Live foundation telemetry — GET /api/health
CHECKINGAPI tier
CHECKING
awaiting first probe
Database
—
no live probe yet
Realtime tier
PLANNED
Socket.IO contracts pinned · Phase 06
Uptime
—
polling every 8s
01System architecture
Four layers, one direction.
Browser
Tenant websites, public tracking, admin consoles. Collects input, renders envelopes.
Never
Touches the database, holds secrets, enforces rules.
UI tier — Next.js
App Router pages, server components, the typed browser API client in src/services.
Never
Calls fetch outside services/ — or imports from src/server.
API tier — src/server
Route → middleware → controller → service. Auth, tenancy, validation, business logic.
Never
Renders UI or trusts client-supplied tenant identifiers.
MongoDB — source of truth
One shared database via Mongoose ODM; tenantId on every tenant-owned document; compound indexes.
Never
Exposed to the browser — only the API tier's Mongoose layer talks to it.
Sidecar — Phase 06
Realtime tier
Socket.IO attaches alongside the HTTP server. Phase 1 already pins the event names, payload types, and room topology in src/server/realtime/events.ts.
events tracking:status.updated
rooms tenant:{id} · tracking:{id}
writes HTTP only — sockets broadcast
02Multi-tenant model
Many companies. One truth. Zero leakage.
HOST
swift.nttrack.com
SUBDOMAIN
"swift" → tenants.slug
CONTEXT
{ tenantId } attached server-side
SCOPE
every query filter: { tenantId }
Reserved: admin.nttrack.com — the platform owner control plane. V1 supports subdomains only.
Every tenant-owned record carries tenantId — no exceptions.
tenantId is resolved server-side from host or session, never trusted from the client.
Frontend filtering is not security. The backend enforces isolation on every request.
Platform Admin
account
Tenants · website configuration · branding · platform settings.
Tenant Admin
account
Packages · statuses · locations · tracking operations — own tenant only.
End Customer
NO account
Visits the tenant site, enters a tracking ID, views tracking. That is all.
Locked decision: there is deliberately no Customer entity. Customers are anonymous visitors with a tracking ID — no accounts, no customer table.
03Locked decisions
The charter beneath the code.
Locked decision #14 — exactly five package statuses, in order
- 1PENDING
- 2PROCESSED
- 3IN_TRANSIT
- 4ARRIVED_AT_FACILITY
- 5DELIVERED
Pinned in code at src/types/domain.ts — database, API payloads, realtime events, and UI all derive from that single definition. No sixth status in V1.
04Implementation roadmap
Twelve phases. Foundations first.
- PHASE 01COMPLETEProject FoundationRepo, config, layered backend tier, DB connection architecture, realtime contracts, health probe, full documentation.
- PHASE 02COMPLETEBackend + DatabasePlanned tables, constraints, indexes, migrations, seed data, service-layer patterns.
- PHASE 03COMPLETEAuthenticationHTTP-only cookie sessions, password hashing, role guards for /admin and /platform.
- PHASE 04COMPLETETenant ManagementTenant CRUD, slug/subdomain host resolution, request-scoped tenant context.
- PHASE 05COMPLETEPackages + TrackingPackage CRUD, global tracking IDs, the five-status state machine, public tracking endpoint.
- PHASE 06COMPLETETenant Websites + Public TrackingHostname tenant resolution, configuration-driven sites, /track and the allowlisted public API.
- PHASE 07COMPLETEMaps & Realtime TrackingLeaflet/OSM location UX + one-server Socket.IO: rooms, DB-first broadcasts.
- PHASE 08COMPLETEPlatform Admin & Website ManagementControl plane: tenant detail tabs, website + branding editors, preview, metrics.
- PHASE 09COMPLETENotifications & Customer SharingCopy ID/link flows, WhatsApp share URLs, live-update indicators — no providers.
- PHASE 10COMPLETESecurity HardeningRate limits, security headers, CORS allowlist, CSRF checks — full audit pass.
- PHASE 11COMPLETETesting & QAService unit tests, API integration tests, tenant-isolation suite, E2E smoke flows.
- PHASE 12UP NEXTProduction DeploymentDeployment config, secrets wiring, monitoring baseline, launch checklist.YOU ARE HERE
Standing rule — docs update in the same change as the code.
05Documentation
The contracts every phase obeys.
Architecture
System diagram, multi-tenant model, the three user layers, boundaries, and the locked decisions.
Frontend
App Router structure, components, the layered API client, hooks, types, and future tenant-aware areas.
Backend
The Express-style layered API tier: routes, middleware, controllers, services, models, realtime foundation.
Database
Shared MongoDB model, the six implemented collections, tenantId isolation, indexes, and tracking ID strategy.
API
The /api/v1 groups, the implemented auth endpoints, envelopes, and the error code registry.
Authentication
Sessions, cookies, Argon2id, enumeration defenses, role and tenant authorization, CSRF/CORS posture.
Tenant Management
Atomic provisioning, slug rules, lifecycle matrix, list querying, password reset, and admin console.
Package Management
Tracking IDs, the five-status workflows, status/location history, atomic transactions, isolation, and console.
Platform Admin
Control-plane permissions, tenant list, detail tabs, password reset, and server-authorized tenant dashboard access.
Website Configuration
The WebsiteConfig model, branding, sections, visibility and ordering, URL images, SEO, defaults, preview.
Tenant Websites
Hostname resolution, configuration-driven rendering, branding, sections, SEO, status behavior, local dev.
Public Tracking
The allowlisted tracking endpoint, safe errors, rate limiting, timelines, and integration boundaries.
Maps
Leaflet + OSM ecosystem, geocoding abstraction, admin location picker, customer map, licensing duties.
Realtime
One HTTP server hosting Socket.IO, room authorization, DB-first events, reconnection, lifecycle.
Notifications
V1 realtime-only notifications, connection feedback, and the documented future provider architecture.
Customer Sharing
Tracking link generation, copy flows, WhatsApp share URL, clipboard resilience, and privacy bounds.
Deployment
VPS, PM2, Nginx, Cloudflare, environment values, build flow, Git releases, rollback, onboarding.
Security
Server-side isolation, authN/Z, session security, validation, headers, safe public payloads, socket authorization.
Environment
Every environment variable, public vs secret, local vs production principles.
Backup & Restore
Atlas backups, mongodump/mongorestore, retention, and the mandatory restore drill.
Troubleshooting
WebSocket, host resolution, cookies, database, deploy, SSL — symptom to fix maps.
Production Checklist
Pre-flight infrastructure list, the 22-step live smoke test, ops cadence.
Testing
Layered suite (unit/integration/e2e), production-safety guard, coverage matrix, release gate.
Development
Prerequisites, setup, quality gates, seeding, manual verification, troubleshooting, workflow.
Implementation Roadmap
Phases 1–12 with scope, dependencies, and the standing rules for every phase.
Sources of truth live in /docs — rendered here for reading.