Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
phase-1-implementation
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | # ADR-0001 — Application Foundation |
| 2 | |
| 3 | - Status: Accepted for Phase 1 |
| 4 | - Date: 2026-10-05 |
| 5 | |
| 6 | ## Decision |
| 7 | Use a TypeScript-first modular monolith for the initial TreasuryFlow product, with Next.js 16 App Router for the web/application boundary and PostgreSQL as the transactional system of record. Keep financial domain rules in server-only modules independent of UI components. External banks, accounting sources, messaging and other providers are accessed only through typed adapter interfaces. |
| 8 | |
| 9 | ## Rationale |
| 10 | TreasuryFlow needs strong transactional consistency, explicit authorization and auditable domain behavior more than it needs early microservice distribution. A modular monolith minimizes distributed failure modes while preserving clear boundaries that can be extracted later if scale or regulation requires it. |
| 11 | |
| 12 | Current Next.js 16 security guidance requires authorization to be re-verified in Server Actions/Route Handlers and recommends server-only data-access boundaries. TreasuryFlow adopts that rule as a minimum; UI visibility never grants authority. |
| 13 | |
| 14 | ## Initial technical baseline |
| 15 | - Next.js 16 App Router |
| 16 | - TypeScript strict mode |
| 17 | - PostgreSQL |
| 18 | - Schema/migration layer selected during the executable scaffold task; it must support versioned migrations, transactions and constraints. |
| 19 | - Vitest for fast domain/unit tests unless scaffold verification identifies an incompatibility. |
| 20 | - Playwright for critical E2E flows once the shell exists. |
| 21 | - Container-ready deployment; Railway is staging-first, not a production lock-in. |
| 22 | |
| 23 | ## Boundaries |
| 24 | - `domain`: financial invariants and state transitions; no framework imports. |
| 25 | - `application`: use cases, authorization orchestration and transaction boundaries. |
| 26 | - `infrastructure`: persistence, queues, bank/accounting adapters and telemetry. |
| 27 | - `web`: RTL Persian-first presentation and HTTP/Server Action boundaries. |
| 28 | |
| 29 | ## Security consequences |
| 30 | Every mutation is treated as an independent entry point and must authenticate, authorize and validate the target resource on the server. Maker-checker and payment-state rules live below the UI boundary. |
| 31 | |
| 32 | ## Deferred |
| 33 | Authentication provider, ORM/query builder, queue implementation and final production hosting are deliberately not locked until the Phase 1 scaffold spike proves compatibility and portability. |