Desk v2 — the architecture: a report, one picture from the code, and guardrails
Author: shariquerikCreated Sep 28, 2026Updated Sep 29, 2026
Labelswayfinder:map
Child of #42061 (Desk v2 — the root map). Chartered 2026-09-28.
Destination
One written architecture of desk v2 that a new reader understands in an hour, and the tools that keep the code inside it. That is four things:
- A report that measures today's desk v2 against security, user experience, speed and simplicity, and ranks the cuts.
- A target architecture: the layers, the few concepts each layer has, and the main flows (boot, open a list, open a record, save, load a script), each with its permission checks, its cache and its cost.
- Guardrails: written rules, CI checks and one process rule that stop the code from drifting away from the architecture again.
- An interactive diagram built from the code. A hand-written layer file says which layer may use which. The diagram marks in red each place the code breaks it, and the same file drives a CI check.
The map is reached when the report and the target architecture are written and ruled on, the diagram and the checks are merged on desk-v2, and each accepted cut is a ticket on the map that owns its area.
Notes
- Why this map exists. The user, 2026-09-28: each ticket looked at its own feature, and nothing looked at the whole desk. The record page grew from 4,172 lines (2026-08-28) to 12,902 lines (2026-09-25). The goal is simple but flexible, not the most complex framework.
- This map builds, in part. The diagram and the guardrail checks are task tickets on this map. The code cuts that the report finds are not done here. Each goes to the map that owns its area, or to a new map.
- Scope.
frontend/, the Python shell infrappe/shell/, the desk v2 DocTypes, and the parts ofui/that the desk calls. CRM and ERPNext only where they connect to the desk. Not the internals offrappe-ui. - Fixed inputs. The program principles on the root map are not re-opened: the three authored tiers (app, site, per-user), one UI API that drives every surface by name, UI-first customization over scripting, REST API v2 only, and the
ui/versusfrontend/layer rule. Everything below them can be questioned, including merged code and closed rulings. Each proposed cut names the ruling it re-opens. - Order of goals when they conflict. Security is never traded. User experience comes next. Speed is a budget, not a maximum: each page gets a first-paint time and a request count, and when a page meets its budget, simpler code wins over more speed.
- Simple means few concepts, not few lines (user ruling, 2026-09-28). Code is simple when a new reader learns few names, finds one way to do each job, follows a flow through few files, sees each layer use only the layers below it, and does not reason about the order of async events. Simplicity is counted in concepts, pairs of mechanisms that do the same job, files per flow, layer breaks and cycles, and timing guards. Line count only shows where to look. It is never a budget and never a CI check, because a line budget pushes code to be dense.
ui/is a library for every app (user rulings, 2026-09-28). Everything inui/must stand on its own, so any app can use it without the desk.ui/may use only the framework server, REST API v2, and its own code: neverfrappe/shell/,frontend/, desk boot data or record-page words.ui/is new, so no app uses its components or composables yet, but apps will. "No app uses it today" is never a reason to cut or change something inui/. Judgeui/by what it exports, not by what desk v2 imports.- Guardrails take three forms. A written rule gets a CI check where a check is possible. A rule with no check becomes a fixed question in every review brief. A whole-desk review runs each time a map closes.
- The pause is lifted (2026-09-28). New build tickets on Desk v2 — one page model and Desk v2 — return visits paint at once were paused while the report was written, because both change the record page runtime. The hand-off task added their cut tickets and lifted the pause. On both maps the cut tickets come before any new build ticket.
- Research does not move the shared checkout. Read code from
upstream/desk-v2or agit worktree add. A measurement that needs a server uses the worktree server on a spare port, never a switch ofapps/frappe. - Skills:
/researchfor research tickets,/grilling+/domain-modelingfor grilling,/prototypefor the diagram prototype,/frappe-app-dev+/code-stylefor any code,/quality-code-reviewin a fresh subagent before a build PR opens. Review briefs also ask: can this be done with fewer concepts or less code?
Decisions so far
- Desk v2 simplification: where can the same job be done with fewer concepts and less code? — the record page is 12,902 lines, about 1,100 of them timing code; 15 ranked cuts, the top five worth about 525 lines and seven concepts. Input to the report, not re-measured.
- Desk v2 security: every door into the desk and the check at each door — 66 doors, no high gap, 4 medium: email HTML parsed in the live page before the sandbox, site defaults sent to Website Users, DocType names listed to guests by the v2 link search, attachment list with no read check.
- Desk v2 speed: what each page costs on a cold load and a return visit — a cold record is usable in 681 ms on a 4x slower CPU (desk v1: 998 ms), 9 API calls, 734 KB JS; the cost is the browser, not the server; the rich-text editor loads only to show saved comments; three candidate budgets fail today.
- Desk v2 structure: layers, concepts, extension points and the import graph — 114 concepts outside the record page; 13 folders import each other in one loop; 5 layer breaks; 26 ways to change the desk, 10 pairs doing one job;
graph.jsonfor the diagram. - Desk v2 user experience: what a person sees while a page loads, fails and saves — a slow network shows a white page for up to 73 s; the sidebar pushes content 224 px; a save confirms nothing; a validation error does not mark the field; 8 consistency breaks and keyboard gaps.
- The desk v2 report: today's code against security, user experience, speed and simplicity — security sound at the core with four medium gaps; faster than desk v1 on a normal network, poor on a slow one and after a save; simplicity is the weak goal (110 files to open a record, 10 duplicate mechanisms); 31 cuts ranked, top ten each named with its owning map.
- The target architecture: which layers, concepts and flows desk v2 keeps — 9 layers,
main.tson top,ui/stands on its own; a closed concept list per layer in a newfrontend/ARCHITECTURE.md; 22 cuts accepted, 2 kept untilonOpen, 10 refused; 16 changes soui/works in any app; theui/"./*"export stays for now. - Desk v2 architecture: write ARCHITECTURE.md from the target architecture —
frontend/ARCHITECTURE.mdmerged ondesk-v2: 9 layers, a closed concept list per layer, the five flows after the cuts, and a list of gaps in today's code with owners; six documents link to it; 13 open placement choices accepted with the PR. - Desk v2 architecture: hand the accepted cuts to the maps that own them — 32 tickets on five maps, each cut ticket waiting on the security fixes; the 11 items with no open owner wait for the new map's charting; cut 6 and
ui/change U5 each re-open a closed ruling the report missed. - The guardrails: written rules, CI checks, budgets and the whole-desk review — a baseline file that a PR may lower but only raise by a visible edit; CI checks layers, folder loops, the concept list, JS bytes and API calls per page, and that every test file runs; timings and files per flow go to a whole-desk review at each map close; the report's budgets; four fixed review questions; a six-field cost line in every build PR; the line-count rules leave
AGENTS.md; four build tickets. - Desk v2 architecture: chart the new map for the shell, the list, the router and the server routes — charted the shell, the list, the router and the server routes under the root map; it builds, and is reached when all 11 items are merged and four budgets pass; the "latest reply wins" helper goes in
uidata for all 12 counters outside the record page; one new grilling ticket, because the form layout loader that cut 10 called dead is live. - Desk v2 guardrails: CI runs every test file — merged: vitest runs every
*.test.tsunderfrontend/andui/src(213 files), and CI fails on a test file it does not run; the 50 unrunui/files had 7 stale failures, all fixed, none a code bug;ui/now declaresreka-ui. - Desk v2 guardrails: CI speed checks for JS bytes and API calls per page — merged:
frontend/speed-budgets.jsonholds the tolerance, budgets and baselines; a Vite build check fails a page more than 5 KB above its baseline, and a Cypress spec fails a cold load or save that sends more calls than its baseline; record is 13 calls on a ToDo because the page searches every link field at load, User twice.
Not yet specified
- The build tasks for the diagram. Their shape waits on the diagram prototype. The CI checks are already tickets.
- A possible defect from the report: a script's change can be credited to the wrong script. It needs a reproduction before it becomes a ticket. (The
/address defect is fixed by accepted cut 23.) - Two translate functions. A planned
ui/change givesui/its own__, and the desk keeps__and__n. Whether the desk's pair wrapsui/'s or stays apart is open; it is one of the pairs the guardrails count.
Out of scope
- Doing the code cuts. They go to the maps that own each area.
- Changing the program principles listed under Fixed inputs.
- The internals of
frappe-ui, and CRM or ERPNext code beyond the point where it connects to the desk.
Source: frappe/frappe