Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

docs: define TreasuryFlow UI reconstruction specification

Davood Mehraban committed Oct 5, 2026 at 22:38 UTC f751591e6e6241a18f5ef6d5ce2301641ff4aa37
1 file changed +157
docs/superpowers/specs/2026-10-05-treasuryflow-ui-reconstruction-design.md new
+157
@@ -0,0 +1,157 @@
1 +# TreasuryFlow Product UI Reconstruction — Design Specification
2 +
3 +Date: 2026-10-05
4 +Status: Approved design direction; implementation pending written-spec review
5 +Visual source of truth: the previously approved nine-screen TreasuryFlow reference image in the project conversation.
6 +Cost constraint: development and runtime must not require paid tools, paid plugins, paid UI kits, or paid SaaS subscriptions.
7 +
8 +## 1. Goal
9 +Replace the current non-functional dashboard shell with a cohesive, RTL-first treasury operations application whose visual language and information architecture visibly match the approved nine-screen reference and whose primary controls execute real application flows rather than hash-link placeholders.
10 +
11 +## 2. Product acceptance criteria
12 +A release is not complete merely because it builds or returns HTTP 200. It is complete only when:
13 +1. The application visibly matches the approved reference in composition, density, hierarchy, RTL behavior, navigation, tables, forms, status badges, cards, and operational tone.
14 +2. Every primary navigation item opens a real route/view with meaningful content.
15 +3. Primary user actions change application state through validated application/domain services; no fake success actions.
16 +4. Empty, loading, validation, success, failure, permission-denied, and bank-unknown states are represented deliberately.
17 +5. Core flows are keyboard accessible and responsive at supported desktop widths.
18 +6. Automated tests cover navigation and critical workflows, not only server reachability.
19 +7. Desktop packaging opens the same complete product experience.
20 +
21 +## 3. Approved screen map
22 +The first implementation target follows the nine-screen reference:
23 +- Login / secure entry
24 +- Operations dashboard
25 +- Payments / transfers list
26 +- New transfer creation
27 +- Bank accounts
28 +- Reconciliation
29 +- Bank submission queue
30 +- Transfer result/detail
31 +- Reports
32 +
33 +Supporting routes required by the existing product shell:
34 +- Audit events
35 +- Beneficiaries/master data where needed by transfer creation
36 +- Settings/status surfaces only where backed by real configuration
37 +
38 +## 4. Information architecture
39 +Persistent RTL application shell:
40 +- Right-side navigation rail/sidebar
41 +- Product identity and environment indicator
42 +- Main navigation grouped by operations, controls, and reporting
43 +- Top utility/header area for page title, contextual actions, search/filter where applicable, user/role context, and system status
44 +- Main content canvas with constrained readable width on forms and full-width operational tables
45 +
46 +Navigation must use real Next.js routes, never fragment-only links for primary screens.
47 +
48 +## 5. Visual system
49 +The approved reference is authoritative. The implementation will derive a local design-token layer rather than importing a paid kit.
50 +
51 +Token families:
52 +- Neutral application background, elevated surfaces, borders, primary text, secondary text
53 +- Treasury accent and semantic success/warning/danger/info colors
54 +- Consistent radii, shadows, spacing scale, control heights, table density
55 +- Persian/RTL typography using locally available/free fonts only; system-safe fallback required
56 +- Iconography from a free/open-source icon set or simple CSS/SVG assets already allowed by the repository
57 +
58 +Reusable components:
59 +- AppShell, Sidebar, Header/PageHeader
60 +- StatCard, StatusBadge, EmptyState, AlertBanner
61 +- DataTable, FilterBar, Pagination
62 +- Button variants, Input, Select, Date/amount fields, Checkbox
63 +- FormSection, ReviewPanel, ConfirmationDialog
64 +- Timeline/stepper for transfer lifecycle
65 +- AccountCard and health/status indicator
66 +
67 +## 6. Functional behavior by screen
68 +### Login
69 +Production continues to rely on trusted external identity; local desktop mode may provide an explicit local-development entry surface without pretending to be production authentication.
70 +
71 +### Dashboard
72 +Show actionable treasury summary: payment queue counts/amounts, items needing review, reconciliation status, bank/channel health where evidence exists, and recent operational activity. Cards navigate to filtered operational views.
73 +
74 +### Payments
75 +Searchable/filterable table with reference, beneficiary, source account, amount, date, state, and available actions based on authorization. Row selection opens detail.
76 +
77 +### New transfer
78 +Validated multi-section form using Iranian normalization/IBAN and money rules already present in domain code. Submission creates a real local application record/state; maker/checker constraints remain enforced.
79 +
80 +### Bank accounts
81 +List/account cards backed by master data with status and identity fields. No fabricated live balances unless a real adapter supplies them.
82 +
83 +### Reconciliation
84 +Statement/reconciliation results use existing reconciliation domain logic. Unknown/unmatched states are first-class and manually reviewable.
85 +
86 +### Submission queue
87 +Only eligible/approved payments appear. Bank adapter remains disabled unless certified external configuration exists. Disabled/live-unavailable state must be explicit rather than simulated.
88 +
89 +### Transfer detail/result
90 +Lifecycle timeline, immutable references, approval state, bank state, reconciliation state, and audit context. UNKNOWN bank outcome never becomes synthetic success.
91 +
92 +### Reports
93 +Operational reports use real repository/domain data and support useful filtering. Export is implemented only when generated from actual visible/report data.
94 +
95 +### Audit
96 +Read-only audit explorer with filters and actor/action/time/context fields; no mutation actions.
97 +
98 +## 7. Application/data architecture
99 +Keep existing domain modules as the source of business rules. Add an application layer for UI use cases rather than moving business rules into React components.
100 +
101 +For desktop-local mode, introduce a durable local repository appropriate to the application (free/open-source, no external paid dependency) so actions persist across restarts. Production keeps the PostgreSQL adapter and tenant isolation contract.
102 +
103 +UI -> application service/use case -> domain rules -> repository/adapter.
104 +
105 +No screen may directly bypass authorization or domain transition rules.
106 +
107 +## 8. Safety and financial controls
108 +- Maker/checker separation remains mandatory where policy requires it.
109 +- Idempotency remains enforced for submission-sensitive actions.
110 +- Bank LIVE stays disabled without explicit external certification/configuration.
111 +- Unknown bank outcome remains UNKNOWN/manual review.
112 +- Audit-relevant actions emit audit events.
113 +- Tenant context remains server-side and fail-closed in production.
114 +- No secrets embedded in browser bundles or desktop package.
115 +
116 +## 9. Free-only tooling constraint
117 +Allowed implementation path must remain usable without payment:
118 +- Existing Next.js/React stack
119 +- Repository-local CSS/design tokens
120 +- Free/open-source packages only when needed
121 +- Figma Free only as an optional design workspace; the repository and approved reference remain sufficient sources of truth
122 +- No paid Figma libraries, premium icon packs, commercial UI templates, paid component kits, or paid deployment dependency
123 +
124 +If any tool reaches a paywall, it is replaced rather than purchased.
125 +
126 +## 10. Testing strategy
127 +Required gates:
128 +- Unit tests for application use cases and domain integration
129 +- Navigation tests proving every primary menu target renders the intended view
130 +- Form validation tests for transfer creation
131 +- State-transition/authorization tests for maker/checker actions
132 +- Persistence tests for desktop-local repository
133 +- Reconciliation and UNKNOWN-state regression tests
134 +- Accessibility checks for labels, focus, keyboard paths, and RTL semantics
135 +- Production build/typecheck/lint/audit
136 +- Desktop clean-install smoke test that exercises navigation and at least one safe local workflow, not only /api/ready
137 +
138 +## 11. Delivery sequence
139 +1. Design tokens + reusable shell/components
140 +2. Real routing + dashboard
141 +3. Payments list/detail + new transfer
142 +4. Accounts + beneficiaries/master data dependencies
143 +5. Reconciliation + submission queue
144 +6. Reports + audit
145 +7. Local persistence integration
146 +8. Full interaction/accessibility regression
147 +9. Desktop package rebuild and clean-install acceptance test
148 +
149 +## 12. Explicit non-goals for the UI reconstruction
150 +- Fabricating bank connectivity, balances, certifications, or production credentials
151 +- Enabling LIVE bank submission without external approval/evidence
152 +- Replacing the existing tested domain rules with UI-only logic
153 +- Introducing paid dependencies
154 +- Calling a static mockup a finished product
155 +
156 +## 13. Definition of done
157 +TreasuryFlow is accepted only when the approved reference and the running application can be compared side-by-side and the application is recognizably the same product family, while every primary screen and safe local workflow is operational and verified. Remaining external-bank/production provisioning items must be explicitly labeled external, not hidden behind fake UI success.