Overview
Ghostty Config is built with SvelteKit, using the modern Svelte 5 framework with runes enabled. The project follows SvelteKit’s file-based routing convention and is structured for maintainability and scalability.Tech Stack
- Bun: Fast JavaScript runtime and package manager
- Svelte 5: Reactive UI framework with runes for state management
- SvelteKit: Application framework with file-based routing
- TypeScript: Type-safe JavaScript
- Vite: Build tool and development server
- Vitest: Unit testing framework
Directory Structure
Core Directories
/src/routes/
SvelteKit uses file-based routing. Each route is defined by the file structure:
+page.svelte- Route component+page.ts- Route data loading (optional)+layout.svelte- Shared layout wrapper+layout.ts- Layout data loading
/src/lib/stores/
Svelte 5 runes-based state management stores:
config.svelte.ts- Main configuration state managementhistory.svelte.ts- Undo/redo history trackingstate.svelte.ts- Application UI state
/src/lib/components/
Reusable Svelte components, including:
components/settings/- Settings-specific components (inputs, controls, previews)- Generic UI components (buttons, modals, etc.)
/src/lib/utils/
Utility functions and helpers:
colors.ts- Color manipulation utilitieskeybinds.ts- Keybinding validation logickeybinds.test.ts- Keybinding testsparse.ts- Config file parsing
/src/lib/data/
Data schemas and definitions:
ghostty-schema.ts- Ghostty configuration schema definitionssettings.ts- Settings metadata and structure
/src/lib/views/
Page-level view components that compose multiple smaller components into full pages.
Build Configuration
svelte.config.js
Configures SvelteKit with:
- Adapter:
@sveltejs/adapter-staticfor static site generation - Preprocessor:
vitePreprocess()for TypeScript and PostCSS - Compiler options: Enables Svelte 5 runes mode
- Fallback: 404.html for client-side routing
Output
Runningbun run build generates a static site in the build/ directory, ready for deployment to any static hosting service (GitHub Pages, Netlify, Vercel, etc.).
State Management
The app uses Svelte 5 runes ($state, $derived, $effect) for reactive state management instead of traditional Svelte stores. This provides better TypeScript support and more granular reactivity.
Example from src/lib/stores/config.svelte.ts:
Styling
Global styles are defined insrc/app.css. Component-specific styles use Svelte’s scoped <style> blocks. The project uses the Inter variable font from @fontsource-variable/inter.