MUST use when editing src/routes/ segments, src/spa/router/desktopRouter.config.tsx or desktopRouter.config.desktop.tsx (always change both together), mobileRouter.config.tsx, or when moving UI/logic between routes and src/features/.
SPA structure:
src/spa/ – Entry points (entry.web.tsx, entry.mobile.tsx, entry.desktop.tsx) and router config (router/). Router lives here to avoid confusion with src/routes/.src/routes/ – Page segments only (roots).src/features/ – Business logic and UI by domain.This project uses a roots vs features split: src/routes/ only holds page segments; business logic and UI live in src/features/ by domain.
Agent constraint — desktop router parity: Edits to the desktop route tree must update both src/spa/router/desktopRouter.config.tsx and src/spa/router/desktopRouter.config.desktop.tsx in the same change (same paths, nesting, index routes, and segment registration). Updating only one causes drift; the missing tree can fail to register routes and surface as a blank screen or broken navigation on the affected build.
src/routes/src/features/src/routes/ (roots)Each route directory should contain only:
| File / folder | Purpose |
|---|---|
_layout/index.tsx or layout.tsx | Layout for this segment: wrap with <Outlet />, optional shell (e.g. sidebar + main). Should be thin: prefer re-exporting or composing from @/features/*. |
index.tsx or page.tsx | Page entry for this segment. Only import from features and render; no business logic. |
[param]/index.tsx (e.g. [id], [cronId]) | Dynamic segment page. Same rule: thin, delegate to features. |
Rule: Route files should only import and compose. No new features/ folders or heavy components inside src/routes/.
src/features/Put domain-oriented UI and logic here:
Organize by domain (e.g. Pages, Home, Agent, PageEditor), not by route path. One route can use several features; one feature can be used by several routes.
Each feature should:
src/features/<FeatureName>/index.ts or index.tsx@/features/<FeatureName>/... for internal imports when neededChoose the route group
(main)/ – desktop main app(mobile)/ – mobile(desktop)/ – Electron-specificonboarding/, share/ – special flowsCreate only segment files under src/routes/
src/routes/(main)/my-feature/_layout/index.tsx and src/routes/(main)/my-feature/index.tsx (and optional [id]/index.tsx).Implement layout and page content in src/features/
src/features/MyFeature/).index.Keep route files thin
export { default } from '@/features/MyFeature/MyLayout' or compose a few feature components + <Outlet />.@/features/MyFeature (or a specific subpath) and render; no business logic in the route file.Register the route (desktop — two files, always)
desktopRouter.config.tsx: Add the segment with dynamicElement / dynamicLayout pointing at route modules (e.g. @/routes/(main)/my-feature).desktopRouter.config.desktop.tsx: Mirror the same RouteObject shape: identical path / index / parent-child structure. Use the static imports and elements already used in that file (see neighboring routes). Do not register in only one of these files.mobileRouter.config.tsx instead (no need to duplicate into the desktop pair unless the route truly exists on both).desktopRouter.config × 2)| File | Role |
|---|---|
desktopRouter.config.tsx | Dynamic imports via dynamicElement / dynamicLayout — code-splitting; used by entry.web.tsx and entry.desktop.tsx. |
desktopRouter.config.desktop.tsx | Same route tree with synchronous imports — kept for Electron / local parity and predictable bundling. |
Anything that changes the tree (new segment, renamed path, moved layout, new child route) must be reflected in both files in one PR or commit. Remove routes from both when deleting.
| Question | Put in src/routes/ | Put in src/features/ |
|---|---|---|
| Is it the route’s layout wrapper or page entry? | Yes – _layout/index.tsx, index.tsx, [id]/index.tsx | No |
| Does it contain business logic or non-trivial UI? | No | Yes – under the right domain |
| Is it a reusable layout piece (sidebar, header, body)? | No | Yes |
| Is it a hook, store usage, or domain logic? | No | Yes |
| Is it only re-exporting or composing feature components? | Yes | No |
Examples
src/routes/(main)/page/_layout/index.tsx → export { default } from '@/features/Pages/PageLayout'src/features/Pages/PageLayout/ → Sidebar, DataSync, Body, Header, styles, etc.src/routes/(main)/page/index.tsx → Import PageTitle, PageExplorerPlaceholder from @/features/Pages and @/features/PageExplorer; render with <PageTitle /> and placeholder.src/features/Pages/.We are migrating existing routes to this structure step by step:
/page route – segment files in src/routes/(main)/page/, implementation in src/features/Pages/.When touching an old route that still has logic or features/ inside src/routes/:
src/features/<Domain>/ and importing from routes.git mv when moving files so history is preserved.Route (thin):
src/routes/(main)/page/
├── _layout/index.tsx → re-export or compose from @/features/Pages/PageLayout
├── index.tsx → import from @/features/Pages, @/features/PageExplorer
└── [id]/index.tsx → import from @/features/Pages, @/features/PageExplorer
Feature (implementation):
src/features/Pages/
├── index.ts → export PageLayout, PageTitle
├── PageTitle.tsx
└── PageLayout/
├── index.tsx → Sidebar + Outlet + DataSync
├── DataSync.tsx
├── Sidebar.tsx
├── style.ts
├── Body/ → list, actions, drawer, etc.
└── Header/ → breadcrumb, add button, etc.
Router config continues to point at route paths (e.g. @/routes/(main)/page, @/routes/(main)/page/_layout); route files then delegate to features.