Skip to content

Commit 608c47e

Browse files
committed
docs: update README to enhance clarity and structure, add quick start guide and AI integration details
1 parent d35f423 commit 608c47e

1 file changed

Lines changed: 84 additions & 131 deletions

File tree

README.md

Lines changed: 84 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -24,131 +24,109 @@
2424

2525
AimDB turns data contracts into the architecture. Define your schemas once and deploy them unchanged across microcontrollers, edge gateways, Kubernetes and the browser.
2626

27-
---
28-
29-
### Vision
27+
[![AimDB Live Demo](assets/demo.gif)](https://aimdb.dev)
3028

31-
A future where every system, from a $2 sensor to a global fleet, shares one data language. Contracts define how data flows, evolves and how it is observed. Infrastructure adapts to data, not the other way around.
29+
> **[See it running →](https://aimdb.dev)** Live weather stations streaming typed contracts across MCU, edge and cloud.
3230
3331
---
3432

35-
### Design Philosophy
36-
37-
In a data-driven architecture, every design decision starts with the data, not the service that produces it.
38-
39-
**Records declare their own semantics.** When you register a record in AimDB, you choose a buffer type that defines how the data moves:
40-
41-
| Buffer | Semantics | Use Cases |
42-
|--------|-----------|-----------|
43-
| **SPMC Ring** | Bounded stream with independent consumers | Sensor telemetry, event logs |
44-
| **SingleLatest** | Only the current value matters | Feature flags, configuration, UI state |
45-
| **Mailbox** | Latest instruction wins | Device commands, actuation, RPC |
46-
47-
These are the three universal primitives of data movement — portable, typed and runtime-agnostic.
33+
## Why AimDB exists
4834

49-
**Observability becomes automatic.** A record that exists is observable by definition. Every producer and consumer relationship is declared in the builder, not discovered through instrumentation.
35+
Most distributed systems layer observability, sync and schema management on top. AimDB builds them into the data model itself.
5036

51-
**Synchronization becomes declarative.** You don't build a sync layer between your MCU, edge gateway and cloud backend. You declare a record with connector metadata on its key and the same typed data flows across all environments without translation.
37+
- **No glue code between layers** — the buffer type on a record defines how it moves. No manual queue wiring.
38+
- **Every record is observable by default** — no separate metrics layer to wire up.
39+
- **Sync is part of the schema, not a service** — declare a connector on the key, not as a separate process.
40+
- **Schema evolution, serialization and connectors derive from the type** — add a trait, not a dependency.
5241

53-
**Cross-cutting concerns derive from the schema.** Instead of adding observability libraries, feature flag SDKs and experiment frameworks as separate integrations, they become intrinsic properties of records — declared once, applied everywhere.
42+
[The Next Era of Software Architecture Is Data-First](https://aimdb.dev/blog/data-driven-design)
5443

5544
---
5645

57-
### How It Works
46+
## Quick start
5847

59-
Define your contracts, choose buffer semantics and wire up connectors — all in one builder block:
48+
### Run it locally in 5 min
6049

61-
```rust
62-
// A sensor node: produce temperature readings, publish over MQTT
63-
builder.configure::<Temperature>("sensor::temp", |reg| {
64-
reg.buffer(BufferCfg::SpmcRing { capacity: 256 })
65-
.source(|ctx, producer| async move {
66-
loop {
67-
let reading = read_sensor().await;
68-
producer.send(Temperature::set(reading, now())).await.ok();
69-
ctx.sleep(Duration::from_secs(1)).await;
70-
}
71-
})
72-
.link_to("mqtt://sensors/temperature")
73-
.with_serializer(Temperature::to_bytes)
74-
.finish();
75-
});
76-
77-
// An edge gateway: receive from MQTT, observe and forward
78-
builder.configure::<Temperature>("gateway::temp", |reg| {
79-
reg.buffer(BufferCfg::SingleLatest)
80-
.link_from("mqtt://sensors/temperature")
81-
.with_deserializer(Temperature::from_bytes)
82-
.tap(log_tap::<Temperature>("edge")) // [edge] 22.5 °C
83-
.finish();
84-
});
50+
```bash
51+
cargo new my-aimdb-app && cd my-aimdb-app
52+
cargo add aimdb-core aimdb-tokio-adapter tokio --features tokio/full
8553
```
8654

87-
Transport topics can be passed as strings to `link_to` / `link_from`, or declared on key enums with `#[link_address = "mqtt://..."]` and resolved at runtime. No separate instrumentation. No SDK integration. No sync code.
88-
89-
---
90-
91-
### Data Contracts
92-
93-
Data contracts are the heart of AimDB. A contract is a plain Rust struct that carries its own identity, version and capabilities — the single source of truth from sensor firmware to browser UI.
55+
Drop this into `src/main.rs`:
9456

9557
```rust
96-
use aimdb_data_contracts::{SchemaType, Settable};
97-
use serde::{Deserialize, Serialize};
58+
use aimdb_core::{buffer::BufferCfg, AimDbBuilder};
59+
use aimdb_tokio_adapter::{TokioAdapter, TokioRecordRegistrarExt};
60+
use std::sync::Arc;
9861

99-
#[derive(Debug, Clone, Serialize, Deserialize)]
62+
#[derive(Clone, Debug)]
10063
pub struct Temperature {
10164
pub celsius: f32,
102-
pub timestamp: u64,
103-
}
104-
105-
impl SchemaType for Temperature {
106-
const NAME: &'static str = "temperature";
107-
const VERSION: u32 = 1;
10865
}
10966

110-
impl Settable for Temperature {
111-
type Value = f32;
112-
fn set(value: Self::Value, timestamp: u64) -> Self {
113-
Self { celsius: value, timestamp }
114-
}
67+
#[tokio::main]
68+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
69+
let runtime = Arc::new(TokioAdapter::new()?);
70+
let mut builder = AimDbBuilder::new().runtime(runtime);
71+
72+
builder.configure::<Temperature>("temp.indoor", |reg| {
73+
reg.buffer(BufferCfg::SpmcRing { capacity: 16 })
74+
.source(|ctx, producer| async move {
75+
for celsius in [21.0, 22.5, 24.1] {
76+
producer.produce(Temperature { celsius }).await.ok();
77+
ctx.time().sleep(ctx.time().secs(1)).await;
78+
}
79+
})
80+
.tap(|ctx, consumer| async move {
81+
let mut reader = consumer.subscribe().unwrap();
82+
while let Ok(t) = reader.recv().await {
83+
ctx.log().info(&format!("temp: {:.1}°C", t.celsius));
84+
}
85+
})
86+
.finish();
87+
});
88+
89+
builder.build()?.run().await?;
90+
Ok(())
11591
}
11692
```
11793

118-
This struct compiles for `no_std` embedded targets and standard Rust alike. `SchemaType` gives the record its identity and version. `Settable` provides a canonical constructor so producers can create records from a raw valuethis is the interface used by `producer.send(Temperature::set(reading, now()))` in the builder.
94+
`cargo run` — three temperature readings stream through a typed pipeline. The same code compiles for Embassy on a Cortex-M4 or WASM in the browser by swapping the runtime adapternothing else changes.
11995

120-
#### Contract Attributes
96+
### Run a real weather mesh in less than 30 min
12197

122-
Contracts gain capabilities through trait implementations. Each trait is a compile-time declaration of what a contract *can do*, not a runtime configuration:
98+
A full MCU → edge → cloud mesh: three weather stations, MQTT broker and a central hub.
12399

124-
| Attribute | Trait | What It Enables |
125-
|-----------|-------|-----------------|
126-
| **Settable** | `Settable` | Canonical constructor from a raw value — the interface behind `producer.send(T::set(value, ts))`. |
127-
| **Streamable** | `Streamable` | Cross-boundary transport — WASM, WebSocket, CLI. One registry, zero parallel type systems. |
128-
| **Migratable** | `MigrationStep` | Bidirectional schema evolution with typed up/down transforms and chained version steps. |
129-
| **Observable** | `Observable` | Signal extraction for thresholds, logging and monitoring. Icon, unit and `format_log()` built in. |
130-
| **Linkable** | `Linkable` | Wire-format serialization for connectors — MQTT, KNX and any future transport. |
131-
| **Simulatable** | `Simulatable` | Realistic test data generation with random walks, trends and configurable parameters. |
100+
```bash
101+
git clone https://github.com/aimdb-dev/aimdb
102+
cd aimdb/examples/weather-mesh-demo
103+
docker compose up
104+
```
132105

133-
For example, `Observable` turns a contract into a loggable, monitorable signal:
106+
[Walkthrough in the docs](https://aimdb.dev/docs/getting-started)
134107

135-
```rust
136-
impl Observable for Temperature {
137-
type Signal = f32;
138-
const ICON: &'static str = "thermometer";
139-
const UNIT: &'static str = "°C";
108+
---
140109

141-
fn signal(&self) -> f32 { self.celsius }
110+
## What you get
142111

143-
fn format_log(&self, node_id: &str) -> String {
144-
format!("[{}] {:.1} °C", node_id, self.celsius)
145-
}
146-
}
147-
```
112+
- **One async API across MCU, edge, cloud and browser.** Tokio, Embassy, WASM — same code, different runtime adapter. → [How the runtime abstraction works](https://aimdb.dev/blog/building-aimdb-one-async-api)
113+
- **Typed Rust structs are the schema.** No IDL, no codegen step, no schema registry.
114+
- **Three buffer primitives** that cover most data-movement patterns:
115+
116+
| Buffer | Semantics | Use cases |
117+
| --- | --- | --- |
118+
| **SPMC Ring** | Bounded stream with independent consumers | Sensor telemetry, event logs |
119+
| **SingleLatest** | Only the current value matters | Feature flags, config, UI state |
120+
| **Mailbox** | Latest instruction wins | Device commands, actuation, RPC |
121+
122+
- **Capabilities are unlocked by traits.** Implement `Streamable` to cross WASM/WebSocket/CLI boundaries, `Migratable` for typed schema evolution, `Observable` for monitoring, `Linkable` for wire-format connectors. Without the trait, the type system says no.
123+
- **Connectors that ship today:** MQTT, KNX, WebSocket. Writing your own is one trait impl.
148124

149-
Each trait you implement unlocks a capability — contracts without `Observable` simply can't be tapped; contracts without `Linkable` can't be wired to connectors. The type system enforces what your data can do.
125+
→ Deep dives: [data contracts](https://aimdb.dev/blog/data-contracts-deep-dive) · [source/tap/transform](https://aimdb.dev/blog/source-tap-transform) · [schema migration](https://aimdb.dev/blog/schema-migration-without-ceremony) · [reactive pipelines](https://aimdb.dev/blog/reactive-pipelines)
150126

151-
#### Platform-Agnostic by Design
127+
---
128+
129+
### Platform-Agnostic by Design
152130

153131
The same contract works across all runtimes without modification:
154132

@@ -166,29 +144,13 @@ The Rust type system enforces correctness at compile time. The dataflow engine's
166144

167145
---
168146

169-
### Getting Started
170-
171-
#### 1. See it live
147+
## Ask your AI about your running system
172148

173-
Explore a running sensor mesh — no setup required:
174-
175-
<p align="center">
176-
<a href="https://aimdb.dev">
177-
<img src="assets/demo.gif" alt="AimDB Live Demo" width="600">
178-
</a>
179-
</p>
149+
AimDB ships an MCP server. Point any MCP-compatible client at a running instance and query it in natural language.
180150

181-
> **[aimdb.dev](https://aimdb.dev)** — live weather stations streaming typed contracts across MCU, edge and cloud.
151+
[![AimDB MCP demo](assets/copilot-communication.gif)](assets/copilot-communication.gif)
182152

183-
#### 2. Explore with AI
184-
185-
Connect an MCP-compatible editor to the live demo and query your data in natural language — no install required:
186-
187-
<p align="center">
188-
<img src="assets/copilot-communication.gif" alt="AimDB MCP Live Demo" width="600">
189-
</p>
190-
191-
Add the remote MCP server to your workspace:
153+
Try it against the live demo — no install required. Add this to your workspace:
192154

193155
`.vscode/mcp.json`:
194156

@@ -203,27 +165,18 @@ Add the remote MCP server to your workspace:
203165
}
204166
```
205167

206-
Then ask: *"What's the current temperature in Munich?"* — see the [MCP server docs](tools/aimdb-mcp/) for Claude Desktop and other editors.
207-
208-
#### 3. Run locally
168+
Then ask: *"What's the current temperature in Munich?"*
209169

210-
Spin up a full MCU → edge → cloud mesh with one command:
170+
See the [MCP server docs](tools/aimdb-mcp/) for Claude Desktop and other editors or read the deep dive: [AI-Assisted System Introspection: AimDB Meets the Model Context Protocol](https://aimdb.dev/blog/ai-introspection-with-mcp).
211171

212-
```bash
213-
cd examples/weather-mesh-demo
214-
docker compose up
215-
```
216-
217-
This starts three weather stations, an MQTT broker and a central hub — all wired together with typed data contracts.
172+
---
218173

219-
#### 4. Build your own
174+
## Learn more
220175

221-
- [Quick Start Guide](https://aimdb.dev/docs/getting-started) — Dependencies, platform setup and your first contract
222-
- [Data Contracts](https://aimdb.dev/docs/data-contracts) — Type-safe schemas with built-in capabilities
223-
- [Connectors](https://aimdb.dev/docs/connectors) — MQTT, KNX, WebSocket and more
224-
- [Deployment](https://aimdb.dev/docs/deployment) — Running on MCU, edge, cloud and browser
225-
- [API Reference](https://docs.rs/aimdb-core) — Full Rust API documentation
226-
- [Blog](https://aimdb.dev/blog) — News, tutorials and insights from the AimDB team
176+
- [Quick Start Guide](https://aimdb.dev/docs/getting-started) — dependencies, platform setup, your first contract
177+
- [API reference (docs.rs)](https://docs.rs/aimdb-core) — full Rust API
178+
- [Blog](https://aimdb.dev/blog) — design notes, deep dives, release write-ups
179+
- [Live demo](https://aimdb.dev) — running sensor mesh
227180

228181
---
229182

@@ -250,7 +203,7 @@ This starts three weather stations, an MQTT broker and a central hub — all wir
250203

251204
---
252205

253-
### Contributing
206+
## Contributing
254207

255208
Found a bug or want a feature? Open a [GitHub issue](https://github.com/aimdb-dev/aimdb/issues).
256209

@@ -260,7 +213,7 @@ Want to contribute? See the [contributing guide](CONTRIBUTING.md). We have [good
260213

261214
---
262215

263-
### License
216+
## License
264217

265218
[Apache 2.0](LICENSE)
266219

0 commit comments

Comments
 (0)