# facundodlf/book-publishing-app architecture

> Architecture diagram of the GitHub repository facundodlf/book-publishing-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/facundodlf/book-publishing-app
- Repository: https://github.com/facundodlf/book-publishing-app

## Overview

This is a browser-based book and recipe publishing editor. Users organize a book’s front matter, chapters, recipes, and back matter; edit content and layout; optionally structure pasted recipe text; then preview and export a PDF. The book is held in a client-side Zustand store, with a sample book as initial content. Source excerpts show the main UI and PDF flow; the magic-import API implementation and some helper details were not sampled, so those connections are limited to what the excerpts and source index support.

Main entry points: [`lib/book/store.ts`](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/store.ts) (Book state), [`app/page.tsx`](https://github.com/facundodlf/book-publishing-app/blob/main/app/page.tsx) (Editor shell), [`components/book/editor-area.tsx`](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/editor-area.tsx) (Book editor), [`lib/book/pdf.tsx`](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/pdf.tsx) (PDF generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Book workspace"]
  node_home["Editor shell<br/>[page.tsx]"]
  node_structure["Book structure"]
end

subgraph group_authoring["Content authoring"]
  node_editor["Book editor<br/>[editor-area.tsx]"]
  node_rich["Rich text editor<br/>[rich-editor.tsx]"]
  node_style["Style controls<br/>[style-panel.tsx]"]
end

subgraph group_imports["Recipe imports"]
  node_import_dialog["Recipe import"]
  node_recipe_parser["Recipe parser<br/>[import-recipe.ts]"]
  node_magic_dialog["Magic import"]
  node_magic_api["Magic import API<br/>[route.ts]"]
end

subgraph group_publishing["PDF publishing"]
  node_preview["PDF preview<br/>[pdf-preview.tsx]"]
  node_pdf["PDF generator<br/>[pdf.tsx]"]
  node_html_blocks["HTML block conversion<br/>[html-to-blocks.ts]"]
end

subgraph group_model["Book model"]
  node_store["Book state<br/>[store.ts]"]
  node_types["Book schema<br/>[types.ts]"]
  node_sample["Sample book<br/>[sample-book.ts]"]
end

node_user(("Author"))

node_user -->|"edits book"| node_home
node_home -->|"renders"| node_structure
node_home -->|"renders"| node_editor
node_home -->|"renders"| node_style
node_home -->|"opens preview"| node_preview
node_structure -->|"reads and updates"| node_store
node_editor -->|"reads and updates"| node_store
node_editor -->|"renders"| node_rich
node_editor -->|"opens"| node_import_dialog
node_editor -->|"opens"| node_magic_dialog
node_import_dialog -->|"parses recipe"| node_recipe_parser
node_import_dialog -->|"updates entry"| node_store
node_magic_dialog -->|"posts text"| node_magic_api
node_magic_dialog -->|"replaces entry"| node_store
node_store -->|"initializes from"| node_sample
node_store -->|"uses schema"| node_types
node_style -->|"updates styles"| node_store
node_style -->|"exports book"| node_pdf
node_preview -->|"reads book"| node_store
node_preview -->|"generates download"| node_pdf
node_pdf -->|"converts content"| node_html_blocks
node_pdf -->|"uses schema"| node_types

click node_home "https://github.com/facundodlf/book-publishing-app/blob/main/app/page.tsx"
click node_structure "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/structure-sidebar.tsx"
click node_editor "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/editor-area.tsx"
click node_rich "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/rich-editor.tsx"
click node_style "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/style-panel.tsx"
click node_store "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/store.ts"
click node_types "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/types.ts"
click node_sample "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/sample-book.ts"
click node_import_dialog "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/import-recipe-dialog.tsx"
click node_recipe_parser "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/import-recipe.ts"
click node_magic_dialog "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/magic-import-dialog.tsx"
click node_magic_api "https://github.com/facundodlf/book-publishing-app/blob/main/app/api/magic-import/route.ts"
click node_preview "https://github.com/facundodlf/book-publishing-app/blob/main/components/book/pdf-preview.tsx"
click node_pdf "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/pdf.tsx"
click node_html_blocks "https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/html-to-blocks.ts"

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_home,node_structure toneBlue
class node_editor,node_rich,node_style toneAmber
class node_import_dialog,node_recipe_parser,node_magic_dialog,node_magic_api toneMint
class node_preview,node_pdf,node_html_blocks toneRose
class node_store,node_types,node_sample,node_user toneIndigo
```

## Components

### Book workspace

- [Editor shell](https://github.com/facundodlf/book-publishing-app/blob/main/app/page.tsx): `app/page.tsx`
- [Book structure](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/structure-sidebar.tsx): `components/book/structure-sidebar.tsx`

### Content authoring

- [Book editor](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/editor-area.tsx): `components/book/editor-area.tsx`
- [Rich text editor](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/rich-editor.tsx): `components/book/rich-editor.tsx`
- [Style controls](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/style-panel.tsx): `components/book/style-panel.tsx`

### Recipe imports

- [Recipe import](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/import-recipe-dialog.tsx): `components/book/import-recipe-dialog.tsx`
- [Recipe parser](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/import-recipe.ts): `lib/book/import-recipe.ts`
- [Magic import](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/magic-import-dialog.tsx): `components/book/magic-import-dialog.tsx`
- [Magic import API](https://github.com/facundodlf/book-publishing-app/blob/main/app/api/magic-import/route.ts): `app/api/magic-import/route.ts`

### PDF publishing

- [PDF preview](https://github.com/facundodlf/book-publishing-app/blob/main/components/book/pdf-preview.tsx): `components/book/pdf-preview.tsx`
- [PDF generator](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/pdf.tsx): `lib/book/pdf.tsx`
- [HTML block conversion](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/html-to-blocks.ts): `lib/book/html-to-blocks.ts`

### Book model

- [Book state](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/store.ts): `lib/book/store.ts`
- [Book schema](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/types.ts): `lib/book/types.ts`
- [Sample book](https://github.com/facundodlf/book-publishing-app/blob/main/lib/book/sample-book.ts): `lib/book/sample-book.ts`

### Other components

- **Author**

## Connections

- Author → Editor shell: edits book (evidence: `README.md`)
- Editor shell → Book structure: renders (evidence: `app/page.tsx`)
- Editor shell → Book editor: renders (evidence: `app/page.tsx`)
- Editor shell → Style controls: renders (evidence: `app/page.tsx`)
- Editor shell → PDF preview: opens preview (evidence: `app/page.tsx`)
- Book structure → Book state: reads and updates (evidence: `components/book/structure-sidebar.tsx`)
- Book editor → Book state: reads and updates (evidence: `components/book/editor-area.tsx`)
- Book editor → Rich text editor: renders (evidence: `components/book/editor-area.tsx`)
- Book editor → Recipe import: opens (evidence: `components/book/editor-area.tsx`)
- Book editor → Magic import: opens (evidence: `components/book/editor-area.tsx`)
- Recipe import → Recipe parser: parses recipe (evidence: `components/book/import-recipe-dialog.tsx`)
- Recipe import → Book state: updates entry (evidence: `components/book/import-recipe-dialog.tsx`)
- Magic import → Magic import API: posts text (evidence: `components/book/magic-import-dialog.tsx`)
- Magic import → Book state: replaces entry (evidence: `components/book/magic-import-dialog.tsx`)
- Book state → Sample book: initializes from (evidence: `lib/book/store.ts`)
- Book state → Book schema: uses schema (evidence: `lib/book/store.ts`)
- Style controls → Book state: updates styles (evidence: `components/book/style-panel.tsx`)
- Style controls → PDF generator: exports book (evidence: `components/book/style-panel.tsx`)
- PDF preview → Book state: reads book (evidence: `components/book/pdf-preview.tsx`)
- PDF preview → PDF generator: generates download (evidence: `components/book/pdf-preview.tsx`)
- PDF generator → HTML block conversion: converts content (evidence: `lib/book/pdf.tsx`)
- PDF generator → Book schema: uses schema (evidence: `lib/book/pdf.tsx`)
