ERP Architecture
A modular ERP replacing a spreadsheet-driven operation, built around a domain model that can absorb a decade of process change.
- Year
- 2024
- Type
- Modular ERP platform
- Status
- In production
- Audience
- Operations, finance and warehouse teams in mid-sized distribution businesses.

The context.
The engagement started as a stock-tracking request and ended as a full operational backbone: inventory, procurement, sales, finance and human resources.
The core insight was that the client's processes would keep changing, so the system was modelled around stable domain entities with configurable workflow on top.
Every financial mutation is recorded as an immutable ledger entry, which made the first external audit a query instead of a project.
What was actually broken.
- Twelve spreadsheets acted as the single source of truth, and disagreed.
- Stock levels were accurate only on the day of a manual count.
- Approvals happened over messaging apps with no record.
- Month-end close consumed a week of manual reconciliation.
Decisions were made on stale numbers, and no one could reconstruct why a figure changed.
Modelling a business that would restructure its own processes twice during the build, without rewriting the core.
What was engineered.
- A domain-driven core separating immutable transaction records from mutable configuration and workflow.
- Double-entry ledger semantics for every value movement, making balances derived rather than stored.
- A permission model expressed as roles over resources and actions, auditable and testable in isolation.
- Module boundaries enforced at the service layer so procurement can evolve without destabilising finance.
Layer by layer.
Data-dense operational UI with server-driven forms and optimistic updates.
- React
- TypeScript
- TanStack Query
Modular monolith with explicit domain boundaries and transactional services.
- Node.js
- TypeScript
- Zod
Typed RPC surface with per-module contracts and versioned migrations.
- REST
- OpenAPI
- TypeScript types
Normalised relational schema with an append-only accounting ledger.
- PostgreSQL
- Row-level security
Materialised views for financial and inventory reporting.
- PostgreSQL
- Materialised views
Containerised deployment with automated backups and point-in-time recovery.
- Docker
- PgBackRest
- CI/CD
Session-based auth with granular role and department scoping.
- JWT
- RBAC
- Audit log
Document store for invoices and signed delivery notes.
- Object storage
- Checksums
The why behind each trade-off.
Why a modular monolith instead of microservices?
One team, one deployment surface, and transactions that genuinely span modules. Distributed transactions would have bought organisational flexibility nobody needed at a correctness cost nobody wanted.
Why PostgreSQL?
ERP is a consistency problem before it is a scale problem. Real constraints, real transactions, and row-level security that enforces access at the data layer rather than in application code.
Why an append-only ledger?
Mutable balances make history negotiable. An append-only ledger means any figure can be replayed to its source, which is the difference between bookkeeping and accounting.
Why server-driven forms?
Business rules change monthly. Encoding them once on the server and rendering from that contract kept the client from becoming a second, divergent rulebook.
What resisted.
- Scalability
Reporting queries over a growing ledger degraded predictably; materialised views with incremental refresh restored sub-second dashboards.
- Migration
Importing years of spreadsheet history required a reconciliation harness that refused any import which did not balance.
- Security
Row-level security policies were written alongside the schema and covered by tests, so a missing filter fails CI rather than production.
- Change management
Process restructuring mid-build was absorbed through configuration because workflow was never hardcoded into the domain.
What it taught.
- Model what the business is, not what it currently does. Processes churn; entities rarely do.
- Immutable financial history costs a little storage and saves entire audits.
- Permissions belong in the database when the database is the source of truth.
Measured, not claimed.
1 day
Month-end close
Reduced from roughly one week.
6
Modules
Inventory, procurement, sales, finance, HR, reports.
99.2%
Stock accuracy
Measured against physical counts.
100%
Audit trail
Every value movement replayable to source.
The system in context.


Technology stack
- React
- TypeScript
- TanStack Query
- Tailwind CSS
- Node.js
- TypeScript
- Zod
- PostgreSQL
- Redis
- Materialised views
- Docker
- CI/CD
- Automated backups