This document outlines the architectural constraints and coding conventions for the refactored Next.js frontend.
- Framework: Next.js 14+ (App Router).
- Language: TypeScript (Strict mode).
- Styling: Tailwind CSS v4.
- UI Components: shadcn/ui (based on @base-ui/react).
- State Management: Zustand.
- Data Fetching: TanStack Query (React Query) v5.
- Runtime: Tauri v2.
- Ambient Background: Use vibrant mesh gradients defined in
globals.cssthat sync with the active theme. - Glass Material:
- Use
.glass-sidebarfor the navigation bar. - Use
.glass-headerfor the top bar. - Use
.glass-cardfor main content containers.
- Use
- Performance Mode: Always respect the
low-transparencyclass on thebody. When active, all blurs and gradients MUST be disabled in favor of solid colors (var(--card-solid)). - Themes: Support all 11 core themes (Enterprise Blue, Pure Black, Dark One, etc.) using
next-themes.
- Logic Separation: Keep components "dumb" by moving complex logic into custom hooks (e.g.,
useAccounts,useDashboardStats). - Semantic HTML: Avoid nested
<button>elements. Userender={<span />}andnativeButton={false}on triggers (like DropdownMenuTrigger) to maintain accessibility without breaking HTML specs. - Client Components: Mark interactive components with
"use client". Prefer Server Components for static layouts where possible.
- Transport: Use the centralized
invokeandinvokeFirsthelpers from@/lib/api/transport. - Addressing: Always use
withAddr()to wrap IPC parameters ensuring the backend service address is correctly injected. - Error Handling: Standardize business error unwrapping in the transport layer to show consistent toast notifications.
- No Fetch for IPC: Do not use
fetch()for backend commands in the desktop environment; use Tauri's nativeinvokefor maximum reliability and speed.
app/: Routing and page layouts.components/ui/: Atomic shadcn components.components/modals/: Feature-specific dialogs.hooks/: Business logic hooks.lib/api/: Typed backend client wrappers.store/: Zustand global state stores.types/: Shared TypeScript interfaces.
- Validation: Every significant change must be verified with
pnpm run build:desktopto ensure static export compatibility. - Sync: Ensure all new backend commands are added to
lib/api/with correct underscore/camelCase mapping.