Client Architecture
Sliced Layouts & Routing Architecture
How create-modern-mern-app organizes the frontend into dedicated shells, sliced layout components, and lazy-loaded routes with React Router.
1. Sliced Shell Organization
Instead of monolithic page wrappers, navigation and shell components are sliced into client/src/layout/slices/:
client/src/layout/
├── WebsiteLayout.tsx # Public shell (Navbar + Content + Footer)
├── DashboardLayout.tsx # Authenticated shell (Sidebar + Header + Outlet)
└── slices/
├── Navbar.tsx # Public navigation bar
├── Footer.tsx # Public website footer
├── Sidebar.tsx # shadcn AppSidebar slice with collapsible nav
└── Header.tsx # Dashboard site header slice with SidebarTrigger
2. Route Registration & Lazy Loading (`client/src/App.tsx`)
All protected and heavy dashboard routes are dynamically split into asynchronous chunks:
App.tsx Route Hierarchy
typescript
import { Routes, Route } from 'react-router-dom';
import { lazy, Suspense } from 'react';
import { WebsiteLayout } from './layout/WebsiteLayout';
import { Home } from './pages/website/Home';
import { About } from './pages/website/About';
import { Contact } from './pages/website/Contact';
const Account = lazy(() => import('./pages/auth/Account'));
const DashboardLayout = lazy(() => import('./layout/DashboardLayout'));
const Overview = lazy(() => import('./pages/dashboard/Overview'));
const Members = lazy(() => import('./pages/dashboard/Members'));
export default function App() {
return (
Loading...