1```mermaid
2flowchart TB
3 subgraph Routes["๐ Routes"]
4 R1["/ (Welcome)"]
5 R2["/chat/[id]"]
6 RL["+layout.svelte"]
7 end
8
9 subgraph Components["๐งฉ Components"]
10 C_Sidebar["ChatSidebar"]
11 C_Screen["ChatScreen"]
12 C_Form["ChatForm"]
13 C_Messages["ChatMessages"]
14 C_Message["ChatMessage"]
15 C_MessageEditForm["ChatMessageEditForm"]
16 C_ModelsSelector["ModelsSelector"]
17 C_Settings["ChatSettings"]
18 end
19
20 subgraph Hooks["๐ช Hooks"]
21 H1["useModelChangeValidation"]
22 H2["useProcessingState"]
23 end
24
25 subgraph Stores["๐๏ธ Stores"]
26 S1["chatStore<br/><i>Chat interactions & streaming</i>"]
27 S2["conversationsStore<br/><i>Conversation data & messages</i>"]
28 S3["modelsStore<br/><i>Model selection & loading</i>"]
29 S4["serverStore<br/><i>Server props & role detection</i>"]
30 S5["settingsStore<br/><i>User configuration</i>"]
31 end
32
33 subgraph Services["โ๏ธ Services"]
34 SV1["ChatService"]
35 SV2["ModelsService"]
36 SV3["PropsService"]
37 SV4["DatabaseService"]
38 SV5["ParameterSyncService"]
39 end
40
41 subgraph Storage["๐พ Storage"]
42 ST1["IndexedDB<br/><i>conversations, messages</i>"]
43 ST2["LocalStorage<br/><i>config, userOverrides</i>"]
44 end
45
46 subgraph APIs["๐ llama-server API"]
47 API1["/v1/chat/completions"]
48 API2["/props"]
49 API3["/models/*"]
50 API4["/v1/models"]
51 end
52
53 %% Routes โ Components
54 R1 & R2 --> C_Screen
55 RL --> C_Sidebar
56
57 %% Component hierarchy
58 C_Screen --> C_Form & C_Messages & C_Settings
59 C_Messages --> C_Message
60 C_Message --> C_MessageEditForm
61 C_Form & C_MessageEditForm --> C_ModelsSelector
62
63 %% Components โ Hooks โ Stores
64 C_Form & C_Messages --> H1 & H2
65 H1 --> S3 & S4
66 H2 --> S1 & S5
67
68 %% Components โ Stores
69 C_Screen --> S1 & S2
70 C_Sidebar --> S2
71 C_ModelsSelector --> S3 & S4
72 C_Settings --> S5
73
74 %% Stores โ Services
75 S1 --> SV1 & SV4
76 S2 --> SV4
77 S3 --> SV2 & SV3
78 S4 --> SV3
79 S5 --> SV5
80
81 %% Services โ Storage
82 SV4 --> ST1
83 SV5 --> ST2
84
85 %% Services โ APIs
86 SV1 --> API1
87 SV2 --> API3 & API4
88 SV3 --> API2
89
90 %% Styling
91 classDef routeStyle fill:#e1f5fe,stroke:#01579b,stroke-width:2px
92 classDef componentStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
93 classDef hookStyle fill:#fff8e1,stroke:#ff8f00,stroke-width:2px
94 classDef storeStyle fill:#fff3e0,stroke:#e65100,stroke-width:2px
95 classDef serviceStyle fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
96 classDef storageStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px
97 classDef apiStyle fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
98
99 class R1,R2,RL routeStyle
100 class C_Sidebar,C_Screen,C_Form,C_Messages,C_Message,C_MessageEditForm,C_ModelsSelector,C_Settings componentStyle
101 class H1,H2 hookStyle
102 class S1,S2,S3,S4,S5 storeStyle
103 class SV1,SV2,SV3,SV4,SV5 serviceStyle
104 class ST1,ST2 storageStyle
105 class API1,API2,API3,API4 apiStyle
106```