What is a Mixin?
A mixin is a label on a document that tells the platform how to interpret its content node tree. It determines:- Which viewer/editor the UI renders for the document
- What node types are expected in the tree
- What features are available on content nodes
- How the content was produced (spatial parsing, markdown conversion, email ingestion, etc.)
mixins field and are composable — a document can use multiple mixins when one builds on another.
Content Structure Overview
| Mixin | Root Node | Tree Shape | UI Component | Use Cases |
|---|---|---|---|---|
spatial | document | Deep — page → content-area → line → word | Spatial viewer with bounding boxes | PDFs, scans, images, PowerPoints |
text | document | Shallow — text nodes | Text viewer | Plain text files |
markdown | document | Shallow — block-level nodes | Block editor | News articles, rich-text content, general writing |
email | email | Shallow — block-level nodes | Email header panel + block editor | Email messages |
Spatial Content Structure
The spatial mixin is the original Kodexa content structure, designed for documents where physical layout matters — PDFs, scanned images, PowerPoints, and similar formats.Tree structure
Key characteristics
- Deep tree —
document→page→content-area→line→word - Bounding boxes — Every node carries spatial coordinates
[x, y, width, height]describing its position on the page - Page-based — Content is organized by physical pages
- Word-level granularity — Individual words are nodes, enabling precise tagging and spatial queries
- Read-only in UI — Users view the spatial layout and tag content, but don’t edit the text directly
Spatial features
Content nodes in a spatial document carry spatial features:Example selectors
Text Content Structure
The text mixin is the simplest structure, used for plain text content without spatial information or rich formatting.Tree structure
Key characteristics
- Shallow tree — Minimal hierarchy
- No bounding boxes — No spatial positioning
- No formatting — Plain text only
- View-only in UI — Rendered as plain text
Markdown Content Structure
The markdown mixin represents rich-text content as a tree of block-level content nodes. Each block is an independently editable region in the UI, and inline formatting (bold, italic, links, inline code) is stored as markdown syntax within the block’s content.Why block-level?
A full markdown AST would create nodes for every bold span, link, and inline code segment. This is unnecessarily complex for editing — every keystroke in a bold word would require tree restructuring. Instead, the markdown mixin uses block-level nodes only:- Block nodes —
heading,paragraph,list,code-block, etc. — are ContentNodes in the tree - Inline formatting —
**bold**,*italic*,[links](url),`code`— stays as markdown syntax within each block’s content string
Tree structure
Block node types
- Text Blocks
- Container Blocks
- Media & Structural Blocks
| Node Type | Features | Content |
|---|---|---|
heading | markdown:level (1-6) | Inline markdown text |
paragraph | — | Inline markdown text |
blockquote | — | Inline markdown text |
content_parts and rendered as rich text in the editor.Key characteristics
- Shallow tree —
document→ blocks, with nesting only for lists and tables - No bounding boxes — Content is not spatially positioned
- Editable in UI — Block-based editor where each ContentNode is an editable block
- Inline markdown — Rich formatting preserved as markdown syntax within block content
Example selectors
Email Content Structure
The email mixin composes themarkdown mixin to represent email messages. Email-specific metadata (from, to, subject, date) is stored in document metadata, while the email body uses the same block-level markdown nodes.
Tree structure
Document metadata
Email headers are stored as document-level metadata, not as content nodes:| Field | Type | Description |
|---|---|---|
from | string | Sender email address |
to | string[] | Recipient addresses |
cc | string[] | CC addresses |
bcc | string[] | BCC addresses |
subject | string | Email subject line |
date | datetime | Send date/time |
messageId | string | RFC 2822 Message-ID |
inReplyTo | string | Parent message ID for threading |
threadId | string | Conversation thread identifier |
headers | object | Additional raw email headers |
Attachments
Email attachments are not embedded in the email KDDB. Each attachment becomes its own document family in the store with the appropriate mixin:- A PDF attachment → spatial mixin with its own KDDB
- A text file attachment → text mixin
- A forwarded email → email mixin
Key characteristics
- Root node is
email(notdocument) — distinguishes email from general markdown - Composable — The
emailmixin includes themarkdownmixin for the body - Headers in metadata — Email-specific data lives in document metadata, not the tree
- Same block editor — The body uses the same block editor as the
markdownmixin - Same selectors — Query the body with the same selector syntax
Example selectors
The Block Editor
Themarkdown and email mixins share a block-based editor in the Kodexa UI. Each content node is rendered as an independently editable block, similar to Notion or Google Docs.
How editing maps to the KDDB
Every user action in the editor corresponds directly to a KDDB content node operation:| User Action | KDDB Operation |
|---|---|
| Edit text in a block | Update content_parts on the ContentNode |
| Reorder blocks (drag & drop) | Update index on affected ContentNodes |
| Change block type (e.g., paragraph → heading) | Update node_type, add/remove features |
| Delete a block | Remove ContentNode from tree |
| Add a new block | Create new ContentNode at the target index |
| Split a block (press Enter) | Split content_parts, create new ContentNode after current |
| Merge blocks (Backspace at start) | Merge content into previous node, remove current |
Block type selection
Users can change a block’s type using a toolbar or/ command. Compatible conversions include:
paragraph↔heading↔blockquoteparagraph→list(wraps in a list with one list-item)paragraph→code-block- Any text block →
horizontal-rule(clears content)
Extraction Across All Content Structures
The extraction pipeline works the same way regardless of mixin. Tags are applied to content nodes, grouped by index, and converted to data objects: This means you can extract structured data from markdown and email content using the same data definitions, tagging models, and extraction engine that work with spatial documents. For example:- News articles — Extract entities, topics, dates, and quotes from markdown content
- Emails — Extract action items, deadlines, and referenced documents from email bodies
- Reports — Extract metrics, summaries, and key findings from rich-text documents
Choosing a Content Structure
Use spatial when...
Use spatial when...
You’re processing PDFs, scanned documents, images, or PowerPoints where physical layout matters. The spatial mixin preserves bounding boxes, page structure, and word-level positioning — essential for document understanding, table extraction, and content that needs to be visually overlaid on the original document.
Use text when...
Use text when...
You have plain text content with no formatting or layout requirements. This is the simplest structure and is appropriate for log files, raw text exports, or content that will be processed purely for its text.
Use markdown when...
Use markdown when...
You have rich-text content that users need to view and edit — news articles, reports, knowledge base entries, or any content that benefits from structured blocks (headings, lists, code, tables) with inline formatting. The block editor makes this content interactive.
Use email when...
Use email when...
You’re ingesting email messages. The email mixin gives you structured metadata (from, to, subject, date, threading) plus a markdown body that users can view and edit. Attachments become their own document families with appropriate mixins.
What’s Next?
Document Structure Deep Dive
Detailed look at content nodes, spatial data, and how the tree maps to real documents.
SDK Reference
Work with documents programmatically in Python and TypeScript.
Data Definitions
Define taxonomies to extract structured data from any content structure.
Selectors
Query content nodes using the XPath-like selector language.
