Skip to content

Commit 783ebec

Browse files
committed
docs: improve README with installation, quick start, and navigation
Add critical onboarding sections to help developers evaluate and get started with Ensemble: - Installation instructions for all packages - Quick start example with React integration - Packages overview table - Real-time collaboration section highlighting the new package - Table of contents for navigation - Examples & demos section - Documentation hub with links to all package READMEs Also fix broken documentation links (removed references to non-existent src/ files). The README now follows progressive disclosure - practical usage first, then architectural deep-dives.
1 parent 1ab7d52 commit 783ebec

File tree

1 file changed

+198
-3
lines changed

1 file changed

+198
-3
lines changed

README.md

Lines changed: 198 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,126 @@
11
# Ensemble
22

3+
[![npm version](https://img.shields.io/npm/v/@d-buckner/ensemble-core.svg)](https://www.npmjs.com/package/@d-buckner/ensemble-core)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE)
5+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue)](https://www.typescriptlang.org/)
6+
37
## Overview
48

59
Ensemble is a frontend framework for building complex applications using the actor model. It enables developers to organize application logic into independent, composable actors that communicate via message passing. Actors can run on any thread (main or a worker) without coupling the actor topology to execution context, allowing for flexible performance optimization and clear separation of concerns.
610

11+
## Table of Contents
12+
13+
- [Overview](#overview)
14+
- [Project Status](#project-status)
15+
- [Installation](#installation)
16+
- [Quick Start](#quick-start)
17+
- [Packages](#packages)
18+
- [The Challenge](#the-challenge)
19+
- [Core Architecture](#core-architecture)
20+
- [Actors and the Actor System](#actors-and-the-actor-system)
21+
- [ActorClients: The Developer Interface](#actorclients-the-developer-interface)
22+
- [Actor System: Lifecycle and Dependency Management](#actor-system-lifecycle-and-dependency-management)
23+
- [How It Works: The Actor Model](#how-it-works-the-actor-model)
24+
- [Mental Model](#mental-model)
25+
- [The Routing Pattern](#the-routing-pattern)
26+
- [Why Centralized Routing?](#why-centralized-routing)
27+
- [Real-Time Collaboration](#real-time-collaboration)
28+
- [Key Design Principles](#key-design-principles)
29+
- [Examples & Demos](#examples--demos)
30+
- [Documentation](#documentation)
31+
- [Contributing](#contributing)
32+
- [License](#license)
33+
734
**Who is this for?**
835

936
Ensemble is an experiment framework for folks who have run into compositional/multi-threading challenges with traditional frameworks and tools. If you're building a typical CRUD app or small-to-medium application, established patterns and tools likely serve you better. This framework is designed for teams working on large-scale or innovative frontends where maintaining development velocity as complexity grows becomes a primary concern.
1037

38+
## Project Status
39+
40+
**Version:** 0.1.0 (Initial Release)
41+
**Status:** ⚠️ Experimental - APIs may change
42+
43+
Ensemble is a new framework actively being developed. While the core concepts are solid and the implementation is functional, you should expect:
44+
- API changes between minor versions
45+
- Ongoing performance optimization
46+
- Expanding documentation and examples
47+
48+
Not recommended for production use yet, but perfect for experimentation and feedback.
49+
50+
## Installation
51+
52+
```bash
53+
# Core framework
54+
npm install @d-buckner/ensemble-core
55+
56+
# React bindings
57+
npm install @d-buckner/ensemble-react
58+
59+
# SolidJS bindings
60+
npm install @d-buckner/ensemble-solidjs
61+
62+
# Vite plugin (for multi-threading support)
63+
npm install -D @d-buckner/ensemble-vite-plugin
64+
65+
# Collaboration (real-time CRDT sync)
66+
npm install @d-buckner/ensemble-collaboration
67+
```
68+
69+
## Quick Start
70+
71+
```typescript
72+
import { createActorToken, ActorSystem, Actor, action } from '@d-buckner/ensemble-core';
73+
74+
// 1. Define an actor
75+
class CounterActor extends Actor {
76+
state = { count: 0 };
77+
78+
@action
79+
increment(): void {
80+
this.setState({ count: this.state.count + 1 });
81+
}
82+
}
83+
84+
// 2. Create a token and system
85+
const CounterToken = createActorToken<CounterActor>('counter');
86+
const system = new ActorSystem();
87+
88+
system.register({ token: CounterToken, actor: CounterActor });
89+
await system.start();
90+
91+
// 3. Use the actor
92+
const counter = system.get(CounterToken);
93+
counter.on('stateChanged', (state) => console.log(state));
94+
counter.actions.increment(); // { count: 1 }
95+
```
96+
97+
**With React:**
98+
99+
```typescript
100+
import { useActor } from '@d-buckner/ensemble-react';
101+
102+
function Counter() {
103+
const { state, actions } = useActor(CounterToken);
104+
return (
105+
<button onClick={actions.increment}>
106+
Count: {state.count}
107+
</button>
108+
);
109+
}
110+
```
111+
112+
## Packages
113+
114+
Ensemble is a monorepo with multiple packages:
115+
116+
| Package | Version | Description |
117+
|---------|---------|-------------|
118+
| [@d-buckner/ensemble-core](./packages/core) | 0.1.0 | Core actor framework with threading support |
119+
| [@d-buckner/ensemble-react](./packages/react) | 0.1.0 | React hooks and bindings |
120+
| [@d-buckner/ensemble-solidjs](./packages/solidjs) | 0.1.0 | SolidJS primitives and bindings |
121+
| [@d-buckner/ensemble-vite-plugin](./packages/vite-plugin) | 0.1.0 | Vite plugin for Web Worker threading |
122+
| [@d-buckner/ensemble-collaboration](./packages/collaboration) | 0.1.0 | Real-time collaboration with Automerge CRDTs |
123+
11124
## The Challenge
12125
For large-scale and innovative frontends, some fundamental architectural challenges can impact developer velocity:
13126

@@ -41,8 +154,6 @@ Actors are the fundamental building blocks of a Ensemble application. Each actor
41154

42155
The key insight is that while actors may depend on each other logically, they're not bound to the same execution context. An actor running in a worker thread can depend on an actor in the main thread, or vice versa. This separation allows you to optimize performance without restructuring your application logic.
43156

44-
**See [src/actor/README.md](./src/actor/README.md) for actor implementation details.**
45-
46157
### ActorClients: The Developer Interface
47158

48159
When you need to interact with an actor, you don't get direct access to the actor implementation. This is especially important when actors run in different execution contexts. Instead, you work with an **ActorClient**, a strongly typed proxy that knows how to communicate with the actor regardless of where it's running.
@@ -122,7 +233,52 @@ Each thread (main or worker) has exactly one **ThreadBus** instance responsible
122233

123234
By centralizing the actor system knowledge on the main thread, worker threads can remain lightweight. They don't need to understand the entire application topology. Instead, they receive targeted messages with actor IDs and simply route to their local actors. This keeps the system scalable even as your actor system grows.
124235

125-
**See [src/busses/README.md](./src/busses/README.md) for message bus implementation details.**
236+
## Real-Time Collaboration
237+
238+
The `@d-buckner/ensemble-collaboration` package provides CRDT-based collaboration using Automerge:
239+
240+
- 🔄 **Automatic conflict resolution** - Automerge CRDTs handle concurrent edits
241+
- 🌐 **WebRTC-first with WebSocket fallback** - Low-latency P2P with reliable fallback
242+
- 🎭 **Actor-based architecture** - Four specialized actors (Collaboration, PeerMessaging, WebSocket, WebRTC)
243+
- 📦 **Type-safe** - Generic document types with full TypeScript support
244+
- 🔌 **Framework agnostic** - Works with any transport layer
245+
246+
```typescript
247+
import { CollaborationActor } from '@d-buckner/ensemble-collaboration';
248+
249+
// Extend CollaborationActor with domain-specific actions
250+
class TodosActor extends CollaborationActor<TodoDoc> {
251+
static readonly initialState: TodoDoc = { todos: [] };
252+
253+
constructor() {
254+
super(TodosActor.initialState);
255+
}
256+
257+
@action
258+
addTodo(text: string): void {
259+
this.setState(draft => {
260+
draft.todos.push({
261+
id: `todo-${Date.now()}`,
262+
text,
263+
done: false
264+
});
265+
});
266+
// Automatically synced with all connected peers!
267+
}
268+
269+
@action
270+
toggleTodo(id: string): void {
271+
this.setState(draft => {
272+
const todo = draft.todos.find(t => t.id === id);
273+
if (todo) todo.done = !todo.done;
274+
});
275+
}
276+
}
277+
```
278+
279+
The CRDT document **is** the actor state directly - no wrapper objects. Changes sync automatically through effects, and the actor handles transport abstraction so your code stays clean and focused on business logic.
280+
281+
See the [collaboration package README](./packages/collaboration/README.md) for complete setup instructions and server configuration.
126282

127283
## Key Design Principles
128284

@@ -131,3 +287,42 @@ By centralizing the actor system knowledge on the main thread, worker threads ca
131287
3. **Scalability**: Centralized routing keeps workers lightweight and focused
132288
4. **Type safety**: Strong typing throughout the message passing system
133289
5. **Consistency**: State updates are events, keeping the API uniform
290+
291+
## Examples & Demos
292+
293+
Working examples are available in the `demos/` directory:
294+
295+
**React:**
296+
- [Counter](./demos/react/counter) - Basic actor with React hooks
297+
- [Collaboration](./demos/react/collaboration) - Real-time collaborative todo list with CRDT sync
298+
299+
**SolidJS:**
300+
- [Counter](./demos/solidjs/counter) - Basic actor with SolidJS primitives
301+
- [Metrics Dashboard](./demos/solidjs/metrics-dashboard) - Performance monitoring dashboard
302+
303+
```bash
304+
# Run a demo
305+
npm run demo:react:counter
306+
npm run demo:solidjs:metrics-dashboard
307+
```
308+
309+
## Documentation
310+
311+
- **[Core Package](./packages/core/README.md)** - Actor, ActorClient, ActorSystem API
312+
- **[React Bindings](./packages/react/README.md)** - useActor, useActorState hooks
313+
- **[SolidJS Bindings](./packages/solidjs/README.md)** - createActor, createActorState primitives
314+
- **[Vite Plugin](./packages/vite-plugin/README.md)** - Multi-threading configuration
315+
- **[Collaboration](./packages/collaboration/README.md)** - CRDT collaboration setup
316+
- **[Performance Guide](./PERFORMANCE.md)** - Optimization strategies and trade-offs
317+
- **[Design Documents](./designs/README.md)** - Architecture deep-dives
318+
319+
## Contributing
320+
321+
Ensemble is in active development and welcomes contributions!
322+
323+
- **Issues**: [GitHub Issues](https://github.com/d-buckner/ensemble/issues)
324+
- **Discussions**: [GitHub Discussions](https://github.com/d-buckner/ensemble/discussions)
325+
326+
## License
327+
328+
[Apache 2.0](./LICENSE)

0 commit comments

Comments
 (0)