|
36 | 36 |
|
37 | 37 | ## Demo App |
38 | 38 |
|
39 | | -- Lives under `lib/a2ui/demo/` and the `A2UI.Demo.*` namespace |
40 | | -- Not part of the published library — embedded example only |
| 39 | +- Lives under `dev/demo/` and the `A2UI.Demo.*` namespace |
| 40 | +- Not part of the published hex package — dev/test only |
| 41 | +- Compiled only in `:dev` and `:test` environments (see `elixirc_paths` in mix.exs) |
41 | 42 | - Config in `config/config.exs` is demo-specific, not library config |
42 | 43 | - Run with `mix a2ui.demo` |
43 | 44 |
|
| 45 | +## Package Info |
| 46 | + |
| 47 | +- Hex package name: `a2ui` |
| 48 | +- Version: 0.1.0 |
| 49 | +- Source: https://github.com/actioncard/a2ui-elixir |
| 50 | +- License: Apache-2.0 |
| 51 | +- Maintainer: Action Card AB |
| 52 | + |
| 53 | +## Architecture |
| 54 | + |
| 55 | +``` |
| 56 | +Agent (GenServer / A2A Remote Agent) |
| 57 | + │ {:a2ui_message, msg} / PubSub |
| 58 | + ▼ |
| 59 | +Transport Layer (A2UI.Transport behaviour) |
| 60 | + │ |
| 61 | + ▼ |
| 62 | +LiveView Process (use A2UI.Live) |
| 63 | + ├─ handle_info({:a2ui_message, msg}) → SurfaceManager → assign |
| 64 | + ├─ render: <.surface /> → Renderer walks adjacency list → function components |
| 65 | + ├─ handle_event("a2ui_action") → EventHandler → Transport → agent |
| 66 | + └─ handle_event("a2ui_input_change") → updates local data model |
| 67 | + │ |
| 68 | + ▼ LiveView WebSocket |
| 69 | +Browser (native HTML, phx-click / phx-change events) |
| 70 | +``` |
| 71 | + |
| 72 | +## Key Design Decisions |
| 73 | + |
| 74 | +1. **Function Components** (not LiveComponents) — surface state managed centrally in LiveView assigns via SurfaceManager |
| 75 | +2. **Pure Functional SurfaceManager** — `apply_message(surfaces, msg) → surfaces`, no GenServer needed |
| 76 | +3. **Data Binding Resolved at Render Time** — props stay as raw JSON until render, LiveView diff engine detects changes |
| 77 | +4. **Adjacency List Stays Flat** — renderer walks `%{id => component}` map via ID lookups, no tree reconstruction |
| 78 | +5. **CSS Convention** — `a2ui-*` BEM-style classes, layout via CSS utility classes, weight via `--a2ui-weight` custom property |
| 79 | +6. **Transport as Behaviour** — `A2UI.Transport` behaviour; `Local` (process messages) now, SSE/A2A later |
| 80 | + |
44 | 81 | ## Do NOT |
45 | 82 |
|
46 | 83 | - Use `Application.get_env/3` in library code — accept config via function arguments |
|
0 commit comments