Skip to content

🎨 Frontend Development

This section covers the SvelteKit frontend architecture, components, and development patterns.

πŸ“– Overview

LibreFolio's frontend is built with:

  • SvelteKit 2.x - Full-stack web framework
  • Svelte 5 - Reactive UI framework using Runes ($state, $derived, $effect)
  • Tailwind CSS 4.x - Utility-first CSS (configured via @theme in CSS)
  • TypeScript - Type safety
  • lucide-svelte - Icon library

πŸ“‚ Directory Structure

frontend/src/
β”œβ”€β”€ routes/           # SvelteKit pages and routing
β”‚   β”œβ”€β”€ (app)/        # Authenticated app routes (Dashboard, Brokers, etc.)
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ brokers/
β”‚   β”‚   β”‚   └── [id]/    # Broker detail page
β”‚   β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ transactions/
β”‚   β”‚   β”œβ”€β”€ fx/
β”‚   β”‚   β”œβ”€β”€ files/
β”‚   β”‚   └── settings/
β”‚   └── +page.svelte  # Login page (Public)
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ api/          # API client (Zodios, generated from OpenAPI)
β”‚   β”œβ”€β”€ components/   # Reusable components
β”‚   β”‚   β”œβ”€β”€ auth/     # LoginCard, RegisterCard, ForgotPasswordCard
β”‚   β”‚   β”œβ”€β”€ brokers/  # Broker cards, forms, icon, import
β”‚   β”‚   β”œβ”€β”€ files/    # FilesTable with DataTable
β”‚   β”‚   β”œβ”€β”€ layout/   # Sidebar, Header, LanguageSelector
β”‚   β”‚   β”œβ”€β”€ settings/ # Settings tabs (Profile, Preferences, Global, About)
β”‚   β”‚   β”œβ”€β”€ table/    # DataTable suite (ModalBase, ConfirmModal, etc.)
β”‚   β”‚   └── ui/       # Generic UI atoms
β”‚   β”‚       β”œβ”€β”€ input/    # PasswordInput, PasswordStrength
β”‚   β”‚       β”œβ”€β”€ media/    # ImageCropper, ImageEditModal, AssetPickerModal, FileEditModal
β”‚   β”‚       └── select/   # BaseDropdown, SimpleSelect, SearchSelect
β”‚   β”œβ”€β”€ i18n/         # Internationalization (EN, IT, FR, ES)
β”‚   β”œβ”€β”€ stores/       # Global state (Auth, Settings, Language)
β”‚   β”œβ”€β”€ types/        # TypeScript type definitions
β”‚   └── utils/        # Utilities (imageCrop, upload, urlFilters)
β”œβ”€β”€ e2e/              # Playwright E2E tests (7 suites, 109+ tests)
└── static/           # Static assets

⚑ Svelte 5 Runes

LibreFolio fully embraces Svelte 5's Runes for reactivity, replacing the legacy let and $ syntax.

πŸ”‘ Key Runes Used

  • $state: Declares reactive state.
    let count = $state(0);
    
  • $derived: Declares derived state (automatically updates when dependencies change).
    let double = $derived(count * 2);
    
  • $effect: Side effects (runs when dependencies change).
    $effect(() => {
        console.log(count);
    });
    
  • $props: Declares component props.
    let { title, active = false } = $props();
    

πŸ“š Documentation Sections


πŸ—οΈ Build & Development

Frontend tasks are managed via dev.py front:

# Start Vite dev server with Hot Module Replacement
./dev.py front dev

# Build for production (output in frontend/build/)
./dev.py front build

# Build with source maps for debugging
./dev.py front build --debug

# Type-check with svelte-check
./dev.py front check

# Preview production build locally
./dev.py front preview
Command Description
front dev Starts Vite at localhost:5173, proxies API calls to backend
front build Production build with minification and tree-shaking
front build --debug Build with source maps (useful for debugging deployed code)
front check Runs svelte-check for TypeScript and Svelte diagnostics
front preview Serves the production build locally for testing

Development workflow

Run ./dev.py server in one terminal and ./dev.py front dev in another. The Vite dev server proxies /api calls to the backend automatically.

Topic Description
DataTable Advanced table with sorting, filtering, pagination
FX Chain Algorithm DFS + graphology for multi-step FX routes
Authentication LoginCard, RegisterCard, ForgotPasswordCard
Settings User preferences, profile, and global settings
File Upload File uploader, image crop, asset picker