create-idocs 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -2
- package/dist/chunk-YVMC6WCS.js +43 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/scaffold.d.ts +8 -0
- package/dist/scaffold.js +8 -0
- package/package.json +32 -3
- package/template/.claude/skills/idocs/SKILL.md +108 -0
- package/template/.claude/skills/idocs/assets/examples/shop.diagram.yaml +164 -0
- package/template/.claude/skills/idocs/references/format.md +123 -0
- package/template/.claude/skills/idocs/references/layout.md +39 -0
- package/template/.claude/skills/idocs/references/scenarios.md +104 -0
- package/template/.claude/skills/idocs/references/setup.md +95 -0
- package/template/.claude/skills/idocs/references/troubleshooting.md +49 -0
- package/template/.github/workflows/deploy.yml +60 -0
- package/template/CLAUDE.md +27 -0
- package/template/README.md +30 -0
- package/template/_gitignore +6 -0
- package/template/_pnpm-workspace.yaml +4 -0
- package/template/astro.config.mjs +32 -0
- package/template/diagrams/diagram.schema.json +647 -0
- package/template/diagrams/shop/diagram.yaml +105 -0
- package/template/diagrams/shop/nodes/gateway.md +1 -0
- package/template/diagrams/shop/nodes/orders.md +9 -0
- package/template/package.json +29 -0
- package/template/public/favicon.svg +1 -0
- package/template/src/content/docs/architecture.mdx +13 -0
- package/template/src/content/docs/editing.mdx +62 -0
- package/template/src/content/docs/index.mdx +18 -0
- package/template/src/content.config.ts +7 -0
- package/template/src/env.d.ts +2 -0
- package/template/src/styles/custom.css +16 -0
- package/template/tsconfig.json +6 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# yaml-language-server: $schema=../diagram.schema.json
|
|
2
|
+
title: The shop
|
|
3
|
+
description: |
|
|
4
|
+
A small online shop. **Click any box** to read about it, or pick a scenario above
|
|
5
|
+
the diagram and press play to watch a request travel through the system.
|
|
6
|
+
|
|
7
|
+
groups:
|
|
8
|
+
backend:
|
|
9
|
+
label: Backend
|
|
10
|
+
caption: runs on Kubernetes
|
|
11
|
+
|
|
12
|
+
nodes:
|
|
13
|
+
browser:
|
|
14
|
+
kind: client
|
|
15
|
+
icon: react
|
|
16
|
+
title: Shopper browser
|
|
17
|
+
sub: React storefront
|
|
18
|
+
gateway:
|
|
19
|
+
kind: gateway
|
|
20
|
+
icon: nginx
|
|
21
|
+
title: API gateway
|
|
22
|
+
sub: ":443"
|
|
23
|
+
in: backend
|
|
24
|
+
catalog:
|
|
25
|
+
kind: service
|
|
26
|
+
icon: nodejs
|
|
27
|
+
title: Catalog
|
|
28
|
+
sub: ":4001 · Node.js"
|
|
29
|
+
lines: [products and prices]
|
|
30
|
+
uses: [cache, db]
|
|
31
|
+
in: backend
|
|
32
|
+
orders:
|
|
33
|
+
kind: service
|
|
34
|
+
icon: lucide:shopping-cart
|
|
35
|
+
title: Orders
|
|
36
|
+
sub: ":4002"
|
|
37
|
+
lines: [creates and tracks orders]
|
|
38
|
+
uses: [db]
|
|
39
|
+
in: backend
|
|
40
|
+
cache:
|
|
41
|
+
kind: cache
|
|
42
|
+
icon: redis
|
|
43
|
+
title: Redis
|
|
44
|
+
sub: product cache
|
|
45
|
+
in: backend
|
|
46
|
+
db:
|
|
47
|
+
kind: database
|
|
48
|
+
icon: postgresql
|
|
49
|
+
title: PostgreSQL
|
|
50
|
+
sub: products and orders
|
|
51
|
+
in: backend
|
|
52
|
+
payments:
|
|
53
|
+
kind: external
|
|
54
|
+
icon: stripe
|
|
55
|
+
title: Stripe
|
|
56
|
+
sub: payment provider
|
|
57
|
+
|
|
58
|
+
edges:
|
|
59
|
+
- browser -> gateway: HTTPS
|
|
60
|
+
- gateway -> catalog: /products
|
|
61
|
+
- gateway -> orders: /orders
|
|
62
|
+
- catalog -> cache: { kind: data, label: lookup }
|
|
63
|
+
- catalog -> db: { kind: data }
|
|
64
|
+
- orders -> db: { kind: data }
|
|
65
|
+
- orders -> payments: { kind: channel, label: charge, auth: API key, payload: payment intent }
|
|
66
|
+
|
|
67
|
+
scenarios:
|
|
68
|
+
browse:
|
|
69
|
+
title: Browse a product
|
|
70
|
+
summary: The shopper opens a product page. The catalog answers from the cache.
|
|
71
|
+
steps:
|
|
72
|
+
- browser -> catalog: GET /products/42
|
|
73
|
+
- catalog -> cache: { label: GET product:42, kind: lookup }
|
|
74
|
+
- cache -> catalog: { label: hit, note: A cache hit never touches the database. }
|
|
75
|
+
- catalog -> browser: 200 OK
|
|
76
|
+
|
|
77
|
+
checkout:
|
|
78
|
+
title: Place an order
|
|
79
|
+
summary: The order is saved first, charged second, and confirmed last.
|
|
80
|
+
phases:
|
|
81
|
+
- title: Save
|
|
82
|
+
steps:
|
|
83
|
+
- browser -> orders: POST /orders
|
|
84
|
+
- orders -> db: { label: INSERT order (pending), kind: lookup }
|
|
85
|
+
- title: Charge
|
|
86
|
+
steps:
|
|
87
|
+
- orders -> payments: create payment intent
|
|
88
|
+
- at payments:
|
|
89
|
+
label: authorise card
|
|
90
|
+
note: Stripe is the one step we do not control.
|
|
91
|
+
- payments -> orders: succeeded
|
|
92
|
+
- title: Confirm
|
|
93
|
+
steps:
|
|
94
|
+
- orders -> db: { label: mark paid, kind: lookup }
|
|
95
|
+
- orders -> browser: 201 Created
|
|
96
|
+
|
|
97
|
+
declined:
|
|
98
|
+
title: Card declined
|
|
99
|
+
summary: Stripe refuses the card. The order stays pending and the shopper is told why.
|
|
100
|
+
steps:
|
|
101
|
+
- browser -> orders: POST /orders
|
|
102
|
+
- orders -> payments: create payment intent
|
|
103
|
+
- payments -> orders: { label: card_declined, kind: error }
|
|
104
|
+
- at orders: { label: keep order pending, kind: error }
|
|
105
|
+
- orders -> browser: { label: 402 Payment Required, kind: error }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The only public entry point. It checks the user's token and routes each request by path.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The orders service owns the order lifecycle.
|
|
2
|
+
|
|
3
|
+
| State | Meaning |
|
|
4
|
+
|---|---|
|
|
5
|
+
| `pending` | saved, not yet charged |
|
|
6
|
+
| `paid` | the payment went through |
|
|
7
|
+
| `failed` | the card was declined |
|
|
8
|
+
|
|
9
|
+
This text is `diagrams/shop/nodes/orders.md`. Edit it, and it changes in the drawer that opens when a reader clicks the box.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-docs",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "astro dev",
|
|
7
|
+
"build": "astro build",
|
|
8
|
+
"preview": "astro preview",
|
|
9
|
+
"check": "idocs check",
|
|
10
|
+
"idocs": "idocs"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@astrojs/react": "^7.0.0",
|
|
14
|
+
"@astrojs/starlight": "^0.42.0",
|
|
15
|
+
"@fontsource/ibm-plex-mono": "^5.3.0",
|
|
16
|
+
"@fontsource/ibm-plex-sans": "^5.3.0",
|
|
17
|
+
"@the-package-labs/idocs-astro": "^0.3.1",
|
|
18
|
+
"@the-package-labs/idocs-react": "^0.3.1",
|
|
19
|
+
"astro": "^7.0.0",
|
|
20
|
+
"react": "^19.3.0",
|
|
21
|
+
"react-dom": "^19.3.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@the-package-labs/idocs": "^0.3.1",
|
|
25
|
+
"@types/react": "^19.2.0",
|
|
26
|
+
"@types/react-dom": "^19.2.0"
|
|
27
|
+
},
|
|
28
|
+
"packageManager": "pnpm@12.9.1"
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="#0a6f8f"/><circle cx="9" cy="16" r="3" fill="#fff"/><circle cx="23" cy="9" r="3" fill="#fff"/><circle cx="23" cy="23" r="3" fill="#fff"/><path d="M12 16h4l3-7h1M16 16l3 7h1" stroke="#fff" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: How the shop works
|
|
3
|
+
description: The architecture of the example shop, as a diagram you can explore.
|
|
4
|
+
tableOfContents: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import Diagram from '@the-package-labs/idocs-astro/Diagram.astro'
|
|
8
|
+
|
|
9
|
+
This page is `src/content/docs/architecture.mdx`. The picture comes from `diagrams/shop/diagram.yaml`.
|
|
10
|
+
|
|
11
|
+
<Diagram name="shop" showDescription />
|
|
12
|
+
|
|
13
|
+
Use the page around a diagram for what the diagram cannot say: why a choice was made, what to watch out for, who to ask.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Editing diagrams
|
|
3
|
+
description: The ten-minute tour of diagram.yaml.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Diagram from '@the-package-labs/idocs-astro/Diagram.astro'
|
|
7
|
+
|
|
8
|
+
Every diagram is a folder under `diagrams/`. Save a file and the page reloads.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm idocs new payments # creates diagrams/payments/diagram.yaml
|
|
12
|
+
pnpm check # validates every diagram; errors point at file:line:column
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Show it on any page:
|
|
16
|
+
|
|
17
|
+
```mdx
|
|
18
|
+
import Diagram from '@the-package-labs/idocs-astro/Diagram.astro'
|
|
19
|
+
|
|
20
|
+
<Diagram name="payments" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Boxes and arrows
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
nodes:
|
|
27
|
+
api: { kind: service, icon: nodejs, title: Orders API, sub: ":4002" }
|
|
28
|
+
db: { kind: database, icon: postgresql, title: PostgreSQL }
|
|
29
|
+
|
|
30
|
+
edges:
|
|
31
|
+
- api -> db: { kind: data, label: SQL }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`kind` picks a default icon and colour. `icon` takes a name like `postgresql`; find one with `pnpm idocs icons search redis`. Put what a reader should see when they click a box in `diagrams/<name>/nodes/<id>.md`.
|
|
35
|
+
|
|
36
|
+
## Stories
|
|
37
|
+
|
|
38
|
+
A scenario is a story that plays over the diagram:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
scenarios:
|
|
42
|
+
load-orders:
|
|
43
|
+
title: Load my orders
|
|
44
|
+
steps:
|
|
45
|
+
- api -> db: { label: SELECT, kind: lookup }
|
|
46
|
+
- db -> api: rows
|
|
47
|
+
- at api: { label: build the response, note: Why this step matters. }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Group steps into `phases:` for longer stories, give failures their own scenario, and put long ones in `scenarios/<id>.yaml`.
|
|
51
|
+
|
|
52
|
+
Every scenario can also be read as a swimlane **story** (the *Story* button above the diagram). Give steps a `title` and a `detail` to write it up, and set `mode: story` on a scenario to open it that way.
|
|
53
|
+
|
|
54
|
+
## Try one
|
|
55
|
+
|
|
56
|
+
Here is the shop diagram again. Press play on **Card declined**.
|
|
57
|
+
|
|
58
|
+
<Diagram name="shop" scenario="declined" />
|
|
59
|
+
|
|
60
|
+
## Learn the rest
|
|
61
|
+
|
|
62
|
+
The full format, layout hints, icons and theming are documented at https://github.com/The-Package-Labs/idocs. If you use Claude Code, the `idocs` skill in `.claude/skills/` knows the format: ask it to draw a flow from your code, and it will run `pnpm check` and fix what it reports.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: My docs
|
|
3
|
+
description: How our system works, with diagrams you can play.
|
|
4
|
+
template: splash
|
|
5
|
+
hero:
|
|
6
|
+
tagline: Click a box to read about it. Pick a scenario and press play to watch a request travel through the system.
|
|
7
|
+
actions:
|
|
8
|
+
- text: See how the shop works
|
|
9
|
+
link: architecture/
|
|
10
|
+
icon: right-arrow
|
|
11
|
+
- text: Edit these docs
|
|
12
|
+
link: editing/
|
|
13
|
+
variant: minimal
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
import Diagram from '@the-package-labs/idocs-astro/Diagram.astro'
|
|
17
|
+
|
|
18
|
+
<Diagram name="shop" scenario="checkout" />
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { defineCollection } from 'astro:content'
|
|
2
|
+
import { docsLoader } from '@astrojs/starlight/loaders'
|
|
3
|
+
import { docsSchema } from '@astrojs/starlight/schema'
|
|
4
|
+
|
|
5
|
+
export const collections = {
|
|
6
|
+
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* Your theme. Override --idocs-* tokens to restyle every diagram, for example:
|
|
2
|
+
|
|
3
|
+
.idocs { --idocs-accent: #7a4ec4; }
|
|
4
|
+
:root[data-theme='dark'] .idocs { --idocs-accent: #b79bf0; }
|
|
5
|
+
*/
|
|
6
|
+
:root {
|
|
7
|
+
--sl-color-accent-high: #0a6f8f;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:root[data-theme="light"] {
|
|
11
|
+
--sl-color-accent: #0a6f8f;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:root[data-theme="dark"] {
|
|
15
|
+
--sl-color-accent: #55bcdb;
|
|
16
|
+
}
|