Meridian Flow: Engineering a Multi-Tenant Dispatch Platform for Freight Operations.

How Grotics partnered with a freight operations team to design, build, and ship a multi-tenant dispatch platform — replacing manual spreadsheets with one auditable system of record.

Architecture Type

Event-Driven SaaS

Modular monolith with strict data isolation

Engagement Model

Greenfield Build

Delivered alongside the client team

Technical Scope

Core Engine & Payouts

Postgres RLS, Fastify, Stripe Connect

Client Sovereign Cloud

Client AWS & repositories

No lock-in; in-house handover

Handover

Client-Owned Stack

Runs in the client's own AWS account

Meridian Flow — system overview
In production
How it works

One state of truth per load

Each load moves through a single, unambiguous lifecycle. Carrier updates arrive as events, are validated once, and are appended to an immutable history — so two dispatchers can never book the same load twice.

Append-only event logAdvisory-lock booking
DISPATCH LIFECYCLEONE LOAD, ONE CARRIER
TENANCY MODELRow-level security
CARRIER PAYOUTSStripe Connect
SCHEDULINGTemporal.io workflows
CHANGE HISTORYAppend-only event log

Tenant context comes from signed JWT claims

Loads are claimed under advisory locks before assignment

Status changes are appended once and never overwritten

Carrier payouts settle from the double-entry ledger

01 / The Context

Dispatch bottlenecks threatening operational scale.

Freight brokerages and multi-carrier fleets live on fast, volatile transactions. Before Meridian Flow, dispatch teams relied on a patchwork of spreadsheets, a legacy transport management system, and manual PDF reconciliation runs.

Manual reconciliation

Settlement runs across spreadsheets and PDFs

Line-item checks across carrier fuel surcharges and accessorial fees were slow and easy to get wrong.

Concurrency risk

The same load, booked twice

When rates moved fast, dispatchers working in parallel could assign the same load to competing carriers without noticing.

Core Operational Bottleneck

Uncoordinated state meant untracked detention fees, duplicate booking penalties, and numbers nobody fully trusted. The team needed one system where a load could never sit in an ambiguous state.

02 / Partnership Model

Senior-Led Pod. Zero Middleware Layers.

No committees, no hand-off to a junior bench. Meridian Flow worked directly with a three-person senior team inside their own Slack and GitHub organization.

01

Systems Architect

Database Schema, RLS & Cloud Infra

Authored the PostgreSQL declarative permission model, Temporal state machine graphs, and automated AWS CDK multi-environment infrastructure.

Focus: Invariant Isolation & Ledger Design
02

Senior Backend Engineer

Fastify, Webhooks & Stripe Connect

Engineered the dispatch routing gateway, out-of-order webhook reconciliation queues, and automated multi-party escrow clearing logic.

Focus: Idempotency & Payment Routing
03

Senior Frontend Engineer

React, Real-Time Streams & UX

Delivered keyboard-driven, high-density dispatcher views, live GPS telemetry maps, and responsive optimistic state updates.

Focus: Density & Keyboard Command Palette
Grotics principle: senior engineers on every pod
Direct Slack channel • Async updates • Pairing on hard problems
03 / Topology

Technical Blueprint: The Modular Dispatch Engine

Designed for consistency without distributed-system overhead: a modular monolith deployed on AWS ECS, with isolation enforced inside the database.

1. Ingress & Auth

Fastify Node.js gateway with Zod payload validation. JWT identity paired with signed tenant claims.

TLS termination at the edge

2. Postgres RLS Engine

PostgreSQL with database-level Row-Level Security. Every single query enforces current_setting('app.tenant_id').

Enforced in the database

3. Temporal.io Workflows

Distributed durable execution. Manages multi-day driver trips, automatic timeout escalations, and out-of-order telematics events.

Durable Execution & Retry Queues

4. Double-Entry Ledger

Immutable debit/credit journal table, settled through Stripe Connect so carrier payouts follow the ledger.

Audit Trail • Auto Stripe Escrow
Architecture Rationale

Why Modular Monolith Over Microservices?

Splitting this into microservices would have meant distributed transactions across the money paths and a lot of operational overhead for a small team. Keeping clean module boundaries inside one deployable unit keeps dispatch and ledger writes transactional and the codebase easy to navigate.

Deep Engineering Decisions

Engineering Trade-Offs & Defensive Design

What separates a demo from a system you can operate: how edge cases and contention are handled at the database and network layers.

CHALLENGE 01

Multi-Carrier Webhook Idempotency

Carriers send updates via webhooks that arrive out-of-order, duplicated, or delayed. Naive updates would regress a load from "Delivered" back to "In-Transit".

Solution Mechanism

Implemented a Redis-backed distributed lock with a monotonic event counter. Webhooks are staged into an append-only event stream; out-of-order payloads are rejected or reconciled against the carrier's state vector.

Result: out-of-order updates cannot regress a load
CHALLENGE 02

Strict Multi-Tenant Database Isolation

Freight brokers handle confidential spot margins. Relying only on application-level where("tenant_id", id) filters leaves room for human error.

Solution Mechanism

Configured native PostgreSQL Row-Level Security policies tied directly to connection pool session variables. Even if an engineer writes an unbounded query, the database engine returns zero rows from other tenants.

Result: isolation enforced by the engine
CHALLENGE 03

High-Speed Driver Allocation Race Conditions

During morning peaks, many dispatchers bid on the same high-value loads at once, which produced phantom assignments and double-booked carriers.

Solution Mechanism

Replaced standard database optimistic locking with Postgres advisory transaction locks paired with WebSocket presence markers. Dispatchers see instant visual reserve locks before submission.

Result: a load can only be claimed once
04 / What shipped

What the first release shipped with.

The first release went out with the tooling and documentation the in-house team needed to run the platform themselves.

OpenAPI v3 specification with generated client SDKs
Automated GitHub Actions CI/CD with ephemeral preview databases
Architecture handover with a practical operational runbook
Architecture
Modular monolith

One deployable, clean boundaries

Dispatch and ledger writes stay transactional in one system.

Data isolation
Postgres RLS

Isolation enforced in the database

Every query runs under a tenant-scoped session.

Automation
Temporal.io

Durable trips and retries

Long-running trips survive restarts, delays, and out-of-order updates.

Payments
Stripe Connect

Payouts from the ledger

Settlement entries post before money moves.

Engagement Model

The engineers who designed the system are the ones who built it, documented it, and stayed in the client's Slack until handover was done.

G

Grotics

Senior-led, from first commit to handover

Next Step

Building a high-concurrency SaaS platform?

Let's talk through your data model, API requirements, and infrastructure trade-offs before the first schema is written.