# 3235143305-design/xunwei-plandraft-demo architecture

> Architecture diagram of the GitHub repository 3235143305-design/xunwei-plandraft-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/3235143305-design/xunwei-plandraft-demo
- Repository: https://github.com/3235143305-design/xunwei-plandraft-demo

## Overview

寻味 PlanDraft is a local synthetic trip-draft demo. Users enter a destination and dates, save a draft, and can explicitly restore it or encounter version-conflict protection; confirmation is also supported by the API. The browser keeps only a draft pointer in localStorage, while Node serves the same-origin UI/API and SQLite stores full drafts. The documented demo deliberately synthesizes itinerary data and does not call travel or AI services. The graph follows shown calls and README-described behavior; unsampled HTML/UI wiring and internal server routing details are not inferred beyond the available evidence.

Main entry points: [`app/plan-draft-demo.js`](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft-demo.js) (Demo form UI), [`app/plan-draft.js`](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft.js) (Draft client), [`services/plan-draft-store.js`](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/services/plan-draft-store.js) (SQLite draft store), [`app/api.js`](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/api.js) (Same-origin API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser demo"]
  node_demo_ui["Demo form UI<br/>[plan-draft-demo.js]"]
  node_synthetic_builder["Synthetic itinerary<br/>[plan-draft-demo.js]"]
  node_draft_client["Draft client<br/>[plan-draft.js]"]
  node_api_fetch["Same-origin API client<br/>[api.js]"]
end

subgraph group_server["Local API"]
  node_node_server["HTTP server<br/>[server.js]"]
  node_draft_api["Draft API handlers<br/>[server.js]"]
end

subgraph group_draft["Draft domain"]
  node_draft_rules["Draft lifecycle rules"]
end

subgraph group_persistence["Persistence"]
  node_sqlite_store[("SQLite draft store")]
  node_sqlite_db[("SQLite database")]
end

node_traveler(("Traveler"))
node_local_storage[("Browser localStorage")]

node_traveler -->|"enters dates"| node_demo_ui
node_demo_ui -->|"builds draft"| node_synthetic_builder
node_demo_ui -->|"saves or restores"| node_draft_client
node_demo_ui -->|"provides request"| node_api_fetch
node_draft_client -->|"stores pointer"| node_local_storage
node_draft_client -->|"sends requests"| node_api_fetch
node_api_fetch -.->|"fetches same-origin"| node_node_server
node_node_server -->|"dispatches requests"| node_draft_api
node_draft_api -->|"calls store"| node_sqlite_store
node_sqlite_store -->|"creates and transitions"| node_draft_rules
node_sqlite_store -->|"reads and writes"| node_sqlite_db

click node_demo_ui "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft-demo.js"
click node_synthetic_builder "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft-demo.js"
click node_draft_client "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft.js"
click node_api_fetch "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/api.js"
click node_node_server "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/server.js"
click node_draft_api "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/server.js"
click node_sqlite_store "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/services/plan-draft-store.js"
click node_draft_rules "https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/services/plan-draft-service.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_demo_ui,node_synthetic_builder,node_draft_client,node_api_fetch toneBlue
class node_node_server,node_draft_api,node_local_storage toneAmber
class node_draft_rules toneMint
class node_sqlite_store,node_sqlite_db toneRose
class node_traveler toneIndigo
```

## Components

### Browser demo

- [Demo form UI](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft-demo.js): `app/plan-draft-demo.js`
- [Synthetic itinerary](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft-demo.js): `app/plan-draft-demo.js`
- [Draft client](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/plan-draft.js): `app/plan-draft.js`
- [Same-origin API client](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/app/api.js): `app/api.js`

### Local API

- [HTTP server](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/server.js): `server.js`
- [Draft API handlers](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/server.js): `server.js`

### Draft domain

- [Draft lifecycle rules](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/services/plan-draft-service.js): `services/plan-draft-service.js`

### Persistence

- [SQLite draft store](https://github.com/3235143305-design/xunwei-plandraft-demo/blob/main/services/plan-draft-store.js): `services/plan-draft-store.js`
- **SQLite database**

### Other components

- **Traveler**
- **Browser localStorage**

## Connections

- Traveler → Demo form UI: enters dates (evidence: `README.md`)
- Demo form UI → Synthetic itinerary: builds draft (evidence: `app/plan-draft-demo.js`)
- Demo form UI → Draft client: saves or restores (evidence: `app/plan-draft-demo.js`)
- Demo form UI → Same-origin API client: provides request (evidence: `app/plan-draft-demo.js`)
- Draft client → Browser localStorage: stores pointer (evidence: `app/plan-draft.js`)
- Draft client → Same-origin API client: sends requests (evidence: `app/plan-draft.js`)
- Same-origin API client → HTTP server: fetches same-origin (evidence: `app/api.js`)
- HTTP server → Draft API handlers: dispatches requests (evidence: `server.js`)
- Draft API handlers → SQLite draft store: calls store (evidence: `server.js`)
- SQLite draft store → Draft lifecycle rules: creates and transitions (evidence: `services/plan-draft-store.js`)
- SQLite draft store → SQLite database: reads and writes (evidence: `services/plan-draft-store.js`)
