Blueprint
Dental SaaS app architecture
Blueprint page for the frontend app structure, route map, layouts, pages, state model, and UI system.
App structure
Folder structure
Recommended feature split for the current Next App Router codebase.
Route map
Pages and layouts
Concrete URL map and layout ownership.
State
State management
Client versus server responsibility split.
Resolve active user, role, organization, and tenant-scoped state snapshot. Lifetime: Per request.
Track theme mode, dashboard range, and inbox density. Lifetime: Per browser tab.
Lead status filter, selected conversation, and current onboarding focus. Lifetime: Per route session.
Leads, conversations, integrations, contracts, billing, and audit records. Lifetime: Persistent in storage.
Notice banners, pending actions, and optimistic interaction affordances. Lifetime: Ephemeral UI state.
Data
Data fetching strategy
Preferred fetching model for Next 16 App Router.
Use async Server Components and cache(async) bootstrap helpers that read cookies() and readAppState(). Keeps secrets and tenant authorization on the server.
Workspace layout resolves session, scopes AppState, and derives summary counts once. Avoids re-fetching the same state in each child component.
Theme, filters, and selected conversation stay inside a client provider instead of duplicating server data. Minimizes client bundle pressure and hydration work.
Client actions call /api/v1 endpoints; server remains the source of truth for changed state. Good fit for inbox replies, lead status changes, and integration setup.
Workspace routes use loading.tsx; long-running widgets should later move behind Suspense boundaries. Matches Next App Router recommendations for request-time data.
Design system
UI components and basics
Reusable primitives and token rules for the app shell.
All panels use the same surface, line, and shadow tokens for a consistent SaaS shell.
Eyebrows, h1 titles, and compact labels separate navigation, decision-making, and dense data.
Accent for healthy, amber for attention, red for risk, with pill badges across modules.
Cards, tables, rails, and inspectors share one spacing rhythm to keep the dashboard readable.
Dashboard
Dashboard widgets
Widget inventory for the overview screen.
New, unanswered, at-risk, booked, and lost lead totals with conversion context.
Average reply time, no-response pressure, and alert thresholds.
Conversion and volume by Telegram, web form, and future channels.
Assigned queue pressure and booked outcomes by staff member.
Clinic DB, Stripe, and intake provider readiness.
Messages, AI runs, integration count, and seat pressure.
Inbox
Inbox structure
Three-rail inbox information architecture.
Onboarding
Onboarding flow
Operational sequence from signup to first live sync.
Route: /register. Success: Owner can sign in and sees a tenant-scoped dashboard shell.
Route: /setup. Success: Managers, admins, and owners match the intended operating model.
Route: /integrations. Success: Telegram and web form are active; Clinic DB config is saved.
Route: /compliance. Success: Clinic DB data access contract is approved and audit recorded.
Route: /queue. Success: Imported leads appear in queue and inbox with correct tenant scope.
Route: /billing. Success: Billing method, payment reference, and plan limits are visible and usable.
Layouts
Layout map
Layout ownership and shell partitioning.
Owns fonts, globals, and the shared document shell.
Owns access-entry presentation and keeps auth routes separate from workspace chrome.
Owns tenant bootstrap, sidebar navigation, and the workspace state provider.
Owns super-admin navigation and platform-only context.
Pages
Page set
High-level page inventory for the MVP app shell.
/login, /register
/dashboard, /setup, /queue, /alerts, /leads, /inbox, /inbox/[conversationId]
/automations, /integrations, /ai
/reports, /billing, /compliance, /platform
Modules
Business modules
Channel and billing touchpoints exposed as widgets or admin summaries.