# Page and Route Creation Guide
This guide explains how to create pages and routes in the dashboard application, following the established patterns and architecture.
## Table of Contents
1. [Route Structure Overview](#route-structure-overview)
2. [Creating Basic Pages](#creating-basic-pages)
3. [Creating Settings Pages](#creating-settings-pages)
4. [Creating Feature Pages](#creating-feature-pages)
5. [Layout Patterns](#layout-patterns)
6. [Form Patterns (Field.Group)](#form-patterns-fieldgroup)
7. [Navigation Setup](#navigation-setup)
8. [Breadcrumb Setup](#breadcrumb-setup)
---
## Route Structure Overview
The dashboard has two main route contexts:
### 1. Organization Routes (`/org/[slug]/...`)
- Uses `OrgSidebar` and `AppHeader`
- Path pattern: `/org/[slug]/[feature]`
- Example: `/org/acme/courses`, `/org/acme/settings`
### 2. LMS Routes (`/lms/...`)
- Uses `LMSSidebar` and `LmsHeader`
- Path pattern: `/lms/[feature]`
- Example: `/lms/community`, `/lms/settings`
---
## Creating Basic Pages
### Step 1: Create the Route File
**Location**: `apps/dashboard/src/routes/[context]/[feature]/+page.svelte`
**Pattern**:
```svelte
Feature Name - ClassroomIO{$t('feature.title')}
{#snippet child()}
{/snippet}
```
### Step 2: Create the Feature Page Component
**Location**: `apps/dashboard/src/lib/features/[feature]/pages/[feature].svelte`
**Pattern**:
```svelte
{#if isLoading}
{:else if !data.length}
{:else}
{#each data as item}
{/each}
{/if}
```
### Step 3: Export the Page
**Location**: `apps/dashboard/src/lib/features/[feature]/pages/index.ts`
```typescript
export { default as FeaturePage } from './feature.svelte';
```
---
## Creating Settings Pages
Settings pages follow a specific pattern with layouts and subroutes.
### Step 1: Create Settings Layout
**Location**: `apps/dashboard/src/routes/[context]/settings/+layout.svelte`
```svelte
{@render children?.()}
```
### Step 2: Create Default Settings Page
**Location**: `apps/dashboard/src/routes/[context]/settings/+page.svelte`
```svelte
Settings - ClassroomIO{$t('settings.heading')}
{#snippet child()}
{/snippet}
```
### Step 3: Create Settings Subroute
**Location**: `apps/dashboard/src/routes/[context]/settings/[subroute]/+page.svelte`
```svelte
Subroute Name - ClassroomIO{$t('settings.subroute.heading')}
{#snippet child()}
{/snippet}
```
**Note**: Settings pages use subroutes instead of tabs. Each subroute has its own `+page.svelte` file.
---
## Creating Feature Pages
### Feature Page Structure
Feature pages contain all business logic and should be placed in `lib/features/[feature]/pages/`.
**Key Principles**:
- ✅ All business logic goes in the feature page
- ✅ Use `Page.BodyHeader` for filters, search, and view toggles
- ✅ Use `Empty` component for empty states
- ✅ Use `Search` component for search inputs
- ✅ Handle loading states with skeleton/loader components
- ❌ Don't use `Page.Header` or `Page.Action` in feature pages (these are in route files)
### Example Feature Page
```svelte
All
{#if isLoading}
{:else if !discussions.length}
{:else}
{#each discussions as discussion}
{/each}
{/if}