Client shell and navigation
The client shell is the shared frame around the CRM single-page application. It starts the Vue app, checks the user session, chooses a desktop or mobile frame, and directs each URL to the right CRM workspace while keeping common navigation, settings, notifications, and dialogs available.
Application initialization
The application starts in frontend/…/main.js. It creates the Vue app, installs Pinia and the router, loads shared UI and translation services, and attaches dialog and real-time socket services before mounting the app. Development mode first loads server context so local sessions have the same basic data as a deployed session.
The initialization path moves from shared services to the shell and then to the current route. This keeps pages focused on CRM work rather than session setup or global UI wiring.
flowchart TD
A[Browser opens CRM] --> B[Create Vue app]
B --> C[Install UI, state, router, and translation services]
C --> D[Create socket and global dialog services]
D --> E{Development mode?}
E -->|Yes| F[Load development context]
E -->|No| G[Use page context]
F --> H[Mount App]
G --> H
H --> I[Check session and route]
I --> J[Render shell and page]
Service bootstrap
The bootstrap layer provides a shared request path through Frappe UI. It also exposes socket and dialog services to pages through application-wide properties. The root app sets time zone and translation context before normal page content appears (frontend/…/main.js, frontend/…/App.vue).
References: frontend/…/main.js• L1-81 frontend/…/App.vue• L1-48 frontend/…/socket.js• L1-27
Route handling
The router maps CRM concepts to named routes under the /crm browser history base. List routes support a view type or saved view. Record routes carry a record identifier. The route guard turns a valid URL into an allowed and usable destination.
Route map
The main route groups are:
| Route group | User purpose |
|---|---|
| Dashboard | Review the CRM home workspace and metrics |
| Leads, Deals, Contacts, Organizations | Browse records or open one record |
| Notes, Tasks, Call Logs | Work with shared productivity areas |
| Data import | Start or review imports |
| Notifications | Review mobile notification content or the shared desktop panel |
| Welcome and Onboarding | Complete first-use or persona steps |
| Setup | Complete required initial CRM setup for an eligible administrator |
| Not Permitted and Invalid Page | Explain access or route errors |
List routes accept list, kanban, or group_by as standard view types. A saved view can also appear in the URL and in the sidebar. Detail routes use a saved last tab when the URL does not name one, so a return to a lead or deal preserves the user's work area.
The views store keeps default destinations by route name. It also resolves a standard view by doctype and view type when a list URL does not name a saved view. This lets each CRM area keep its own home choice while still providing a predictable list view.
References: frontend/…/router.js• L31-152 frontend/…/router.js• L216-307 frontend/…/Leads.vue• L1-30 frontend/…/Deals.vue• L1-29 frontend/…/Lead.vue• L1-49 frontend/…/views.js• L14-75
Navigation guards
The guard applies access and destination rules before a page renders:
- It reads the session and waits for the user list when that data is not ready.
- It sends signed-out users to login with a return path to CRM.
- It sends signed-in users without CRM access to the access-denied page.
- It sends an eligible administrator to setup when the server shows that first-time setup is incomplete. The setup route is not available after setup is complete.
- It resolves the home route to the user's default view and falls back to Leads when no default exists.
- It fills in a record tab or list view when the URL omits one.
This makes direct links and browser navigation follow the same rules as clicks in the shell. The views store supplies default, standard, public, and pinned view information to the guard and the sidebar.
References: frontend/…/router.js• L7-29 frontend/…/router.js• L163-215 frontend/…/router.js• L216-307 frontend/…/views.js• L49-100
Responsive shells
The root app chooses the page frame from the browser width. The desktop frame keeps navigation visible beside the page. The mobile frame replaces it with a drawer and a compact header. Both frames provide the same page slot and global modal area, so CRM pages can share their main flow across screen sizes.
Desktop frame
DesktopLayout places the application sidebar on the left and the page header plus route content on the right. It keeps global modals mounted outside the page slot and starts availability tracking when the desktop shell is created. The sidebar can collapse to a rail and stores that choice for later visits.
References: frontend/…/App.vue• L31-43 frontend/…/DesktopLayout.vue• L1-19 frontend/…/AppSidebar.vue• L11-18 frontend/…/AppSidebar.vue• L263-267
Mobile frame
MobileLayout uses the same page slot but opens the sidebar as a drawer over the current page. The drawer has an outside-click overlay and closes after route changes. Record routes select mobile record pages at the narrower route breakpoint, while list and utility pages keep their shared page route.
The shell uses a 640-pixel cutoff to choose the frame. Record component selection uses a 768-pixel cutoff. This difference lets the frame stay compact while a record page switches to its mobile presentation at a wider width.
References: frontend/…/App.vue• L31-43 frontend/…/MobileLayout.vue• L1-15 frontend/…/MobileSidebar.vue• L1-56 frontend/…/router.js• L53-68 frontend/…/router.js• L89-104 frontend/…/router.js• L154-156
Global stores
Pinia stores and shared composables hold state that must survive route changes or coordinate several parts of the shell. They provide a common view of the session, users, saved views, site settings, notifications, metadata, statuses, and shared actions.
Session and access state
The session store derives the current user from the browser session cookie. It exposes login and logout resources plus a reactive isLoggedIn value. Successful login returns the user to the CRM home route. Logout clears local session state and returns the browser to login.
The users store supplies CRM membership and role checks to the router, sidebar, settings, and pages. It loads the small CRM user set first, then fills broader user details in the background. This lets access checks and the first screen respond quickly without giving up user information needed by later features.
References: frontend/…/session.js• L7-37 frontend/…/users.js• L7-41 frontend/…/users.js• L136-182 frontend/…/router.js• L166-189
Shared product state
The main shared state areas are:
| State area | Role in the client shell |
|---|---|
| Views | Resolves default, standard, public, and pinned navigation destinations |
| Settings and brand | Supplies site name, logo, favicon, and global CRM settings |
| Notifications | Loads the latest notices, tracks the unread total, and controls the notification panel |
| Metadata | Supplies doctype fields, user layout settings, and value formatting to shared record surfaces |
| Statuses | Supplies lead, deal, and communication status labels and colors |
| Global actions | Shares dialogs, sockets, and the active make-call action |
The views store loads saved view data and groups it by its navigation role. Route defaults remain tied to route names, while standard views remain tied to a doctype and view type. This gives the router and sidebar one shared source for both home destinations and saved navigation.
Metadata is shared in a similar way. A doctype definition is loaded once into the common metadata state, then record surfaces can use its fields, grid settings, user layout settings, and number or currency rules without each page rebuilding that context.
Notifications keep the latest notice list and the unread total as separate shared resources. Loading the list refreshes the total, and marking selected notices as read reloads the list. The store avoids sending an empty selection because that action means mark every notice as read.
These stores do not replace page data. They provide shared context so a page, a navigation control, and a global overlay can respond to the same user or site state.
References: frontend/…/views.js• L5-100 frontend/…/meta.js• L6-32 frontend/…/meta.js• L75-157 frontend/…/settings.js• L4-30 frontend/…/notifications.js• L6-56 frontend/…/statuses.js• L8-29 frontend/…/global.js• L4-23
Layout navigation
Navigation is built from reusable shell components rather than from each page. The sidebar offers core CRM areas and saved views. The header gives pages a shared target for local actions. The user menu opens settings, app switching, help, account actions, and logout without changing the current page route.
Record list navigation
The Leads and Deals pages connect record workspaces to the shared shell. Each page places breadcrumbs and create actions in LayoutHeader, then lets the current URL choose a list, grouped, or kanban presentation through shared view controls. A row or kanban card leads to the matching record route while local actions can create notes, tasks, calls, or a new record without leaving the workspace (frontend/…/Leads.vue, frontend/…/Deals.vue).
The lead workspace also accepts a broadcast create event. This gives another shell-level action a direct way to open the lead form while preserving the current navigation context. Both workspaces keep custom list actions and saved-view changes inside the same route and header contract.
References: frontend/…/Leads.vue• L1-44 frontend/…/Leads.vue• L235-267 frontend/…/Leads.vue• L316-327 frontend/…/Deals.vue• L1-43 frontend/…/Deals.vue• L209-241 frontend/…/Deals.vue• L287-297
Sidebar navigation
AppSidebar builds an All Views group from the core CRM routes. It adds public and pinned views from the views store, so a saved view becomes a normal navigation destination with its route, view type, and view name. The active row follows the route or saved-view query and updates immediately on a normal click. Modified clicks leave the current highlight unchanged so opening a link in another tab does not alter the current page state. The sidebar's outer column provides both a positioning context for the notification panel and a visible surface behind the navigation in dark mode.
The sidebar also gives users quick access to search and the optional Flow launcher. On desktop it owns the notification panel, help and onboarding entry points, demo controls, collapse control, and trial billing prompt. On eligible cloud sites, the trial card turns billing state into a short status message and opens cloud billing when the user chooses a plan. An active trial can be dismissed for a limited time, while an ended trial remains visible. On mobile it reuses the same menu data, hides desktop-only destinations, and closes the drawer after selection. Onboarding links can open a route or the settings workspace, so first-use guidance connects navigation with the work it describes.
The sidebar keeps the notification count inside the clickable notification row. This makes the count part of the same action as the label and avoids a separate click target that would not open the panel. Its scroll area also preserves row size and active-row shadow space when the view list is longer than the available height.
References: frontend/…/AppSidebar.vue• L1-18 frontend/…/AppSidebar.vue• L21-41 frontend/…/AppSidebar.vue• L60-88 frontend/…/AppSidebar.vue• L140-184 frontend/…/AppSidebar.vue• L238-374 frontend/…/TrialCard.vue• L1-31 frontend/…/trialCard.js• L51-87 frontend/…/trialCard.js• L11-43
Header and overlays
LayoutHeader lets a route place page-specific controls in the shell header through named slots. It teleports that content to the header target supplied by the desktop or mobile frame. This keeps page actions aligned with the active shell while the route owns the action content.
Global dialogs, document modals, event alerts, and call controls remain mounted at shell level. The notification panel shows the shared notice list and uses the separate unread total for its sidebar badge. Socket events reload the list, which then refreshes the unread total. Desktop notifications open beside the sidebar. Mobile notifications use a route and a mobile page.
References: frontend/…/LayoutHeader.vue• L1-25 frontend/…/AppHeader.vue• L1-12 frontend/…/MobileAppHeader.vue• L1-21 frontend/…/App.vue• L3-11 frontend/…/Notifications.vue• L1-25 frontend/…/Notifications.vue• L115-131 frontend/…/GlobalModals.vue• L1-40
User and settings navigation
The user menu displays the active brand and user, then builds actions from CRM settings. It can open the settings dialog, switch to Desk or another installed app, show product information, or log out. Settings use a second navigation layer inside a dialog; the visible tabs change with the user's role and installed integrations.
The settings dialog is therefore a shell-level workspace rather than a route. Pages inside it share the current session and can update site settings without replacing the main CRM destination.
References: frontend/…/UserDropdown.vue• L1-45 frontend/…/UserDropdown.vue• L71-173 frontend/…/Settings.vue• L1-47 frontend/…/Settings.vue• L100-265
Related client areas
The shell supplies the route and shared context for two major client areas. Client record views explains the list, board, filter, and record surfaces that appear in the route content slot. Dashboards and workspaces explains dashboard content and configurable workspaces reached from the shell. The parent page, CRM client application, describes how these pieces fit with the wider Vue application and its server connection.
Change checklist
When these files or sections are changed, remember to consider these:
- A new or renamed page route must also update sidebar route names, saved-view resolution, mobile detail selection, setup redirects, and notification links when those paths can target the page.
- A change to the route base or login redirect must stay aligned with the server entry path and direct-link behavior.
- A change to the desktop or mobile breakpoint must be checked against both shell selection and record component selection because they use separate thresholds.
- A new global overlay or shared action must be mounted in the shell and connected to the global store or shell-level service that can reach it.
- A change to user loading or CRM role checks must preserve both the fast access decision and the later user-detail lookup.
- A change to setup completion must keep the server setting, the client completion flag, administrator eligibility, and the setup route guard in the same state model.
- A change to view names, route defaults, or view types must keep the URL parameters, per-route default rules, doctype standard-view lookup, and sidebar links in the same shape.
- A change to doctype metadata or saved user layout settings must preserve the shared metadata cache and the server format used to save those settings.
- A change to lead or deal list actions must preserve the shared header, view-control, record-route, and context-action contract used by both workspaces.
- A change to sidebar surface or overflow behavior must preserve both notification-panel placement and the sidebar background across light and dark themes.
- A change to sidebar shortcuts must preserve the mobile drawer close behavior for search, Flow, notifications, and route selection.
- A change to sidebar links must keep normal-click highlighting separate from modified-click behavior so opening a link in another tab does not change the current page.
- A change to notification loading or read actions must keep the notice list, unread total, socket refresh, and selected-document contract aligned.
- A change to the trial card or billing dialog must keep cloud-site eligibility, billing refresh after plan changes, dismissal rules, and upgrade telemetry aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The session cookie is absent or identifies Guest | The router sends the browser to login instead of rendering CRM | Keep session detection and the /login?redirect-to=/crm path aligned |
| A signed-in user is not in the CRM user set | The user sees the access-denied page and cannot enter CRM routes | Keep the user resource available before the CRM membership check |
| An eligible administrator has not completed setup | The router redirects the user to setup before normal CRM work | Keep the server setup value and the client completion flag aligned |
| A list URL has no valid view type or saved view | The router can fall back to the wrong list presentation or lose the saved view | Resolve standard view types and named views through the views store |
| Default view data is loaded without its route name or doctype context | The home route or list route can open the wrong destination | Keep route defaults keyed by route name and standard views keyed by doctype and type |
| A record URL has no hash | The record opens without the user's last activity tab unless the guard adds it | Preserve the per-record last-tab keys and route hash handling |
| Mobile drawer state remains open after navigation | The drawer can cover the new page | Close it on both sidebar selection and route changes |
| A mobile shortcut keeps the drawer open while opening a global action | Search or Flow can open behind the drawer and block the page | Use the shared close wrapper before opening the command palette or Flow launcher |
| A cached resource receives a real-time refresh event but has no matching cache key | The visible data stays stale after a server event | Keep resource cache keys usable by the socket refresh handler |
| A notification list refreshes without its unread count being refreshed | The sidebar badge can show an old unread total | Keep successful list loads connected to unread-count reloads |
| A lead or deal page stops passing the active view context to record links | Opening a record loses the saved view or view type when the user returns | Keep list and kanban links tied to the current route query |
| A doctype field or user setting changes without updating shared metadata state | Record forms or grids can show stale fields, layout rules, or number formats | Load metadata through the shared cache and update saved settings through its common path |
| Billing state or cloud-settings availability is unavailable when the trial card loads | The billing prompt can be hidden or show old trial information | Gate the card by cloud settings and retain cached trial state while refreshing it |
| A billing dialog closes without refreshing trial state | The sidebar can continue to show an ended or active trial after a plan change | Refresh the shared trial state when cloud billing closes |
Key files
| File | Why to read it |
|---|---|
| frontend/…/main.js | Shows the client bootstrap order and shared service registration |
| frontend/…/App.vue | Shows session-aware rendering, shell choice, global overlays, and app context |
| frontend/…/router.js | Defines route groups and the access, setup, default-view, and tab rules |
| frontend/…/DesktopLayout.vue | Shows the desktop shell composition and availability startup |
| frontend/…/MobileLayout.vue | Shows the mobile shell composition |
| frontend/…/AppSidebar.vue | Shows core navigation, saved views, search and Flow shortcuts, notifications, onboarding, billing prompt, and shell actions |
| frontend/…/TrialCard.vue | Shows how trial status becomes a sidebar action and opens billing settings |
| frontend/…/trialCard.js | Defines shared trial loading, cache, refresh, and dismissal behavior |
| frontend/…/cloudSettings.js | Defines cloud billing dialog availability and lifecycle |
| frontend/…/trialCard.js | Defines the user-facing trial states and actions |
| frontend/…/MobileSidebar.vue | Shows the mobile drawer and route-based close behavior |
| frontend/…/LayoutHeader.vue | Shows how route headers join the shared shell header |
| frontend/…/Notifications.vue | Shows the notification panel, filters, socket refresh, and read actions |
| frontend/…/Leads.vue | Shows how the lead workspace connects list, kanban, creation, and shell actions |
| frontend/…/Deals.vue | Shows how the deal workspace connects list, kanban, creation, and shell actions |
| frontend/…/session.js | Defines the client session state and login/logout behavior |
| frontend/…/users.js | Defines CRM membership and role information used by access and navigation |
| frontend/…/views.js | Defines route defaults, standard views, and saved view data used by routes and the sidebar |
| frontend/…/meta.js | Defines shared doctype metadata, user layout settings, and field value rules |
| frontend/…/notifications.js | Defines the shared notice list, unread count, panel state, and read contract |
| frontend/…/Settings.vue | Shows the role-aware settings navigation workspace |
| frontend/…/socket.js | Shows how real-time events refresh shared client resources |