Manual · Engineering

Engineering record — internal detail. The manual is authoritative for product behaviour.

Engineering8 min read

System architecture & stack

What the platform is built from today: frameworks, datastore, auth, storage, jobs, AI, testing and the design contract.

ForEngineer

Product shape

A multi-tenant logistics finance application. One workspace (organisation) owns customers, vendors, warehouses, products, containers, trips and the full double-entry ledger. Role and department decide which modules a member sees, and the same predicate drives both sidebar visibility and server route authorisation.

The surface splits into three worlds: a public marketing and documentation site, an authentication surface, and the dashboard (finance, port, fleet, inventory, analytics, administration, superadmin).

Stack

LayerChoiceVersion
FrameworkNext.js (App Router)16.2.7
UI runtimeReact19.2.4
StylingTailwind CSS v4 + shadcn/Radix + tw-animate-css^4
DatabaseNeon Postgres (serverless driver)@neondatabase/serverless ^1.1.0
ORMDrizzle ORM + drizzle-zod, drizzle-kit migrations0.45.x / kit 0.31.10
AuthBetter Auth + @better-auth/infra1.6.27
Object storageCloudflare R2 via AWS SDK v3 + presigner^3.1098.0
Background jobsTrigger.dev^4.5.9
Rate limitingUpstash Redis + @upstash/ratelimit^2.0.8
AIVercel AI SDK with OpenAI and Anthropic providersai ^7.0.17
EmailResend + React Email^6.16.0
Documents@react-pdf/renderer, pdf-parse, tesseract.js OCR, ExcelJS—
Forms and validationreact-hook-form + zodzod ^4.3.6
Client stateZustand + TanStack Query and Table—
ChartsRecharts^3.8.1
TestingVitest (unit), Playwright (e2e)—
MessagingTelegram bot webhook at /api/telegram/webhook—

Watch

Documentation drift to resolve

AGENTS.md still names Supabase and @supabase/ssr as the database and auth stack. The dependency manifest and the migration records say otherwise: the datastore is Neon and auth is Better Auth. AGENTS.md should be corrected so agents do not reintroduce Supabase patterns.

Architectural invariants

  • One tenant boundary: every query is organisation-scoped, and cross-org references are rejected at the action layer.
  • The ledger is append-only: posted entries are never edited, only reversed.
  • Every automatic posting is idempotent with respect to its business event.
  • The AI layer is read-only for data and can propose, never commit; all commits pass through a human approval action that writes an audit entry.
  • Money conversion always uses a stored rate; a missing rate is an error, never a silent 1.0.

Design contract

DESIGN.md is the authoritative frontend specification — the split-flap concourse board world. Any task that creates, modifies or restyles a component, page or interaction must read it first. It governs tokens, type scale, section grammar, motion and the explicit list of patterns not to reintroduce.