๐จ 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
@themein 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 (DataTable, toolbar, pagination, column filter, SelectionBar)
โ โ โโโ ui/ # Generic UI atoms
โ โ โโโ input/ # PasswordInput, PasswordStrength
โ โ โโโ media/ # ImageCropper, ImageEditModal, AssetPickerModal, FileEditModal
โ โ โโโ modals/ # ModalBase, ConfirmModal
โ โ โโโ select/ # SimpleSelect, SearchSelect + specialized selects
โ โ โโโ tabs/ # TabBar (used standalone and by PageToolbar)
โ โ โโโ toolbar/ # PageToolbar โ shared responsive shell (see Toolbar & Responsive Layout)
โ โโโ i18n/ # Internationalization (EN, IT, FR, ES)
โ โโโ stores/ # Store Client System (State Management)
โ โ โโโ app/ # auth, clientSession, settings, globalSettings, themeStore, language, privacyStore, toastStore, โฆ
โ โ โโโ core/ # EntityStore, EditBuffer, TimeSeriesStore
โ โ โโโ reference/ # brokerStore, assetStore, currencyStore, countryStore, sectorStore, fxRoutesStore
โ โ โโโ portfolio/ # portfolioStore (report cache), portfolioMutation, lotsAnalysisStore, dashboardViewStore
โ โ โโโ risk/ # riskStore, riskBenchmarkStore, riskPanelController
โ โ โโโ transactions/ # txStore, transactionTypeStore
โ โ โโโ fx/ # fxCardInversionStore
โ โ โโโ files/ # imagePreviewCache
โ โ โโโ assetPriceStoreRegistry.ts # Registry: price series per asset and currency
โ โ โโโ fxStoreRegistry.ts # Registry: rate series per FX pair
โ โ โโโ dateRangeStore.svelte.ts # Date range shared by the pages
โ โ โโโ dateRangeController.svelte.ts # Per-page wiring of that date range
โ โ โโโ chartSettingsStore.svelte.ts # Chart aesthetics and signal configs (localStorage)
โ โ โโโ currencyGraphStore.ts # FX currency graph (session cache)
โ โ โโโ signalCatalogStore.svelte.ts # Signal catalog per domain (asset, FX)
โ โโโ types/ # TypeScript type definitions
โ โโโ utils/ # Utilities (urlFilters, chartUtils, โฆ)
โ โโโ files/ # imageCrop.ts, upload.ts
โ โโโ layout/ # responsiveLayout.svelte.ts, labelShrink.ts, dropdownPosition.ts
โโโ e2e/ # Playwright E2E tests
โโโ static/ # Static assets
โก Svelte 5 Runes
New components use Svelte 5's Runes for reactivity, but a minority of older components use no
rune at all, so Svelte compiles them in legacy mode (export let props, $: statements). The
one consequence to know: in a legacy component, a function call inside a template expression
compiles into $.untrack(โฆ), so runes state read inside that function is not tracked โ that is
why the Brokers page stopped following the privacy toggle (R20). Render such a value through a
runes child (e.g. lib/components/ui/display/CurrencyAmount.svelte) or migrate the component; see
Legacy components freeze masked output.
๐ Key Runes Used
$state: Declares reactive state.$derived: Declares derived state (automatically updates when dependencies change).$effect: Side effects (runs when dependencies change).$props: Declares component props.
๐ Documentation Sections
- Components - Reusable UI components
- FX Chain Algorithm - DFS pathfinding for currency conversion chains
- Pages - Application pages and routing
- Onboarding Guides - Welcome setup, intro tour and contextual guides
- Store Client System - Stores and reactive state
- Internationalization - Multi-language support
- Styling - Tailwind CSS and theming
๐๏ธ 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.
๐ Quick Links
| Topic | Description |
|---|---|
| DataTable | Advanced table with sorting, filtering, pagination |
| Toolbar & Responsive Layout | PageToolbar shell, threshold-driven tiers, per-page tuning |
| 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 |