@livestore/cli 0.0.0-snapshot-2ac5fd340c97c9e07fe4c5dc6d31d5132aa6557c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +12 -0
- package/LICENSE +201 -0
- package/dist/cli +0 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +22 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/mcp-coach.d.ts +15 -0
- package/dist/commands/mcp-coach.d.ts.map +1 -0
- package/dist/commands/mcp-coach.js +87 -0
- package/dist/commands/mcp-coach.js.map +1 -0
- package/dist/commands/mcp-tools.d.ts +41 -0
- package/dist/commands/mcp-tools.d.ts.map +1 -0
- package/dist/commands/mcp-tools.js +148 -0
- package/dist/commands/mcp-tools.js.map +1 -0
- package/dist/commands/mcp.d.ts +5 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +67 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/new-project.d.ts +34 -0
- package/dist/commands/new-project.d.ts.map +1 -0
- package/dist/commands/new-project.js +163 -0
- package/dist/commands/new-project.js.map +1 -0
- package/dist/mcp-content/architecture.d.ts +2 -0
- package/dist/mcp-content/architecture.d.ts.map +1 -0
- package/dist/mcp-content/architecture.js +171 -0
- package/dist/mcp-content/architecture.js.map +1 -0
- package/dist/mcp-content/features.d.ts +2 -0
- package/dist/mcp-content/features.d.ts.map +1 -0
- package/dist/mcp-content/features.js +177 -0
- package/dist/mcp-content/features.js.map +1 -0
- package/dist/mcp-content/getting-started.d.ts +2 -0
- package/dist/mcp-content/getting-started.d.ts.map +1 -0
- package/dist/mcp-content/getting-started.js +405 -0
- package/dist/mcp-content/getting-started.js.map +1 -0
- package/dist/mcp-content/overview.d.ts +2 -0
- package/dist/mcp-content/overview.d.ts.map +1 -0
- package/dist/mcp-content/overview.js +120 -0
- package/dist/mcp-content/overview.js.map +1 -0
- package/dist/mcp-content/schemas/blog.d.ts +2 -0
- package/dist/mcp-content/schemas/blog.d.ts.map +1 -0
- package/dist/mcp-content/schemas/blog.js +223 -0
- package/dist/mcp-content/schemas/blog.js.map +1 -0
- package/dist/mcp-content/schemas/ecommerce.d.ts +2 -0
- package/dist/mcp-content/schemas/ecommerce.d.ts.map +1 -0
- package/dist/mcp-content/schemas/ecommerce.js +436 -0
- package/dist/mcp-content/schemas/ecommerce.js.map +1 -0
- package/dist/mcp-content/schemas/social.d.ts +2 -0
- package/dist/mcp-content/schemas/social.d.ts.map +1 -0
- package/dist/mcp-content/schemas/social.js +339 -0
- package/dist/mcp-content/schemas/social.js.map +1 -0
- package/dist/mcp-content/schemas/todo.d.ts +2 -0
- package/dist/mcp-content/schemas/todo.d.ts.map +1 -0
- package/dist/mcp-content/schemas/todo.js +172 -0
- package/dist/mcp-content/schemas/todo.js.map +1 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +2 -0
- package/dist/mod.js.map +1 -0
- package/dist/test-tool.d.ts +2 -0
- package/dist/test-tool.d.ts.map +1 -0
- package/dist/test-tool.js +57 -0
- package/dist/test-tool.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +27 -0
- package/src/cli.ts +35 -0
- package/src/commands/mcp-coach.ts +121 -0
- package/src/commands/mcp-tools.ts +169 -0
- package/src/commands/mcp.ts +97 -0
- package/src/commands/new-project.ts +263 -0
- package/src/mcp-content/architecture.ts +170 -0
- package/src/mcp-content/features.ts +176 -0
- package/src/mcp-content/getting-started.ts +404 -0
- package/src/mcp-content/overview.ts +119 -0
- package/src/mcp-content/schemas/blog.ts +222 -0
- package/src/mcp-content/schemas/ecommerce.ts +435 -0
- package/src/mcp-content/schemas/social.ts +338 -0
- package/src/mcp-content/schemas/todo.ts +171 -0
- package/src/mod.ts +1 -0
- package/tsconfig.json +9 -0
@@ -0,0 +1,404 @@
|
|
1
|
+
export const gettingStartedContent = `# Getting Started with LiveStore
|
2
|
+
|
3
|
+
Build your first local-first application with LiveStore in minutes. This guide walks through creating a real-time collaborative todo app that works offline and syncs when online.
|
4
|
+
|
5
|
+
## Quick Start
|
6
|
+
|
7
|
+
### 1. Installation
|
8
|
+
|
9
|
+
\`\`\`bash
|
10
|
+
# Install LiveStore core
|
11
|
+
npm install @livestore/livestore
|
12
|
+
|
13
|
+
# Choose your platform adapter
|
14
|
+
npm install @livestore/adapter-web # For web applications
|
15
|
+
npm install @livestore/adapter-node # For Node.js applications
|
16
|
+
npm install @livestore/adapter-expo # For React Native/Expo apps
|
17
|
+
\`\`\`
|
18
|
+
|
19
|
+
### 2. Define Your Schema
|
20
|
+
|
21
|
+
LiveStore uses an event-driven architecture where all changes are recorded as immutable events and applied to materialized SQLite tables.
|
22
|
+
|
23
|
+
\`\`\`typescript
|
24
|
+
// schema.ts
|
25
|
+
import { Events, makeSchema, Schema, SessionIdSymbol, State } from '@livestore/livestore'
|
26
|
+
|
27
|
+
// Define your state as SQLite tables
|
28
|
+
export const tables = {
|
29
|
+
todos: State.SQLite.table({
|
30
|
+
name: 'todos',
|
31
|
+
columns: {
|
32
|
+
id: State.SQLite.text({ primaryKey: true }),
|
33
|
+
text: State.SQLite.text({ default: '' }),
|
34
|
+
completed: State.SQLite.boolean({ default: false }),
|
35
|
+
deletedAt: State.SQLite.integer({ nullable: true, schema: Schema.DateFromNumber }),
|
36
|
+
createdAt: State.SQLite.integer({ schema: Schema.DateFromNumber }),
|
37
|
+
},
|
38
|
+
}),
|
39
|
+
|
40
|
+
// Client-only state (not synced)
|
41
|
+
uiState: State.SQLite.clientDocument({
|
42
|
+
name: 'uiState',
|
43
|
+
schema: Schema.Struct({
|
44
|
+
newTodoText: Schema.String,
|
45
|
+
filter: Schema.Literal('all', 'active', 'completed')
|
46
|
+
}),
|
47
|
+
default: { id: SessionIdSymbol, value: { newTodoText: '', filter: 'all' } },
|
48
|
+
}),
|
49
|
+
}
|
50
|
+
|
51
|
+
// Define events that represent state changes
|
52
|
+
export const events = {
|
53
|
+
todoCreated: Events.synced({
|
54
|
+
name: 'v1.TodoCreated',
|
55
|
+
schema: Schema.Struct({
|
56
|
+
id: Schema.String,
|
57
|
+
text: Schema.String,
|
58
|
+
createdAt: Schema.Date
|
59
|
+
}),
|
60
|
+
}),
|
61
|
+
todoCompleted: Events.synced({
|
62
|
+
name: 'v1.TodoCompleted',
|
63
|
+
schema: Schema.Struct({ id: Schema.String }),
|
64
|
+
}),
|
65
|
+
todoUncompleted: Events.synced({
|
66
|
+
name: 'v1.TodoUncompleted',
|
67
|
+
schema: Schema.Struct({ id: Schema.String }),
|
68
|
+
}),
|
69
|
+
todoDeleted: Events.synced({
|
70
|
+
name: 'v1.TodoDeleted',
|
71
|
+
schema: Schema.Struct({ id: Schema.String, deletedAt: Schema.Date }),
|
72
|
+
}),
|
73
|
+
|
74
|
+
// UI state events (local only)
|
75
|
+
uiStateSet: tables.uiState.set,
|
76
|
+
}
|
77
|
+
|
78
|
+
// Materializers map events to state changes
|
79
|
+
const materializers = State.SQLite.materializers(events, {
|
80
|
+
'v1.TodoCreated': ({ id, text, createdAt }) =>
|
81
|
+
tables.todos.insert({ id, text, completed: false, createdAt }),
|
82
|
+
|
83
|
+
'v1.TodoCompleted': ({ id }) =>
|
84
|
+
tables.todos.update({ completed: true }).where({ id }),
|
85
|
+
|
86
|
+
'v1.TodoUncompleted': ({ id }) =>
|
87
|
+
tables.todos.update({ completed: false }).where({ id }),
|
88
|
+
|
89
|
+
'v1.TodoDeleted': ({ id, deletedAt }) =>
|
90
|
+
tables.todos.update({ deletedAt }).where({ id }),
|
91
|
+
})
|
92
|
+
|
93
|
+
const state = State.SQLite.makeState({ tables, materializers })
|
94
|
+
|
95
|
+
export const schema = makeSchema({ events, state })
|
96
|
+
\`\`\`
|
97
|
+
|
98
|
+
### 3. Create Reactive Queries
|
99
|
+
|
100
|
+
LiveStore queries automatically update your UI when underlying data changes.
|
101
|
+
|
102
|
+
\`\`\`typescript
|
103
|
+
// queries.ts
|
104
|
+
import { queryDb } from '@livestore/livestore'
|
105
|
+
import { tables } from './schema.js'
|
106
|
+
|
107
|
+
// Reactive query for all active todos
|
108
|
+
export const activeTodos$ = queryDb(
|
109
|
+
tables.todos
|
110
|
+
.select()
|
111
|
+
.where({ deletedAt: null, completed: false })
|
112
|
+
.orderBy('createdAt'),
|
113
|
+
{ label: 'activeTodos' }
|
114
|
+
)
|
115
|
+
|
116
|
+
// Reactive query for completed todos
|
117
|
+
export const completedTodos$ = queryDb(
|
118
|
+
tables.todos
|
119
|
+
.select()
|
120
|
+
.where({ deletedAt: null, completed: true })
|
121
|
+
.orderBy('createdAt'),
|
122
|
+
{ label: 'completedTodos' }
|
123
|
+
)
|
124
|
+
|
125
|
+
// UI state query
|
126
|
+
export const uiState$ = queryDb(
|
127
|
+
tables.uiState.get(),
|
128
|
+
{ label: 'uiState' }
|
129
|
+
)
|
130
|
+
\`\`\`
|
131
|
+
|
132
|
+
### 4. Connect to Your UI Framework
|
133
|
+
|
134
|
+
#### React Integration
|
135
|
+
|
136
|
+
\`\`\`typescript
|
137
|
+
// TodoApp.tsx
|
138
|
+
import React from 'react'
|
139
|
+
import { useLiveQuery, dispatchEvent } from '@livestore/react'
|
140
|
+
import { activeTodos$, completedTodos$, uiState$ } from './queries.js'
|
141
|
+
import { events } from './schema.js'
|
142
|
+
|
143
|
+
const TodoApp: React.FC = () => {
|
144
|
+
const activeTodos = useLiveQuery(activeTodos$)
|
145
|
+
const completedTodos = useLiveQuery(completedTodos$)
|
146
|
+
const uiState = useLiveQuery(uiState$)
|
147
|
+
|
148
|
+
const createTodo = (text: string) => {
|
149
|
+
const id = crypto.randomUUID()
|
150
|
+
dispatchEvent(events.todoCreated({ id, text, createdAt: new Date() }))
|
151
|
+
}
|
152
|
+
|
153
|
+
const toggleTodo = (id: string, completed: boolean) => {
|
154
|
+
dispatchEvent(
|
155
|
+
completed
|
156
|
+
? events.todoCompleted({ id })
|
157
|
+
: events.todoUncompleted({ id })
|
158
|
+
)
|
159
|
+
}
|
160
|
+
|
161
|
+
const deleteTodo = (id: string) => {
|
162
|
+
dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))
|
163
|
+
}
|
164
|
+
|
165
|
+
return (
|
166
|
+
<div className="todo-app">
|
167
|
+
<h1>Local-First Todos</h1>
|
168
|
+
|
169
|
+
{/* Add todo form */}
|
170
|
+
<form onSubmit={(e) => {
|
171
|
+
e.preventDefault()
|
172
|
+
const form = e.target as HTMLFormElement
|
173
|
+
const input = form.elements.namedItem('todo') as HTMLInputElement
|
174
|
+
if (input.value.trim()) {
|
175
|
+
createTodo(input.value.trim())
|
176
|
+
input.value = ''
|
177
|
+
}
|
178
|
+
}}>
|
179
|
+
<input name="todo" placeholder="What needs to be done?" />
|
180
|
+
<button type="submit">Add Todo</button>
|
181
|
+
</form>
|
182
|
+
|
183
|
+
{/* Active todos */}
|
184
|
+
<div className="todo-list">
|
185
|
+
<h2>Active ({activeTodos.length})</h2>
|
186
|
+
{activeTodos.map(todo => (
|
187
|
+
<div key={todo.id} className="todo-item">
|
188
|
+
<input
|
189
|
+
type="checkbox"
|
190
|
+
checked={false}
|
191
|
+
onChange={() => toggleTodo(todo.id, true)}
|
192
|
+
/>
|
193
|
+
<span>{todo.text}</span>
|
194
|
+
<button onClick={() => deleteTodo(todo.id)}>Delete</button>
|
195
|
+
</div>
|
196
|
+
))}
|
197
|
+
</div>
|
198
|
+
|
199
|
+
{/* Completed todos */}
|
200
|
+
<div className="todo-list">
|
201
|
+
<h2>Completed ({completedTodos.length})</h2>
|
202
|
+
{completedTodos.map(todo => (
|
203
|
+
<div key={todo.id} className="todo-item completed">
|
204
|
+
<input
|
205
|
+
type="checkbox"
|
206
|
+
checked={true}
|
207
|
+
onChange={() => toggleTodo(todo.id, false)}
|
208
|
+
/>
|
209
|
+
<span>{todo.text}</span>
|
210
|
+
<button onClick={() => deleteTodo(todo.id)}>Delete</button>
|
211
|
+
</div>
|
212
|
+
))}
|
213
|
+
</div>
|
214
|
+
</div>
|
215
|
+
)
|
216
|
+
}
|
217
|
+
|
218
|
+
export default TodoApp
|
219
|
+
\`\`\`
|
220
|
+
|
221
|
+
#### Vue Integration
|
222
|
+
|
223
|
+
\`\`\`vue
|
224
|
+
<!-- TodoApp.vue -->
|
225
|
+
<template>
|
226
|
+
<div class="todo-app">
|
227
|
+
<h1>Local-First Todos</h1>
|
228
|
+
|
229
|
+
<form @submit.prevent="createTodo">
|
230
|
+
<input v-model="newTodoText" placeholder="What needs to be done?" />
|
231
|
+
<button type="submit">Add Todo</button>
|
232
|
+
</form>
|
233
|
+
|
234
|
+
<div class="todo-list">
|
235
|
+
<h2>Active ({{ activeTodos.length }})</h2>
|
236
|
+
<div v-for="todo in activeTodos" :key="todo.id" class="todo-item">
|
237
|
+
<input
|
238
|
+
type="checkbox"
|
239
|
+
:checked="false"
|
240
|
+
@change="toggleTodo(todo.id, true)"
|
241
|
+
/>
|
242
|
+
<span>{{ todo.text }}</span>
|
243
|
+
<button @click="deleteTodo(todo.id)">Delete</button>
|
244
|
+
</div>
|
245
|
+
</div>
|
246
|
+
</div>
|
247
|
+
</template>
|
248
|
+
|
249
|
+
<script setup lang="ts">
|
250
|
+
import { ref } from 'vue'
|
251
|
+
import { useLiveQuery, dispatchEvent } from '@livestore/vue'
|
252
|
+
import { activeTodos$ } from './queries.js'
|
253
|
+
import { events } from './schema.js'
|
254
|
+
|
255
|
+
const activeTodos = useLiveQuery(activeTodos$)
|
256
|
+
const newTodoText = ref('')
|
257
|
+
|
258
|
+
const createTodo = () => {
|
259
|
+
if (newTodoText.value.trim()) {
|
260
|
+
const id = crypto.randomUUID()
|
261
|
+
dispatchEvent(events.todoCreated({
|
262
|
+
id,
|
263
|
+
text: newTodoText.value.trim(),
|
264
|
+
createdAt: new Date()
|
265
|
+
}))
|
266
|
+
newTodoText.value = ''
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
const toggleTodo = (id: string, completed: boolean) => {
|
271
|
+
dispatchEvent(
|
272
|
+
completed
|
273
|
+
? events.todoCompleted({ id })
|
274
|
+
: events.todoUncompleted({ id })
|
275
|
+
)
|
276
|
+
}
|
277
|
+
|
278
|
+
const deleteTodo = (id: string) => {
|
279
|
+
dispatchEvent(events.todoDeleted({ id, deletedAt: new Date() }))
|
280
|
+
}
|
281
|
+
</script>
|
282
|
+
\`\`\`
|
283
|
+
|
284
|
+
### 5. Initialize Your Application
|
285
|
+
|
286
|
+
\`\`\`typescript
|
287
|
+
// main.ts
|
288
|
+
import { LiveStore } from '@livestore/livestore'
|
289
|
+
import { WebAdapter } from '@livestore/adapter-web'
|
290
|
+
import { schema } from './schema.js'
|
291
|
+
|
292
|
+
// Initialize LiveStore with your schema
|
293
|
+
const liveStore = LiveStore.create({
|
294
|
+
schema,
|
295
|
+
adapter: WebAdapter({
|
296
|
+
databaseName: 'todo-app',
|
297
|
+
// Optional: Add sync configuration
|
298
|
+
sync: {
|
299
|
+
url: 'wss://your-sync-server.com',
|
300
|
+
auth: { token: 'your-auth-token' }
|
301
|
+
}
|
302
|
+
})
|
303
|
+
})
|
304
|
+
|
305
|
+
// Start your application
|
306
|
+
const app = document.getElementById('app')
|
307
|
+
if (app) {
|
308
|
+
// Your framework-specific initialization
|
309
|
+
// React: createRoot(app).render(<TodoApp />)
|
310
|
+
// Vue: createApp(TodoApp).mount(app)
|
311
|
+
}
|
312
|
+
\`\`\`
|
313
|
+
|
314
|
+
## Advanced Features
|
315
|
+
|
316
|
+
### Offline Support
|
317
|
+
|
318
|
+
Your app automatically works offline. All operations execute against the local database, and changes sync when connectivity returns.
|
319
|
+
|
320
|
+
\`\`\`typescript
|
321
|
+
// Check online status
|
322
|
+
const isOnline$ = queryDb(
|
323
|
+
LiveStore.connectionStatus(),
|
324
|
+
{ label: 'connectionStatus' }
|
325
|
+
)
|
326
|
+
\`\`\`
|
327
|
+
|
328
|
+
### Real-Time Collaboration
|
329
|
+
|
330
|
+
Multiple users can collaborate in real-time. Conflicts are automatically resolved using last-write-wins or custom merge strategies.
|
331
|
+
|
332
|
+
\`\`\`typescript
|
333
|
+
// Custom conflict resolution
|
334
|
+
const materializers = State.SQLite.materializers(events, {
|
335
|
+
'v1.TodoTextChanged': ({ id, text, editedAt }) =>
|
336
|
+
// Use timestamp for conflict resolution
|
337
|
+
tables.todos
|
338
|
+
.update({ text, editedAt })
|
339
|
+
.where({ id })
|
340
|
+
.and(tables.todos.column('editedAt').lt(editedAt))
|
341
|
+
})
|
342
|
+
\`\`\`
|
343
|
+
|
344
|
+
### Testing
|
345
|
+
|
346
|
+
\`\`\`typescript
|
347
|
+
// todo.test.ts
|
348
|
+
import { createTestStore } from '@livestore/testing'
|
349
|
+
import { schema, events } from './schema.js'
|
350
|
+
|
351
|
+
test('creating and completing todos', async () => {
|
352
|
+
const store = createTestStore(schema)
|
353
|
+
|
354
|
+
// Dispatch events
|
355
|
+
await store.dispatch([
|
356
|
+
events.todoCreated({ id: '1', text: 'Test todo', createdAt: new Date() }),
|
357
|
+
events.todoCompleted({ id: '1' })
|
358
|
+
])
|
359
|
+
|
360
|
+
// Query final state
|
361
|
+
const completedTodos = await store.query(
|
362
|
+
tables.todos.select().where({ completed: true })
|
363
|
+
)
|
364
|
+
|
365
|
+
expect(completedTodos).toHaveLength(1)
|
366
|
+
expect(completedTodos[0].text).toBe('Test todo')
|
367
|
+
})
|
368
|
+
\`\`\`
|
369
|
+
|
370
|
+
## Next Steps
|
371
|
+
|
372
|
+
### Production Deployment
|
373
|
+
1. **Set up sync server**: Deploy LiveStore sync server for real-time collaboration
|
374
|
+
2. **Configure authentication**: Add user authentication and authorization
|
375
|
+
3. **Add monitoring**: Set up distributed tracing and performance monitoring
|
376
|
+
4. **Optimize performance**: Add indexes and query optimization
|
377
|
+
|
378
|
+
### Advanced Patterns
|
379
|
+
- **Multi-user collaboration**: User permissions and access control
|
380
|
+
- **Rich text editing**: Operational transforms for collaborative editing
|
381
|
+
- **File synchronization**: Binary data and file attachment handling
|
382
|
+
- **Schema migrations**: Evolving your data model over time
|
383
|
+
|
384
|
+
### Platform-Specific Guides
|
385
|
+
- **Web deployment**: Service workers, PWA configuration, OPFS optimization
|
386
|
+
- **Mobile apps**: Background sync, push notifications, native storage
|
387
|
+
- **Desktop apps**: Electron integration, native file system access
|
388
|
+
|
389
|
+
## Examples Repository
|
390
|
+
|
391
|
+
Explore complete working examples:
|
392
|
+
- **TodoMVC**: Classic todo app with real-time sync
|
393
|
+
- **Collaborative Editor**: Rich text editing with operational transforms
|
394
|
+
- **Chat Application**: Real-time messaging with presence indicators
|
395
|
+
- **E-commerce**: Product catalog with shopping cart and orders
|
396
|
+
|
397
|
+
\`\`\`bash
|
398
|
+
# Clone examples repository
|
399
|
+
git clone https://github.com/livestorejs/examples.git
|
400
|
+
cd examples/web-todomvc
|
401
|
+
npm install && npm run dev
|
402
|
+
\`\`\`
|
403
|
+
|
404
|
+
Visit [docs.livestore.dev](https://docs.livestore.dev) for comprehensive documentation, API reference, and advanced patterns.`
|
@@ -0,0 +1,119 @@
|
|
1
|
+
export const overviewContent = `# LiveStore: Local-First Data Platform
|
2
|
+
|
3
|
+
LiveStore is a production-ready local-first data platform that combines the immediate responsiveness of local SQLite databases with the collaborative power of real-time synchronization. Built on distributed systems principles from Martin Kleppmann's research, LiveStore enables applications that work seamlessly offline and sync reliably when online.
|
4
|
+
|
5
|
+
## Core Philosophy
|
6
|
+
|
7
|
+
**Local-First Principles**: Your data lives primarily on your device, not in the cloud. Applications respond immediately to user actions without network round-trips, providing the smooth experience users expect from native applications.
|
8
|
+
|
9
|
+
**Collaborative by Design**: Real-time collaboration isn't an afterthought – it's built into the foundation. Multiple users can work together seamlessly with automatic conflict resolution and eventual consistency guarantees.
|
10
|
+
|
11
|
+
**Reliability Through Event Sourcing**: All changes are captured as immutable events, providing a complete audit trail and enabling powerful features like undo/redo, time travel debugging, and deterministic testing.
|
12
|
+
|
13
|
+
## What Makes LiveStore Different
|
14
|
+
|
15
|
+
### 💾 Local SQLite Performance
|
16
|
+
- **Sub-millisecond queries** from local SQLite database
|
17
|
+
- **Complex joins and aggregations** with full SQL expressiveness
|
18
|
+
- **Reactive queries** that automatically update your UI
|
19
|
+
- **ACID transactions** for data integrity
|
20
|
+
|
21
|
+
### 🌐 Distributed Systems Reliability
|
22
|
+
- **Conflict-free synchronization** using CRDT-inspired merge strategies
|
23
|
+
- **Causal consistency** with vector clocks and event ordering
|
24
|
+
- **Network partition tolerance** – works offline, syncs when online
|
25
|
+
- **Eventually consistent** convergence across all replicas
|
26
|
+
|
27
|
+
### 🔐 End-to-End Type Safety
|
28
|
+
- **Schema-first development** with Effect-based validation
|
29
|
+
- **Compile-time query validation** prevents runtime errors
|
30
|
+
- **Automatic TypeScript generation** from schema definitions
|
31
|
+
- **Runtime safety** with comprehensive input validation
|
32
|
+
|
33
|
+
### 🏗️ Framework Agnostic
|
34
|
+
- **React, Vue, Solid, Svelte** – use with any frontend framework
|
35
|
+
- **Web, Node.js, React Native** – deploy anywhere JavaScript runs
|
36
|
+
- **Consistent API** across all platforms and frameworks
|
37
|
+
|
38
|
+
## Real-World Use Cases
|
39
|
+
|
40
|
+
### 📝 Collaborative Applications
|
41
|
+
- **Document editors** with real-time collaboration (Google Docs-style)
|
42
|
+
- **Project management** tools with team coordination
|
43
|
+
- **Design tools** with multiplayer editing capabilities
|
44
|
+
- **Chat applications** with offline message queuing
|
45
|
+
|
46
|
+
### 📱 Mobile-First Applications
|
47
|
+
- **Field service apps** that work in areas with poor connectivity
|
48
|
+
- **Healthcare applications** with sensitive data that must stay local
|
49
|
+
- **Educational apps** for students in low-connectivity environments
|
50
|
+
- **Financial apps** requiring immediate transaction feedback
|
51
|
+
|
52
|
+
### 🏮 Enterprise Applications
|
53
|
+
- **CRM systems** with offline sales capability
|
54
|
+
- **Inventory management** with real-time stock updates
|
55
|
+
- **Customer service** tools with offline case management
|
56
|
+
- **Analytics dashboards** with local data caching
|
57
|
+
|
58
|
+
## Architecture at a Glance
|
59
|
+
|
60
|
+
\`\`\`mermaid
|
61
|
+
graph TB
|
62
|
+
UI[UI Framework] --> Queries[Reactive Queries]
|
63
|
+
UI --> Events[Event Dispatch]
|
64
|
+
|
65
|
+
Events --> EventLog[Event Log]
|
66
|
+
EventLog --> Materializers[Materializers]
|
67
|
+
Materializers --> SQLite[SQLite Database]
|
68
|
+
Queries --> SQLite
|
69
|
+
|
70
|
+
EventLog --> Sync[Sync Engine]
|
71
|
+
Sync --> Network[Network Layer]
|
72
|
+
Network --> Server[Sync Server]
|
73
|
+
|
74
|
+
Server --> OtherClients[Other Clients]
|
75
|
+
OtherClients --> Server
|
76
|
+
Server --> Network
|
77
|
+
\`\`\`
|
78
|
+
|
79
|
+
1. **UI Layer**: Framework-specific bindings (React, Vue, etc.)
|
80
|
+
2. **Query Layer**: Reactive SQL queries with automatic UI updates
|
81
|
+
3. **Event Layer**: Immutable event log with schema validation
|
82
|
+
4. **Materialization**: Events applied to SQLite tables via materializers
|
83
|
+
5. **Synchronization**: Conflict-free replication across devices/users
|
84
|
+
6. **Storage**: Local SQLite database for immediate data access
|
85
|
+
|
86
|
+
## Key Technical Innovations
|
87
|
+
|
88
|
+
### Event-Driven State Management
|
89
|
+
Unlike traditional ORMs that hide change tracking, LiveStore makes all state changes explicit through events. This provides:
|
90
|
+
- **Deterministic state updates** that can be tested and debugged
|
91
|
+
- **Conflict resolution** through event reordering and semantic merging
|
92
|
+
- **Time travel** capabilities for debugging and feature development
|
93
|
+
- **Audit trails** for compliance and data governance
|
94
|
+
|
95
|
+
### Sophisticated Conflict Resolution
|
96
|
+
LiveStore handles conflicts intelligently using multiple strategies:
|
97
|
+
- **Last-Write-Wins**: Simple timestamp-based resolution
|
98
|
+
- **Semantic Merging**: Application-specific conflict resolution logic
|
99
|
+
- **Operational Transforms**: For real-time collaborative text editing
|
100
|
+
- **CRDT Integration**: Conflict-free data types for specific use cases
|
101
|
+
|
102
|
+
### Performance Optimization
|
103
|
+
- **Query compilation caching** for repeated queries
|
104
|
+
- **Reactive dependency tracking** to minimize unnecessary updates
|
105
|
+
- **Incremental synchronization** to reduce network overhead
|
106
|
+
- **Background processing** to keep the UI thread responsive
|
107
|
+
|
108
|
+
## Production Ready
|
109
|
+
|
110
|
+
LiveStore is designed for production applications with enterprise-grade requirements:
|
111
|
+
|
112
|
+
- **Security**: End-to-end encryption, event signatures, access control
|
113
|
+
- **Observability**: Distributed tracing, performance monitoring, health checks
|
114
|
+
- **Scalability**: Horizontal scaling, connection pooling, data partitioning
|
115
|
+
- **Reliability**: Automatic retries, circuit breakers, graceful degradation
|
116
|
+
|
117
|
+
Whether you're building a simple todo app or a complex collaborative platform, LiveStore provides the foundation for applications that users love – fast, reliable, and always available.
|
118
|
+
|
119
|
+
**Ready to get started?** Check out our [Getting Started Guide](./getting-started) or explore our [Example Applications](https://github.com/livestorejs/examples).`
|