# geodes-sms/lowkey architecture

> Architecture diagram of the GitHub repository geodes-sms/lowkey, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/geodes-sms/lowkey
- Repository: https://github.com/geodes-sms/lowkey

## Overview

1. **Overall shape**
   - This repository is a Python framework for collaborative modeling, split into a reusable core under `lowkey/` and a concrete example application under `lowkey-examples/mindmap/`.
   - The core is layered from high-level modeling abstractions down to CRDT primitives and then to network transport.

2. **Top-level architectural layers**
   - `lowkey/collabtypes`: the collaborative metamodeling layer.
   - `lowkey/lww`: the conflict-free replicated data type layer.
   - `lowkey/network`: distributed client/server synchronization over ZeroMQ.
   - `lowkey/collabapi`: a command-oriented API that translates textual modeling operations into session actions.
   - `lowkey-examples/mindmap`: a sample domain built on top of the framework.

3. **CRDT subsystem: `lowkey/lww`**
   - This is the lowest state-management layer and implements last-write-wins data structures: register, set, map, graph, vertex, and edge.
   - These types provide the convergence semantics that make replication safe across peers.
   - The tests here focus on cloning, embedding, graph behavior, and multi-user register semantics, which suggests this layer is the conflict-resolution boundary of the system.

4. **Collaborative modeling type system: `lowkey/collabtypes`**
   - This layer models collaborative entities such as `Entity`, `Clabject`, `Association`, `Node`, `Model`, `Clock`, and literal values.
   - It bridges modeling concepts to the underlying CRDT storage and replication semantics.
   - This is the architectural boundary where domain modeling constructs become distributed, versioned objects.

5. **Command/API layer: `lowkey/collabapi`**
   - The API accepts modeling commands and parses them into structured operations.
   - Commands include creating clabjects, creating associations, and updating entities.
   - `Session` is the execution boundary here: parsed commands are applied against a session state rather than directly manipulating raw data structures.

6. **Network subsystem: `lowkey/network`**
   - This package connects collaborators over the network using ZeroMQ.
   - `Client`, `Server`, `Memory`, and `LWWSession` indicate a replicated session architecture where state updates are exchanged and stored.
   - The README’s ZeroMQ references and “republishing updates from clients” note imply a pub-sub style with update redistribution, not a centralized database backend.

7. **Data flow across layers**
   - User or test input enters as a command string or domain operation.
   - The parser in `collabapi` converts it to a command object.
   - The session applies the command to collaborative types.
   - Those types persist and resolve conflicts using LWW CRDTs.
   - In networked mode, the session’s updates are sent through the client/server layer and propagated to other peers.

8. **Example application: `lowkey-examples/mindmap`**
   - The mindmap example is a full client of the framework, showing how to define a domain metamodel, parser/editor, scenario setup, and tests.
   - It contains its own `metamodel/`, `editor/`, `scenarios/`, and `tests/` packages, which makes it a good reference for how an application is expected to sit on top of the core layers.
   - This example is likely the best place to infer how a real domain maps onto collaborative modeling primitives.

9. **Mindmap domain structure**
   - The mindmap metamodel defines `MindMap`, `Topic`, `CentralTopic`, `MainTopic`, `SubTopic`, and `Marker`.
   - These entities show how domain concepts are represented as model elements rather than application-specific records.
   - The presence of a factory and package module indicates the domain is modeled declaratively and then instantiated through framework-provided mechanisms.

10. **Mindmap editor and commands**
   - `editor/DSLParser.py`, `Editor.py`, and `MindmapSession.py` form a thin application-specific interaction layer.
   - `commands/ReadCommand.py` and `ReadObjectsCommand.py` suggest the editor supports query/read operations in addition to structural editing.
   - This layer sits above the core command/session APIs and adapts a human-facing DSL to the framework.

11. **Scenarios and testing**
   - `scenarios/BuildMindmapScenario.py` provides a scripted setup for a sample model state, which is useful for demos or regression setups.
   - Test suites exist separately for the CRDT layer, the collaborative type system, the network layer, the command API, and the example app.
   - That separation reflects the architecture: each subsystem is intended to be testable in isolation.

12. **Key architectural boundaries**
   - The main boundary is between **domain logic** and **replication mechanics**: mindmap or other models live above `collabtypes`, while consistency and transport live below it.
   - Another boundary is between **local state manipulation** and **distributed synchronization**: `Session`/`LWWSession` hide replication details from the application layer.
   - The command DSL provides a stable interface so the example app does not need to know CRDT or network details.

13. **Technology and runtime notes**
   - The project is Python-based and packaged with `setup.py`.
   - ZeroMQ is the material external transport dependency.
   - CI is run via GitHub Actions and historically Travis, but those are build concerns rather than runtime architecture.

14. **What an architecture diagram should emphasize**
   - Show a vertical stack: DSL/Editor or application commands at the top, collaborative modeling types in the middle, LWW CRDTs beneath, and network replication at the bottom.
   - Show the mindmap example as a consumer of the core framework, not part of the framework itself.
   - Represent the server/client path as an update propagation loop around the session state, with CRDTs ensuring convergence across replicas.

Main entry points: [`lowkey/collabtypes/Entity.py`](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Entity.py) (Entity Model), [`lowkey/collabapi/commands/Command.py`](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/Command.py) (Command), [`lowkey/collabapi/Session.py`](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/Session.py) (Session), [`lowkey/lww/LWWGraph.py`](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWGraph.py) (LWW Graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core framework"]
  node_collab_parser["API Parser<br/>command parser<br/>[Parser.py]"]
  node_collab_session["Session<br/>[Session.py]"]
  node_command_base["Command<br/>[Command.py]"]
  node_create_clabject["Create Clabject<br/>create command"]
  node_create_assoc["Create Assoc<br/>create command"]
  node_update_command["Update<br/>[UpdateCommand.py]"]
  node_entity_model["Entity Model<br/>collab types<br/>[Entity.py]"]
  node_clabject_model["Clabject<br/>collab type<br/>[Clabject.py]"]
  node_assoc_model["Association<br/>collab type<br/>[Association.py]"]
  node_model_clock(("Model Clock<br/>versioning<br/>[Clock.py]"))
  node_literals["Literals<br/>value types<br/>[Literals.py]"]
  node_lww_register(("LWW Register<br/>crdt<br/>[LWWRegister.py]"))
  node_lww_set(("LWW Set<br/>crdt<br/>[LWWSet.py]"))
  node_lww_map(("LWW Map<br/>crdt<br/>[LWWMap.py]"))
  node_lww_graph[("LWW Graph<br/>crdt graph<br/>[LWWGraph.py]")]
  node_lww_vertex(("Vertex<br/>graph part<br/>[LWWVertex.py]"))
  node_lww_edge(("Edge<br/>graph part<br/>[LWWEdge.py]"))
  node_net_client["Client<br/>[Client.py]"]
  node_net_server["Server<br/>[Server.py]"]
  node_net_memory[("Memory<br/>replica store<br/>[Memory.py]")]
  node_net_session["LWW Session<br/>replicated session<br/>[LWWSession.py]"]
end

subgraph group_mindmap["Mindmap example"]
  node_mind_parser["DSL Parser<br/>app parser<br/>[DSLParser.py]"]
  node_mind_editor["Editor<br/>[Editor.py]"]
  node_mind_session["Mindmap Session<br/>app session<br/>[MindmapSession.py]"]
  node_mind_factory["Factory<br/>[MindMapFactory.py]"]
  node_mind_package["Package<br/>[MindMapPackage.py]"]
  node_mind_model["MindMap Model<br/>domain model<br/>[MindMapModel.py]"]
  node_mind_topic["Topics<br/>domain entities<br/>[Topic.py]"]
  node_mind_marker(("Marker<br/>domain entity<br/>[Marker.py]"))
  node_build_scenario["Build Scenario"]
end

node_collab_parser -->|"creates actions"| node_collab_session
node_command_base -->|"specializes"| node_create_clabject
node_command_base -->|"specializes"| node_create_assoc
node_command_base -->|"specializes"| node_update_command
node_collab_session -->|"applies to"| node_entity_model
node_collab_session -->|"executes"| node_command_base
node_entity_model -->|"includes"| node_clabject_model
node_entity_model -->|"includes"| node_assoc_model
node_entity_model -->|"tracks"| node_model_clock
node_entity_model -->|"uses"| node_literals
node_clabject_model -->|"persists in"| node_lww_map
node_assoc_model -->|"persists in"| node_lww_graph
node_lww_graph -->|"composes"| node_lww_vertex
node_lww_graph -->|"composes"| node_lww_edge
node_lww_map -->|"uses"| node_lww_register
node_lww_set -->|"uses"| node_lww_register
node_net_client -->|"syncs"| node_net_server
node_net_server -->|"stores"| node_net_memory
node_net_session -->|"wraps"| node_net_client
node_net_session -->|"replicates"| node_lww_graph
node_mind_parser -->|"feeds"| node_mind_editor
node_mind_editor -->|"uses"| node_mind_session
node_mind_session -->|"extends"| node_collab_session
node_mind_factory -->|"declares"| node_mind_package
node_mind_model -->|"contains"| node_mind_topic
node_mind_topic -->|"annotates"| node_mind_marker
node_build_scenario -->|"creates"| node_mind_model
node_build_scenario -->|"drives"| node_mind_editor

click node_collab_parser "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/Parser.py"
click node_collab_session "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/Session.py"
click node_command_base "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/Command.py"
click node_create_clabject "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/CreateClabjectCommand.py"
click node_create_assoc "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/CreateAssociationCommand.py"
click node_update_command "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/UpdateCommand.py"
click node_entity_model "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Entity.py"
click node_clabject_model "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Clabject.py"
click node_assoc_model "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Association.py"
click node_model_clock "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Clock.py"
click node_literals "https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Literals.py"
click node_lww_register "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWRegister.py"
click node_lww_set "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWSet.py"
click node_lww_map "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWMap.py"
click node_lww_graph "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWGraph.py"
click node_lww_vertex "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWVertex.py"
click node_lww_edge "https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWEdge.py"
click node_net_client "https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Client.py"
click node_net_server "https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Server.py"
click node_net_memory "https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Memory.py"
click node_net_session "https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/LWWSession.py"
click node_mind_parser "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/DSLParser.py"
click node_mind_editor "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/Editor.py"
click node_mind_session "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/MindmapSession.py"
click node_mind_factory "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/MindMapFactory.py"
click node_mind_package "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/MindMapPackage.py"
click node_mind_model "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/MindMapModel.py"
click node_mind_topic "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/Topic.py"
click node_mind_marker "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/Marker.py"
click node_build_scenario "https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/scenarios/BuildMindmapScenario.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_collab_parser,node_collab_session,node_command_base,node_create_clabject,node_create_assoc,node_update_command,node_entity_model,node_clabject_model,node_assoc_model,node_model_clock,node_literals,node_lww_register,node_lww_set,node_lww_map,node_lww_graph,node_lww_vertex,node_lww_edge,node_net_client,node_net_server,node_net_memory,node_net_session toneBlue
class node_mind_parser,node_mind_editor,node_mind_session,node_mind_factory,node_mind_package,node_mind_model,node_mind_topic,node_mind_marker,node_build_scenario toneAmber
```

## Components

### Core framework

Reusable collaborative modeling stack

- [API Parser](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/Parser.py): command parser · Turns text commands into structured operations · `lowkey/collabapi/Parser.py`
- [Session](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/Session.py): api session · Applies commands to collaborative state · `lowkey/collabapi/Session.py`
- [Command](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/Command.py): command model · Base command abstraction · `lowkey/collabapi/commands/Command.py`
- [Create Clabject](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/CreateClabjectCommand.py): create command · Builds collaborative model elements · `lowkey/collabapi/commands/CreateClabjectCommand.py`
- [Create Assoc](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/CreateAssociationCommand.py): create command · Builds relationships between entities · `lowkey/collabapi/commands/CreateAssociationCommand.py`
- [Update](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabapi/commands/UpdateCommand.py): update command · Applies edits to existing entities · `lowkey/collabapi/commands/UpdateCommand.py`
- [Entity Model](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Entity.py): collab types · Core collaborative entity abstractions · `lowkey/collabtypes/Entity.py`
- [Clabject](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Clabject.py): collab type · Typed model element abstraction · `lowkey/collabtypes/Clabject.py`
- [Association](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Association.py): collab type · Links entities within a model · `lowkey/collabtypes/Association.py`
- [Model Clock](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Clock.py): versioning · Tracks collaborative version state · `lowkey/collabtypes/Clock.py`
- [Literals](https://github.com/geodes-sms/lowkey/blob/main/lowkey/collabtypes/Literals.py): value types · Scalar and literal value support · `lowkey/collabtypes/Literals.py`
- [LWW Register](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWRegister.py): crdt · Last-write-wins register primitive · `lowkey/lww/LWWRegister.py`
- [LWW Set](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWSet.py): crdt · Convergent set primitive · `lowkey/lww/LWWSet.py`
- [LWW Map](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWMap.py): crdt · Convergent map primitive · `lowkey/lww/LWWMap.py`
- [LWW Graph](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWGraph.py): crdt graph · Replicated graph container · `lowkey/lww/LWWGraph.py`
- [Vertex](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWVertex.py): graph part · Graph vertex state · `lowkey/lww/LWWVertex.py`
- [Edge](https://github.com/geodes-sms/lowkey/blob/main/lowkey/lww/LWWEdge.py): graph part · Graph edge state · `lowkey/lww/LWWEdge.py`
- [Client](https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Client.py): network client · Sends local updates to peers · `lowkey/network/Client.py`
- [Server](https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Server.py): network server · Receives and republishes updates · `lowkey/network/Server.py`
- [Memory](https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/Memory.py): replica store · In-memory replicated state store · `lowkey/network/Memory.py`
- [LWW Session](https://github.com/geodes-sms/lowkey/blob/main/lowkey/network/LWWSession.py): replicated session · Session bridge for networked collaboration · `lowkey/network/LWWSession.py`

### Mindmap example

Concrete application built on the framework

- [DSL Parser](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/DSLParser.py): app parser · Mindmap-specific textual editor parser · `lowkey-examples/mindmap/editor/DSLParser.py`
- [Editor](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/Editor.py): app editor · Application editing façade · `lowkey-examples/mindmap/editor/Editor.py`
- [Mindmap Session](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/editor/MindmapSession.py): app session · App session wiring for mindmap actions · `lowkey-examples/mindmap/editor/MindmapSession.py`
- [Factory](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/MindMapFactory.py): metamodel factory · Creates mindmap model instances · `lowkey-examples/mindmap/metamodel/MindMapFactory.py`
- [Package](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/MindMapPackage.py): metamodel package · Declares the mindmap metamodel · `lowkey-examples/mindmap/metamodel/MindMapPackage.py`
- [MindMap Model](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/MindMapModel.py): domain model · Top-level mindmap domain object · `lowkey-examples/mindmap/metamodel/entities/MindMapModel.py`
- [Topics](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/Topic.py): domain entities · Mindmap topic hierarchy · `lowkey-examples/mindmap/metamodel/entities/Topic.py`
- [Marker](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/metamodel/entities/Marker.py): domain entity · Topic annotation or tag · `lowkey-examples/mindmap/metamodel/entities/Marker.py`
- [Build Scenario](https://github.com/geodes-sms/lowkey/blob/main/lowkey-examples/mindmap/scenarios/BuildMindmapScenario.py): scenario · Scripted mindmap setup · `lowkey-examples/mindmap/scenarios/BuildMindmapScenario.py`

## Connections

- API Parser → Session: creates actions · Parsed text is executed by a session
- Command → Create Clabject: specializes · Concrete command type
- Command → Create Assoc: specializes · Concrete command type
- Command → Update: specializes · Concrete command type
- Session → Entity Model: applies to · Session mutates collaborative entities
- Session → Command: executes · Consumes parsed commands
- Entity Model → Clabject: includes · Core modeling abstraction
- Entity Model → Association: includes · Core modeling abstraction
- Entity Model → Model Clock: tracks · Versioning and collaboration state
- Entity Model → Literals: uses · Value representation
- Clabject → LWW Map: persists in · Backed by CRDT storage
- Association → LWW Graph: persists in · Relationship state stored as graph
- LWW Graph → Vertex: composes · Graph internals
- LWW Graph → Edge: composes · Graph internals
- LWW Map → LWW Register: uses · Map entries rely on register semantics
- LWW Set → LWW Register: uses · Set membership resolves via register semantics
- Client → Server: syncs · Client/server update exchange
- Server → Memory: stores · Server keeps replicated state in memory
- LWW Session → Client: wraps · Network session sends local updates
- LWW Session → LWW Graph: replicates · Session bridges network and CRDT state
- DSL Parser → Editor: feeds · DSL input drives editor actions
- Editor → Mindmap Session: uses · Editor delegates to app session
- Mindmap Session → Session: extends · Application session builds on core API session
- Factory → Package: declares · Factory follows metamodel package
- MindMap Model → Topics: contains · Mindmap structure
- Topics → Marker: annotates · Topics can carry markers
- Build Scenario → MindMap Model: creates · Scenario assembles example state
- Build Scenario → Editor: drives · Scenario can exercise editor flows
