Skip to content
Enterprise Systems

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.
ERP Architecture system visual
01Overview

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.

02Problem

What was actually broken.

Pain observed
  • 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.
Business risk

Decisions were made on stale numbers, and no one could reconstruct why a figure changed.

Technical constraint

Modelling a business that would restructure its own processes twice during the build, without rewriting the core.

03Solution

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.
04Architecture

Layer by layer.

Frontend

Data-dense operational UI with server-driven forms and optimistic updates.

  • React
  • TypeScript
  • TanStack Query
Backend

Modular monolith with explicit domain boundaries and transactional services.

  • Node.js
  • TypeScript
  • Zod
API

Typed RPC surface with per-module contracts and versioned migrations.

  • REST
  • OpenAPI
  • TypeScript types
Database

Normalised relational schema with an append-only accounting ledger.

  • PostgreSQL
  • Row-level security
Reporting

Materialised views for financial and inventory reporting.

  • PostgreSQL
  • Materialised views
Infrastructure

Containerised deployment with automated backups and point-in-time recovery.

  • Docker
  • PgBackRest
  • CI/CD
Authentication

Session-based auth with granular role and department scoping.

  • JWT
  • RBAC
  • Audit log
Storage

Document store for invoices and signed delivery notes.

  • Object storage
  • Checksums
05Decisions

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.

06Challenges

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.

07Lessons

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.
08Results

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.

09Gallery

The system in context.

Operational dashboard consolidating five former spreadsheets.
Operational dashboard consolidating five former spreadsheets.
Ledger and module boundary map.
Ledger and module boundary map.

Technology stack

Frontend
  • React
  • TypeScript
  • TanStack Query
  • Tailwind CSS
Backend
  • Node.js
  • TypeScript
  • Zod
Data
  • PostgreSQL
  • Redis
  • Materialised views
Infrastructure
  • Docker
  • CI/CD
  • Automated backups
Next case studyTataco AI