Skip to content

Add internals architecture documentation page - #194

Merged
berendkleinhaneveld merged 1 commit into
masterfrom
claude/collagraph-architecture-docs-iv22tu
Jul 13, 2026
Merged

Add internals architecture documentation page#194
berendkleinhaneveld merged 1 commit into
masterfrom
claude/collagraph-architecture-docs-iv22tu

Conversation

@berendkleinhaneveld

Copy link
Copy Markdown
Collaborator

Summary

Adds an Internals → Architecture page to the docs, modelled after observ's architecture page. It explains how Collagraph's internals fit together and — as specifically requested — gives a visual representation of how elements and fragments relate to each other.

The page centres on the Fragment/element relationship and covers:

  • The four cooperating pieces: the SFC compiler, Fragments, Renderers, and observ
  • Fragments vs. elements — the persistent Python-side description driving a disposable toolkit-side element
  • The Fragment family (Fragment, ControlFlowFragment, ListFragment, ComponentFragment, SlotFragment, DynamicFragment)
  • The template tree vs. render tree distinction (template_children / render_children() / iter_all_children())
  • Compilation — real, compiled render() output for a counter and a v-for list
  • Mounting, anchors and first()
  • Reactivity — how a state change flows to a targeted element update
  • The fragment lifecycle (create / mount / unmount(destroy=…))
  • How renderers close the loop

The prose is grounded in the actual source — the compiled snippets and the directive/fragment tables were produced by compiling real .cgx examples, so they match what the compiler emits.

Visuals

Nine Mermaid diagrams serve as the visual representation, including the big-picture flow, a fragments-vs-elements diagram, the fragment class hierarchy, template-vs-render tree, the template→fragment mapping, the mount sequence, the reactive update flow, and a lifecycle state diagram.

Changes

  • docs/internals/architecture.md — new page
  • mkdocs.yml — add a pymdownx.superfences custom fence so Material renders Mermaid diagrams, and add the Internals: Architecture nav section

Verification

  • mkdocs build --strict passes
  • Confirmed all 9 diagrams emit class="mermaid" in the built HTML and the nav link appears

🤖 Generated with Claude Code


Generated by Claude Code

Add an Internals > Architecture page modelled after observ's architecture
docs, explaining how the SFC compiler, Fragments, Renderers and observ
cooperate. Focuses on the Fragment/element relationship, the template vs
render tree distinction, mounting/anchors, reactive updates and the
fragment lifecycle, with Mermaid diagrams as visual representations.

Enable Mermaid rendering via a pymdownx.superfences custom fence and add
the Internals section to the nav.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UttpCd1K8B8kpbqqMtUMVE
@berendkleinhaneveld
berendkleinhaneveld merged commit 4b63eb5 into master Jul 13, 2026
10 checks passed
@berendkleinhaneveld
berendkleinhaneveld deleted the claude/collagraph-architecture-docs-iv22tu branch July 13, 2026 07:23
berendkleinhaneveld added a commit that referenced this pull request Jul 21, 2026
Features:
- Add pure-Python view API as alternative to cgx templates (#193)
- Support text elements for PySide widgets that display text (#191)

Fixes & internals:
- Fragment parenting overhaul (#162)
- Fix PyInstaller hook for CGX files inside packages (#184)
- Write compiled AST to temp file when CGX_DEBUG is set (#175)

Performance:
- Speed up mount path: cheap arity check, reuse first(), leaner emit (#186)
- Cache Fragment._component_parent() lookups (#187)
- Avoid redundant anchor lookups in Fragment.anchor() and unkeyed v-for (#188)

Documentation:
- Add MkDocs documentation with GitHub Pages deployment (#176)
- Add internals architecture documentation page (#194)
- Add docs badge and links to README (#192)

Tooling & CI:
- Add benchmark suite and per-PR benchmark CI workflow (#185)
- Make benchmark CI guard robust against run-to-run noise (#196)
- Update GitHub actions from Node 20 to Node 24 (#190)
- Migrate from pre-commit to prek (#195)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants