A production Laravel MLM platform models members with a materialised upline path for constant time downline reads, runs commission calculations as idempotent Horizon queue jobs, protects payouts with database transactions and a single ledger writer, and invalidates Redis caches per member.

Architecture

Architecture choices that stay fast at scale

The patterns we use to keep genealogy reads instant and payouts correct as a network grows into millions of members.

Model positions as entities, store the path

Every distributor is a Laravel model and every placement in a plan references a sponsor plus a materialised upline path. Storing the path, not just parent links, lets downline counts and the genealogy tree load in one indexed query instead of a recursive walk.

Rule of thumb: never compute a downline by walking parents at request time. Store the path, index it, and let the database do the work.

Run commissions on Horizon, never in the request

Commission runs touch thousands of ledger rows. Each run is pushed onto a queue and processed by Horizon workers, so a payout calculation can never time out a member page load. Jobs are idempotent, which makes retries safe after a deploy or a spot instance restart.

Protect payout integrity with transactions

Wallet debits, commission credits and withdrawal requests all write through database transactions with row level locking. A single writer owns the ledger, so two concurrent runs cannot double pay. The ledger is the source of truth and balances are a cached projection of it.

Cache aggressively, invalidate precisely

Replicated sites and dashboards are cached in Redis and tagged per member. When a rank or balance changes, only that member tags clear, so the platform stays fast without ever showing stale money.

Decisions at a glance

ConcernPatternWhy it wins
Genealogy readsMaterialised upline path plus indexConstant time downline queries
Commission runsHorizon queues, idempotent jobsNo request timeouts, safe retries
Payout integrityDB transactions, single writerNo double payments
Orders and repurchaseCashier plus a clean order eventProven checkout and gateways
Scale outRedis cache and read replicasHandles launch day traffic spikes
Request flow

From order to payout, one clean path

An order completes, Cashier fires an event, the engine accrues commissions on a queue, the ledger settles, and only the affected caches clear. Every step is observable in Telescope.

Order completed
Cashier event
Commission job (Horizon)
Ledger transaction
Wallet updated
Cache invalidated

Talk architecture with our team

Bring your compensation plan and we will map it to a build spec you can review.