Lix tracks changes at the entity level using schemas to define entity structure. This works for any file type - text or binary.
An entity is a meaningful, addressable unit of data within a file. Plugins define what counts as an entity based on the file type.
| File Type | Example Entities |
|---|---|
| JSON | /user/name, /theme, /items/0 (JSON Pointer paths) |
| Markdown | A paragraph, heading, list, or code block |
| Spreadsheets (Excel, CSV) | A row, or an individual cell |
| Design Files (Figma, Sketch) | A component, frame, layer, text node, or vector shape |
| 3D Models (glTF, FBX) | A mesh, material, bone in a skeleton, or node in the scene graph |
| Image Files (PSD, Krita) | A layer, labeled object or region, or path |
The key insight: Lix works with any file format - text or binary. Plugins teach Lix how to understand the structure, enabling entity-level tracking regardless of the underlying format.
Entity-level tracking enables:
Fine-Grained Diffs
/user/age property changed from 30 to 31"Semantic Queries
/user/age"Smart Merging
Precise Comments
The JSON plugin uses JSON Pointer (RFC 6901) to identify entities:
{
"user": {
"name": "John Doe",
"age": 30
},
"theme": "dark"
}This creates entities with these IDs:
/user/name with value "John Doe"/user/age with value 30/theme with value "dark"If someone changes theme to "light", the plugin detects this as a change to the /theme entity. This change is queryable, mergeable, and trackable at a granular level.
A schema defines the structure and constraints of an entity type. Schemas use JSON Schema with Lix-specific extensions prefixed with x-lix-.
Here's the actual schema from the JSON plugin:
import type { LixSchemaDefinition } from "@lix-js/sdk";
export const JSONPointerValueSchema: LixSchemaDefinition = {
"x-lix-key": "plugin_json_pointer_value", // Unique identifier
"x-lix-version": "1.0", // Schema version
"x-lix-primary-key": ["/path"], // Primary key
type: "object",
properties: {
path: {
type: "string",
description: "RFC 6901 JSON Pointer (e.g., '/user/name')",
},
value: {
// Accepts any JSON value
description: "JSON value at the pointer path",
},
},
required: ["path", "value"],
additionalProperties: false,
};Lix-Specific Fields:
x-lix-key: Globally unique schema identifier (snake_case)x-lix-version: Version number for schema evolutionx-lix-primary-key: JSON Pointer(s) to properties that uniquely identify an entityStandard JSON Schema Fields:
type, properties, required, additionalProperties, etc.Schemas can include additional constraints and features:
const MySchema: LixSchemaDefinition = {
"x-lix-key": "my_entity",
"x-lix-version": "1.0",
"x-lix-primary-key": ["/id"],
"x-lix-unique": [["/email"]], // Unique constraints
"x-lix-foreign-keys": [ // Relationships
{
properties: ["/user_id"],
references: {
schemaKey: "user",
properties: ["/id"],
},
},
],
type: "object",
properties: {
id: {
type: "string",
"x-lix-default": "lix_uuid_v7()", // Auto-generated ID
},
email: { type: "string" },
user_id: { type: "string" },
created_at: {
type: "string",
format: "date-time",
"x-lix-default": "lix_now()", // Auto-generated timestamp
},
},
required: ["id", "email"],
};Additional Fields:
x-lix-unique: Properties that must be unique across entitiesx-lix-foreign-keys: Define relationships between entity typesx-lix-default: Auto-generated values (UUIDs, timestamps, etc.)Validation
Interoperability
Evolution
x-lix-version) enables safe data model changesPlugin Schema Entity
↓ ↓ ↓
Understands Defines structure Actual data
file format of entity data being trackedExample Flow:
theme from "dark" to "light" in a JSON file/themepath and value fields/theme is updated in the database with the new valueThis separation makes Lix extensible - add support for any file format (text or binary) by: