Skip to content

Frontend Development Guide

This guide covers development setup for the RecordPlatform frontend application.

Technology Stack

CategoryTechnologyVersion
FrameworkSvelte 5 + SvelteKit 25.46+ / 2.49+
LanguageTypeScript5.9+
StylingTailwind CSS4.1+
Build ToolVite6.0+
Package Managerpnpm10.26+
UI ComponentsBits UI + Lucide Icons-

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm 10+

Development Setup

bash
cd platform-frontend

# Install dependencies
pnpm install

# Start development server
pnpm dev

The development server runs at http://localhost:5173.

Available Scripts

CommandDescription
pnpm devStart development server
pnpm buildBuild for production
pnpm previewPreview production build
pnpm checkTypeScript type checking
pnpm lintRun ESLint
pnpm formatFormat code with Prettier
pnpm types:genGenerate API types from OpenAPI

Environment Variables

Create .env file in platform-frontend/:

VariableDescriptionExample
PUBLIC_API_BASE_URLBackend API URLhttp://localhost:8000/record-platform
PUBLIC_ENVEnvironment namedevelopment
PUBLIC_TENANT_IDDefault tenant ID1

Project Structure

platform-frontend/
├── src/
│   ├── routes/              # SvelteKit pages
│   │   ├── (app)/           # Authenticated routes
│   │   │   ├── dashboard/   # Dashboard page
│   │   │   ├── files/       # File management
│   │   │   └── admin/       # Admin pages
│   │   ├── (auth)/          # Authentication routes
│   │   │   ├── login/
│   │   │   └── register/
│   │   └── share/           # Public share pages
│   ├── lib/
│   │   ├── api/             # API client
│   │   │   ├── client.ts    # HTTP client wrapper
│   │   │   ├── endpoints/   # API endpoint functions
│   │   │   └── types/       # TypeScript types
│   │   ├── components/      # Reusable components
│   │   │   └── ui/          # Base UI components
│   │   ├── stores/          # Svelte 5 runes stores
│   │   └── utils/           # Utility functions
│   ├── app.css              # Global styles
│   ├── app.html             # HTML template
│   └── app.d.ts             # Global type declarations
├── static/                  # Static assets
└── svelte.config.js         # SvelteKit config

Key Stores

The application uses Svelte 5 runes-based stores:

StoreFilePurpose
Authauth.svelte.tsUser authentication state, JWT management
SSEsse.svelte.tsServer-Sent Events connection
SSE Leadersse-leader.svelte.tsMulti-tab leader election
Uploadupload.svelte.tsFile upload queue with chunking
Downloaddownload.svelte.tsFile download manager
Notificationsnotifications.svelte.tsToast notifications
Badgesbadges.svelte.tsUI badge counts

Store Usage Example

svelte
<script>
  import { auth } from '$lib/stores/auth.svelte';

  // Reactive access with Svelte 5 runes
  const user = $derived(auth.user);
  const isAuthenticated = $derived(auth.isAuthenticated);
</script>

{#if isAuthenticated}
  <p>Welcome, {user?.username}</p>
{/if}

API Client

Type Generation

Generate TypeScript types from backend OpenAPI spec:

bash
# Ensure backend is running at localhost:8000
pnpm types:gen

This generates src/lib/api/types/generated.ts with full API types.

Making API Calls

typescript
import { filesApi } from '$lib/api/endpoints/files';

// List user files
const files = await filesApi.list({ page: 1, size: 20 });

// Upload file
const result = await filesApi.upload(file, {
  onProgress: (progress) => console.log(`${progress}%`)
});

Chunked File Upload

The upload system uses dynamic chunk sizing:

File SizeChunk Size
< 10MB2MB
< 100MB5MB
< 500MB10MB
< 2GB20MB
>= 2GB50MB

Upload process:

  1. Calculate optimal chunk size
  2. Start upload session (/file/upload/start)
  3. Upload chunks with progress tracking
  4. Merge chunks (/file/upload/merge)

Build for Production

bash
# Build static site
pnpm build

# Preview build locally
pnpm preview

The build output is in build/ directory, ready for static hosting.

Code Style

  • Use TypeScript strict mode
  • Follow existing component patterns
  • Use Tailwind CSS for styling
  • Keep components small and focused
  • Use stores for shared state

Component Template

svelte
<script lang="ts">
  import { type ComponentProps } from 'svelte';

  interface Props {
    title: string;
    variant?: 'default' | 'primary';
  }

  let { title, variant = 'default' }: Props = $props();
</script>

<div class="component {variant}">
  <h2>{title}</h2>
  {@render children?.()}
</div>

Released under the Apache 2.0 License.