|
2 | 2 | trigger: manual |
3 | 3 | --- |
4 | 4 |
|
5 | | -# SvelteKit Architecture Rules |
6 | | - |
7 | | -## Services vs Stores Separation Pattern |
8 | | - |
9 | | -### `lib/services/` - Pure Business Logic |
10 | | -- **Purpose**: Stateless business logic and external communication |
11 | | -- **Contains**: |
12 | | - - Database operations (DatabaseService) |
13 | | - - API calls to external services (ApiService) |
14 | | - - Pure business logic functions (ChatService, etc.) |
15 | | -- **Rules**: |
16 | | - - NO Svelte runes ($state, $derived, $effect) |
17 | | - - NO reactive state management |
18 | | - - Pure functions and classes only |
19 | | - - Can import types but not stores |
20 | | - - Focus on "how" - implementation details |
21 | | - |
22 | | -### `lib/stores/` - Reactive State Management |
23 | | -- **Purpose**: Svelte-specific reactive state with runes |
24 | | -- **Contains**: |
25 | | - - Reactive state classes with $state, $derived, $effect |
26 | | - - UI-focused state management |
27 | | - - Store orchestration logic |
28 | | -- **Rules**: |
29 | | - - USE Svelte runes for reactivity |
30 | | - - Import and use services for business logic |
31 | | - - NO direct database operations |
32 | | - - NO direct API calls (use services) |
33 | | - - Focus on "what" - reactive state for UI |
34 | | - |
35 | | -### Enforcement |
36 | | -- Services should be testable without Svelte |
37 | | -- Stores should leverage Svelte's reactivity system |
38 | | -- Clear separation: services handle data, stores handle state |
39 | | -- Services can be reused across multiple stores |
40 | | - |
41 | | -### Tailwind & CSS |
42 | | - |
43 | | -- We are using Tailwind v4 which uses oklch colors so we now want to refer to the CSS vars directly, without wrapping it with any color function like `hsla/hsl`, `rgba` etc. |
| 5 | +# Coding rules |
| 6 | + |
| 7 | +## Svelte & SvelteKit |
| 8 | + |
| 9 | +### Services vs Stores Separation Pattern |
| 10 | + |
| 11 | +#### `lib/services/` - Pure Business Logic |
| 12 | + |
| 13 | +- **Purpose**: Stateless business logic and external communication |
| 14 | +- **Contains**: |
| 15 | + - Database operations (DatabaseService) |
| 16 | + - API calls to external services (ApiService) |
| 17 | + - Pure business logic functions (ChatService, etc.) |
| 18 | +- **Rules**: |
| 19 | + - NO Svelte runes ($state, $derived, $effect) |
| 20 | + - NO reactive state management |
| 21 | + - Pure functions and classes only |
| 22 | + - Can import types but not stores |
| 23 | + - Focus on "how" - implementation details |
| 24 | + |
| 25 | +#### `lib/stores/` - Reactive State Management |
| 26 | + |
| 27 | +- **Purpose**: Svelte-specific reactive state with runes |
| 28 | +- **Contains**: |
| 29 | + - Reactive state classes with $state, $derived, $effect |
| 30 | + - UI-focused state management |
| 31 | + - Store orchestration logic |
| 32 | +- **Rules**: |
| 33 | + - USE Svelte runes for reactivity |
| 34 | + - Import and use services for business logic |
| 35 | + - NO direct database operations |
| 36 | + - NO direct API calls (use services) |
| 37 | + - Focus on "what" - reactive state for UI |
| 38 | + |
| 39 | +#### Enforcement |
| 40 | + |
| 41 | +- Services should be testable without Svelte |
| 42 | +- Stores should leverage Svelte's reactivity system |
| 43 | +- Clear separation: services handle data, stores handle state |
| 44 | +- Services can be reused across multiple stores |
0 commit comments