# 0xgf/boneyard architecture

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

- Interactive diagram: https://gitdiagram.com/0xgf/boneyard
- Repository: https://github.com/0xgf/boneyard

## Overview

1. **Repository shape**
   - This is a monorepo with two main products: a reusable package in `packages/boneyard` and a documentation/demo site in `apps/docs`.
   - The root `bones/` directory holds example/generated skeleton definitions used across the docs and package tests.

2. **Core product: `packages/boneyard`**
   - The package is the actual `boneyard-js` library.
   - Its job is to capture UI layouts as “bones” and render those bones back into framework-specific skeleton loaders.
   - The package exposes multiple entrypoints for different runtimes: React, Preact, Vue, Svelte 5, Angular, React Native, plus a Vite plugin and CLI.

3. **Shared capture and layout engine**
   - The center of the package is framework-agnostic logic in files like `shared.ts`, `layout.ts`, `extract.ts`, `responsive.ts`, and `runtime.ts`.
   - This layer is responsible for turning measured component geometry into a normalized bones format, then adapting that format to different viewport sizes and themes.

4. **Web capture pipeline**
   - For web frameworks, the CLI or Vite plugin opens a browser session, scans the app for `<Skeleton name="...">` usage, and snapshots the rendered layout at configured breakpoints.
   - That output is written as `.bones.json` files, which are the main interchange format used everywhere else in the repo.

5. **Native capture pipeline**
   - React Native uses a different path: the `<Skeleton>` component can scan the live UI tree in dev mode while the CLI is running.
   - The native side measures views through React Native internals, then sends the captured layout back to the CLI so it can be serialized into the same bones format as web.

6. **Framework adapters**
   - The package is split into thin adapters for each runtime: `react.tsx`, `preact.tsx`, `vue.tsx`, `svelte.*`, `angular.ts`, and `react-native.tsx`.
   - These adapters share the same underlying bones data model but provide the correct component syntax, loading behavior, and framework integration for each ecosystem.

7. **Distribution and entrypoints**
   - `packages/boneyard/bin/cli.js` is the command-line entry point for capture/build workflows.
   - The package also ships compiled artifacts in `dist/`, suggesting it is published as a consumable library rather than only used locally.
   - The `native*.js` and `native-scan.*` files indicate separate runtime support for device scanning and native execution.

8. **Bones as the architectural boundary**
   - A bones file is the key boundary between “measured UI” and “rendered skeleton.”
   - Generated bones are stored per component name, and the runtime resolves them through a registry import such as `./bones/registry`.
   - This keeps capture-time concerns separate from render-time concerns.

9. **Docs site as the integration showcase**
   - `apps/docs` is a Next.js app that serves both product documentation and live examples.
   - Its routes map directly to product capabilities: install, config, CLI, output, performance, SSR, and framework-specific pages for React, Vue, Svelte, Preact, Angular, and React Native.
   - This app is the clearest place to see the package integrated end-to-end.

10. **Docs app structure**
   - The docs site contains reusable UI pieces like `sidebar`, `toc`, `page-skeleton-wrapper`, `skeleton-demo`, and shared UI controls under `components/ui`.
   - It also includes many local bone definitions under `apps/docs/src/bones`, which power the examples and interactive previews on the site.

11. **Generated content and registry loading**
   - Both the docs app and the package include `registry.js` files that act as the lookup table for named skeletons.
   - The architecture assumes a one-time registry import in the app entry so components can resolve their matching skeleton metadata at runtime.

12. **Deployment and tooling**
   - The docs app has a `vercel.json`, so the public documentation site is deployed as a Vercel-hosted Next.js app.
   - The repo uses a workspace-based setup (`pnpm-workspace.yaml`) and includes tests and a benchmark script inside the package, indicating the package layer is meant to be performance-sensitive and cross-framework stable.

13. **Overall data flow**
   - Author UI in a supported framework → run CLI or Vite plugin to capture layout → write `.bones.json` files → import the registry into the app → `<Skeleton name="...">` renders either the real content or the generated skeleton.
   - The same bones format flows across web and React Native, which is the main architectural idea tying the repo together.

Main entry points: [`packages/boneyard/src/index.ts`](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/index.ts) (Public API), [`packages/boneyard/src/shared.ts`](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/shared.ts) (Shared engine), [`apps/docs/src/app/page.tsx`](https://github.com/0xgf/boneyard/blob/main/apps/docs/src/app/page.tsx) (Docs site), [`packages/boneyard/src/extract.ts`](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/extract.ts) (Extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monorepo["Monorepo"]
  node_workspace["Workspace<br/>pnpm monorepo"]
end

subgraph group_package["boneyard package"]
  node_package_root["boneyard<br/>library pkg"]
  node_package_api["Public API<br/>entrypoints<br/>[index.ts]"]
  node_shared_engine["Shared engine<br/>core logic<br/>[shared.ts]"]
  node_layout_engine["Layout model<br/>geometry/layout<br/>[layout.ts]"]
  node_extractor["Extractor<br/>capture parser<br/>[extract.ts]"]
  node_responsive_adapter["Responsive<br/>viewport adapter<br/>[responsive.ts]"]
  node_runtime_core["Runtime<br/>registry resolver<br/>[runtime.ts]"]
  node_framework_adapters["Adapters<br/>framework shims<br/>[react.tsx]"]
  node_web_capture["Web capture<br/>cli/vite capture<br/>[cli.js]"]
  node_native_capture["Native capture<br/>react-native scan<br/>[native-scan.tsx]"]
  node_dist_artifacts["Published builds<br/>compiled output<br/>[react.js]"]
end

subgraph group_docs["Docs app"]
  node_docs_root["Docs site<br/>nextjs app<br/>[page.tsx]"]
  node_docs_routes["Docs pages<br/>content routes<br/>[page.tsx]"]
  node_docs_components["Docs UI<br/>shared ui<br/>[sidebar.tsx]"]
  node_docs_bones["Docs bones<br/>example data<br/>[registry.js]"]
end

subgraph group_bones["Shared bones"]
  node_registry_pkg["Bone registry<br/>lookup table<br/>[registry.js]"]
end

node_workspace -->|"contains"| node_package_root
node_workspace -->|"contains"| node_docs_root
node_package_root -->|"exports"| node_package_api
node_package_api -->|"uses"| node_shared_engine
node_shared_engine -->|"normalizes"| node_layout_engine
node_shared_engine -->|"extracts"| node_extractor
node_shared_engine -->|"adapts"| node_responsive_adapter
node_shared_engine -->|"resolves"| node_runtime_core
node_package_api -->|"adapts"| node_framework_adapters
node_package_api -->|"captures"| node_web_capture
node_package_api -->|"captures"| node_native_capture
node_web_capture -->|"feeds"| node_extractor
node_native_capture -->|"feeds"| node_extractor
node_extractor -->|"writes"| node_registry_pkg
node_runtime_core -->|"imports"| node_registry_pkg
node_package_api -->|"ships"| node_dist_artifacts
node_docs_root -->|"serves"| node_docs_routes
node_docs_root -->|"composes"| node_docs_components
node_docs_root -->|"demonstrates"| node_docs_bones
node_docs_bones -->|"mirrors"| node_registry_pkg

click node_package_root "https://github.com/0xgf/boneyard/tree/main/packages/boneyard"
click node_package_api "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/index.ts"
click node_shared_engine "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/shared.ts"
click node_layout_engine "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/layout.ts"
click node_extractor "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/extract.ts"
click node_responsive_adapter "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/responsive.ts"
click node_runtime_core "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/runtime.ts"
click node_framework_adapters "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/react.tsx"
click node_web_capture "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/bin/cli.js"
click node_native_capture "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/native-scan.tsx"
click node_registry_pkg "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/bones/registry.js"
click node_dist_artifacts "https://github.com/0xgf/boneyard/blob/main/packages/boneyard/dist/react.js"
click node_docs_root "https://github.com/0xgf/boneyard/blob/main/apps/docs/src/app/page.tsx"
click node_docs_routes "https://github.com/0xgf/boneyard/blob/main/apps/docs/src/app/overview/page.tsx"
click node_docs_components "https://github.com/0xgf/boneyard/blob/main/apps/docs/src/components/sidebar.tsx"
click node_docs_bones "https://github.com/0xgf/boneyard/blob/main/apps/docs/src/bones/registry.js"

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_workspace toneBlue
class node_package_root,node_package_api,node_shared_engine,node_layout_engine,node_extractor,node_responsive_adapter,node_runtime_core,node_framework_adapters,node_web_capture,node_native_capture,node_dist_artifacts toneAmber
class node_docs_root,node_docs_routes,node_docs_components,node_docs_bones toneMint
class node_registry_pkg toneRose
```

## Components

### Monorepo

Workspace root tying the published package to the docs/demo app and shared bones assets.

- **Workspace**: pnpm monorepo · Root workspace and dependency boundary for the repo.

### boneyard package

Reusable library that captures layouts and renders skeleton loaders across runtimes.

- [boneyard](https://github.com/0xgf/boneyard/tree/main/packages/boneyard): library pkg · Published cross-framework skeleton library. · `packages/boneyard`
- [Public API](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/index.ts): entrypoints · Main package exports and framework-specific entrypoints. · `packages/boneyard/src/index.ts`
- [Shared engine](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/shared.ts): core logic · Framework-agnostic capture, normalization, and runtime helpers. · `packages/boneyard/src/shared.ts`
- [Layout model](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/layout.ts): geometry/layout · Converts measured UI into normalized bones layout data. · `packages/boneyard/src/layout.ts`
- [Extractor](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/extract.ts): capture parser · Finds skeleton usage and extracts measurements from rendered apps. · `packages/boneyard/src/extract.ts`
- [Responsive](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/responsive.ts): viewport adapter · Adapts bones data across breakpoints and themes. · `packages/boneyard/src/responsive.ts`
- [Runtime](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/runtime.ts): registry resolver · Resolves named bones at render time and coordinates loader behavior. · `packages/boneyard/src/runtime.ts`
- [Adapters](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/react.tsx): framework shims · Thin framework wrappers for React, Preact, Vue, Svelte, Angular, and React Native. · `packages/boneyard/src/react.tsx`
- [Web capture](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/bin/cli.js): cli/vite capture · Browser-based capture flow used by the CLI and Vite plugin for web frameworks. · `packages/boneyard/bin/cli.js`
- [Native capture](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/native-scan.tsx): react-native scan · Dev-mode React Native scanning path that captures live UI through native internals. · `packages/boneyard/src/native-scan.tsx`
- [Published builds](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/dist/react.js): compiled output · Compiled distributable artifacts shipped for consumer runtimes. · `packages/boneyard/dist/react.js`

### Docs app

Next.js documentation and showcase site for the package.

- [Docs site](https://github.com/0xgf/boneyard/blob/main/apps/docs/src/app/page.tsx): nextjs app · Documentation and interactive showcase for the package. · `apps/docs/src/app/page.tsx`
- [Docs pages](https://github.com/0xgf/boneyard/blob/main/apps/docs/src/app/overview/page.tsx): content routes · Capability-focused routes for install, config, CLI, output, performance, SSR, and framework pages. · `apps/docs/src/app/overview/page.tsx`
- [Docs UI](https://github.com/0xgf/boneyard/blob/main/apps/docs/src/components/sidebar.tsx): shared ui · Reusable site chrome, demos, and controls used throughout the docs app. · `apps/docs/src/components/sidebar.tsx`
- [Docs bones](https://github.com/0xgf/boneyard/blob/main/apps/docs/src/bones/registry.js): example data · Local example bones and registry used to power demos and previews. · `apps/docs/src/bones/registry.js`

### Shared bones

Generated skeleton definitions and registries used by the package and docs.

- [Bone registry](https://github.com/0xgf/boneyard/blob/main/packages/boneyard/src/bones/registry.js): lookup table · Runtime import surface that maps component names to generated bones metadata. · `packages/boneyard/src/bones/registry.js`

## Connections

- Workspace → boneyard: contains · Workspace hosts the reusable package.
- Workspace → Docs site: contains · Workspace hosts the documentation app.
- boneyard → Public API: exports · Package entrypoints expose the consumer API.
- Public API → Shared engine: uses · Public adapters build on the shared core.
- Shared engine → Layout model: normalizes · Measured geometry is converted into bones layout.
- Shared engine → Extractor: extracts · Shared logic drives capture and parsing.
- Shared engine → Responsive: adapts · Bones are reshaped for viewport and theme variants.
- Shared engine → Runtime: resolves · Render-time lookup and loader behavior use the runtime layer.
- Public API → Adapters: adapts · Framework-specific wrappers sit on top of the common model.
- Public API → Web capture: captures · CLI and Vite flows collect browser layouts.
- Public API → Native capture: captures · React Native uses a separate scanning path.
- Web capture → Extractor: feeds · Browser snapshots are parsed into bones data.
- Native capture → Extractor: feeds · Native measurements are serialized through the same format.
- Extractor → Bone registry: writes · Captured components are stored as named bones entries.
- Runtime → Bone registry: imports · App runtime resolves named skeletons through the registry.
- Public API → Published builds: ships · Built artifacts are published for consumption.
- Docs site → Docs pages: serves · The app exposes capability-specific documentation pages.
- Docs site → Docs UI: composes · Shared UI pieces build the docs experience and live demos.
- Docs site → Docs bones: demonstrates · Local bones definitions power examples and previews.
- Docs bones → Bone registry: mirrors · Docs use the same registry-based lookup pattern as the package.
