---
title: Architecture
description: The mental model behind PharmaFlow, branches, auth, stock movements, VAT, and offline sync.
---

This section builds the mental model you need before touching any feature. Read the pages in order; each one assumes the previous.

**[Request lifecycle](/architecture/request-lifecycle)**

What happens from the edge middleware to the route handler and the audit log.

**[Branches and scoping](/architecture/branches-and-scoping)**

How branch isolation works and which roles can cross it.

**[Stock and FEFO](/architecture/stock-and-fefo)**

Batches, the append-only movement ledger, and expiry-first deduction.

**[VAT and money](/architecture/vat-and-money)**

The org tax policy, per-line VAT, and how money is stored and returned.

**[Offline sync](/architecture/offline-sync)**

Devices, revisions, push replay, pull filtering, snapshots, and the console offline pipeline.
