skilldrop-cli 0.16.21 → 0.16.23
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/bin/skilldrop.js +5 -3
- package/catalogue.json +1 -0
- package/model-routing.json +4 -0
- package/package.json +1 -1
- package/packs/solution-architect/skills/interactive-diagram/SKILL.md +160 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/eval_queries.json +12 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/evals.json +164 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/1/README.md +11 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/1/api/app.py +43 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/1/docker-compose.yml +20 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/1/web/checkout.js +9 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/1/worker/worker.py +23 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/10/build-4127-timing.json +179 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/AbstractSensor.java +36 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/AlertService.java +15 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/Greenhouse.java +36 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/Sensor.java +10 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/SoilMoistureSensor.java +25 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/TemperatureSensor.java +19 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/11/src/org/example/greenhouse/Zone.java +26 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/3/schema.sql +35 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/README.md +26 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/config/default.json +29 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/clients/transcription.js +25 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/db.js +16 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/handlers/storageWebhook.js +43 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/jobs/transcribeEpisode.js +28 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/mailer.js +18 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/server.js +32 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/4/src/worker.js +32 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/6/notes.txt +7 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/6/trace-quote-slow.jsonl +13 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/7/oncall-notes.md +16 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/7/system-log.txt +14 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/8/run-4471.json +151 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/9/chat-export.txt +16 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/9/lesson-sync.log +24 -0
- package/packs/solution-architect/skills/interactive-diagram/evals/files/9/ticket-8812.csv +6 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/checkout-map.html +203 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/checkout-map.json +48 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/checkout-map.md +31 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/checkout-trace.html +203 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/checkout-trace.json +110 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/incident-timeline.html +203 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/incident-timeline.json +21 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/inputs/checkout/api/checkout.py +41 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/inputs/checkout/docker-compose.yml +20 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/inputs/checkout/worker/fulfil.py +23 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/inputs/incident/oncall-notes.md +14 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/inputs/trace/checkout-trace.jsonl +9 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/leave-approval.html +203 -0
- package/packs/solution-architect/skills/interactive-diagram/examples/leave-approval.json +28 -0
- package/packs/solution-architect/skills/interactive-diagram/manifest.json +39 -0
- package/packs/solution-architect/skills/interactive-diagram/reference.md +231 -0
- package/packs/solution-architect/skills/interactive-diagram/scripts/build_diagram.py +2605 -0
package/bin/skilldrop.js
CHANGED
|
@@ -485,14 +485,16 @@ function scanSkill(cat, s) {
|
|
|
485
485
|
try { body = fs.readFileSync(file, "utf8"); } catch (e) { continue; }
|
|
486
486
|
const rules = isScript ? SCRIPT_RULES : PROSE_RULES;
|
|
487
487
|
// Eval fixtures are benchmark input: a sample repo, a risky script for a reviewer to catch.
|
|
488
|
-
//
|
|
489
|
-
|
|
488
|
+
// Example inputs are the material a worked example was made from. The skill never runs or
|
|
489
|
+
// follows either, so they are listed, not raised.
|
|
490
|
+
const relPosix = rel.split(path.sep).join("/");
|
|
491
|
+
const fixture = relPosix.startsWith("evals/files/") || relPosix.startsWith("examples/inputs/");
|
|
490
492
|
body.split(/\r?\n/).forEach((line, i) => {
|
|
491
493
|
if (line.length > 400) return; // minified/data line — not reviewable prose or code
|
|
492
494
|
for (const r of rules) {
|
|
493
495
|
if (r.re.test(line))
|
|
494
496
|
findings.push({ sev: fixture ? "⚪" : r.sev, id: r.id, fixture,
|
|
495
|
-
why: fixture ? `in an eval fixture, which the skill never runs: ${r.why}` : r.why,
|
|
497
|
+
why: fixture ? `in ${relPosix.startsWith("examples/") ? "an example's input" : "an eval fixture"}, which the skill never runs: ${r.why}` : r.why,
|
|
496
498
|
owasp: r.owasp, file: rel, line: i + 1, text: line.trim().slice(0, 120) });
|
|
497
499
|
}
|
|
498
500
|
});
|
package/catalogue.json
CHANGED
package/model-routing.json
CHANGED
|
@@ -278,6 +278,10 @@
|
|
|
278
278
|
"tier": "standard",
|
|
279
279
|
"rationale": "Structured synthesis from a content list into groups, labels and a nav model against fixed IA practice. Grouping needs judgment, but the method and the validation plan bound it."
|
|
280
280
|
},
|
|
281
|
+
"interactive-diagram": {
|
|
282
|
+
"tier": "standard",
|
|
283
|
+
"rationale": "Tracing a path through code and citing each part is careful reading, not adversarial judgement; the layout and the checks are done by the script."
|
|
284
|
+
},
|
|
281
285
|
"job-fit-analysis": {
|
|
282
286
|
"tier": "standard",
|
|
283
287
|
"rationale": "Matches a posting's requirements to resume lines and reports the gaps. The rule is mechanical: no line in the resume, no credit."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skilldrop-cli",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.23",
|
|
4
4
|
"description": "Portable AI-agent skills, measured against the agent without them. ADRs, PRDs, runbooks, decks and reviews, installable into Claude Code, Cursor, Kiro, and any IDE that takes custom instructions. One command per skill or per role-based pack.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Sanjay Ananthanarayan",
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: interactive-diagram
|
|
3
|
+
description: Turn a codebase, a system description, a process or a database schema into one self-contained interactive HTML diagram (architecture, workflow, data flow, lifecycle, ERD, sequence, class, tree, timeline or waterfall) where every box and arrow cites the file and line or the words it came from, anything inferred is drawn dashed as an assumption, and each cited line is checked against the repository before the page is written. Laid out automatically, opens offline with no CDN, and exports SVG, PNG and Mermaid. Use when the user asks to "visualize", "map" or "make an interactive diagram of" a repo, a request path, a pipeline, an approval process, a set of tables, an incident's events or a slow trace, or wants a diagram they can click through and share as one file.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# interactive-diagram
|
|
7
|
+
|
|
8
|
+
**The rule: nothing goes on the map that the material doesn't show.** A diagram is trusted
|
|
9
|
+
more than prose, so an invented box misleads more than an invented sentence. Asked to draw a
|
|
10
|
+
repo, the agent's habit is to draw the system such repos usually have: a load balancer, an
|
|
11
|
+
auth service, the Kafka the README says is planned. Here every part and every connection
|
|
12
|
+
either cites where it came from (`src/api.py:40-52`, or the person's own words) or is drawn
|
|
13
|
+
dashed and listed as an assumption. The script checks each cited file and line before it
|
|
14
|
+
writes the page, and refuses a spec that cites a line that isn't there.
|
|
15
|
+
|
|
16
|
+
Two things follow:
|
|
17
|
+
|
|
18
|
+
- **One question per map.** Draw what answers the question asked ("what happens when an order
|
|
19
|
+
is placed"), not every module in the repo. A part that doesn't help answer it stays off,
|
|
20
|
+
and the reply says in one line what was left out.
|
|
21
|
+
- **You write the meaning; the script does the layout.** Never write coordinates. List the
|
|
22
|
+
parts and connections in the order a reader meets them, and the script places them, routes
|
|
23
|
+
every arrow around the boxes, draws groups as boxes that don't overlap, and wraps a long
|
|
24
|
+
flow onto rows so its text stays readable.
|
|
25
|
+
|
|
26
|
+
## How to respond
|
|
27
|
+
|
|
28
|
+
1. **Name the question and pick the type.** One sentence: what will the reader understand
|
|
29
|
+
after looking? Then the type:
|
|
30
|
+
|
|
31
|
+
| Type | For |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `architecture` | What a system is made of and what talks to what |
|
|
34
|
+
| `dataflow` | Where data or money or documents go, stage by stage |
|
|
35
|
+
| `workflow` | A process with steps, decisions and hand-offs, technical or everyday |
|
|
36
|
+
| `lifecycle` | The states something moves through and what moves it |
|
|
37
|
+
| `erd` | Tables, their columns and keys, and how they reference each other |
|
|
38
|
+
| `sequence` | Who calls whom, in order, for one request or exchange |
|
|
39
|
+
| `class` | Types, their members, and inherits, implements, composition and the rest |
|
|
40
|
+
| `tree` | What contains what, one parent each: a repo's folders, a capability breakdown, an org |
|
|
41
|
+
| `timeline` | When things happened, on a clock, one lane per source: an incident, a release history |
|
|
42
|
+
| `waterfall` | Where the time went in one request or run: spans to scale, nested, with the critical path |
|
|
43
|
+
|
|
44
|
+
2. **Gather the facts, with where each came from.**
|
|
45
|
+
- **A repository:** trace the one path the question is about. Read the entry point, follow
|
|
46
|
+
the calls, and for each part and each arrow note the file and lines that show it. Add a
|
|
47
|
+
few characters from those lines after `#` (`src/api.py:12#stripe.PaymentIntent`) so a
|
|
48
|
+
wrong line number is caught. Config and README files show intent, not behaviour: a
|
|
49
|
+
service the README mentions but no code calls is left off, or drawn as an assumption with
|
|
50
|
+
the README as its only evidence and said so in the reply.
|
|
51
|
+
- **A description:** cite the person's words: `"user: anything over ten days goes to HR"`.
|
|
52
|
+
- **Something you believe but can't point to** (who calls the API, what the worker does
|
|
53
|
+
next): `"assumed": true`. It is drawn dashed and listed. Leave it off if it doesn't help
|
|
54
|
+
answer the question.
|
|
55
|
+
- **Times, for a timeline:** write each time as its source gives it, with its offset when
|
|
56
|
+
sources differ (`2026-10-11T03:41:00Z`, `2026-10-10T22:41-05:00`); the script puts them
|
|
57
|
+
on one clock. A time the source is unsure of gets `"approx": true`. Link two events
|
|
58
|
+
(`caused`, `fixed`) only when the material says one led to the other; an event that came
|
|
59
|
+
after another did not necessarily follow from it.
|
|
60
|
+
- **Spans, for a waterfall:** copy each span's start and end from the trace as they are,
|
|
61
|
+
including one that ends after its parent; the script flags it.
|
|
62
|
+
- **The person's guesses or questions** ("is it the north fetch?", "was it the vacuum?"):
|
|
63
|
+
answer each in `answers`, with evidence, or as an assumption when the material is silent.
|
|
64
|
+
They appear as a table at the top of the page.
|
|
65
|
+
|
|
66
|
+
3. **Write the spec** as JSON next to where the page will go. The full shape, every kind and
|
|
67
|
+
the ERD and sequence fields are in [`reference.md`](reference.md). The essentials:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{"type": "architecture", "title": "What a checkout request touches",
|
|
71
|
+
"question": "What happens when a shopper checks out?",
|
|
72
|
+
"summary": "One or two sentences: the takeaway a reader should leave with.",
|
|
73
|
+
"groups": [{"id": "vpc", "label": "Private VPC"}],
|
|
74
|
+
"nodes": [{"id": "api", "label": "Checkout API", "kind": "service", "group": "vpc",
|
|
75
|
+
"note": "FastAPI", "evidence": ["src/api.py:8-14#def checkout"]}],
|
|
76
|
+
"edges": [{"from": "api", "to": "db", "label": "insert order", "evidence": ["src/api.py:13"]}],
|
|
77
|
+
"story": [{"text": "The API checks the cache first.", "edges": ["e2"]}]}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Labels are a few words; detail goes in `note` (shown on the box) or `detail` (shown when
|
|
81
|
+
clicked). For a timeline, set `timezone` to the zone the reader works in. Write `summary`
|
|
82
|
+
last, from what the script computed: a summary that says "over four hours" beside a
|
|
83
|
+
computed 3h 37m is the kind of slip the page exists to prevent. Add a `story` of three to seven steps when the map has a main path worth walking.
|
|
84
|
+
|
|
85
|
+
4. **Build it.** With a repository, always pass `--repo-root` so the citations are checked.
|
|
86
|
+
For a waterfall or a timeline the script also prints what it computed (each span's own
|
|
87
|
+
time, which spans overlap, the longest quiet stretch, time zones): use those numbers in the
|
|
88
|
+
reply as they are, and never add up durations yourself.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Claude Code
|
|
92
|
+
python3 "${CLAUDE_SKILL_DIR}/scripts/build_diagram.py" diagram.json -o diagram.html --repo-root .
|
|
93
|
+
# Other IDEs (from the skill folder)
|
|
94
|
+
python3 scripts/build_diagram.py diagram.json -o diagram.html --repo-root .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Errors list the item, what is wrong and the fix, and nothing is written until they're gone.
|
|
98
|
+
Fix the spec, never the evidence: a citation the check can't find is wrong, so find the
|
|
99
|
+
right lines or mark the item assumed. Add `--mermaid diagram.mmd` for a version to paste
|
|
100
|
+
into a README, and `--compare old.json` to show what a change adds, removes and alters.
|
|
101
|
+
|
|
102
|
+
5. **Reply with the map first.** The script prints the line to open with: a link to the page,
|
|
103
|
+
titled. Use it as the first line, then the takeaway in one or two sentences, then one line
|
|
104
|
+
each for what is drawn as an assumption and what was left out, and last how many citations
|
|
105
|
+
were checked:
|
|
106
|
+
|
|
107
|
+
> **What a checkout request touches** (the script's link line: the title, linked to the page)
|
|
108
|
+
>
|
|
109
|
+
> The API charges Stripe before it records the order, and a worker books the courier later.
|
|
110
|
+
> Assumed: the shopper's browser (no client in this repo). Left out: the products table's
|
|
111
|
+
> other readers. 22 of 22 citations checked.
|
|
112
|
+
|
|
113
|
+
Keep the spec beside the page so the map can be rebuilt after the code changes. No recap of
|
|
114
|
+
commands or layout, and nothing before the link.
|
|
115
|
+
|
|
116
|
+
6. **When the script can't run** (no `python3`), give the Mermaid version in the reply, with
|
|
117
|
+
assumptions marked, and say that the interactive page needs Python 3.
|
|
118
|
+
|
|
119
|
+
This is a non-interactive skill: don't stop to ask. With too little to draw from, draw what
|
|
120
|
+
you have, mark the rest as assumptions, and say in the reply what would settle them.
|
|
121
|
+
|
|
122
|
+
**Sharing:** the page shows the cited lines when a part is clicked. Files that hold secrets
|
|
123
|
+
(`.env`, keys, credential files) are never shown and secret-looking lines are masked, but
|
|
124
|
+
don't cite them in the first place, and read the page before it leaves the team.
|
|
125
|
+
|
|
126
|
+
## Quality bar
|
|
127
|
+
|
|
128
|
+
- **Every part and connection cites its source or is drawn as an assumption.** No exceptions
|
|
129
|
+
for the "obvious" ones.
|
|
130
|
+
- **Every file citation was checked** against the repository, with the count in the reply.
|
|
131
|
+
- **Nothing on the map comes only from a README, a plan or what such systems usually have.**
|
|
132
|
+
- **The map answers one stated question,** and what was left out is said.
|
|
133
|
+
- **One HTML file that works offline:** no CDN, no external fonts, no network requests.
|
|
134
|
+
- **The reply opens with the link and the takeaway,** not with how it was made.
|
|
135
|
+
|
|
136
|
+
## When to use this skill
|
|
137
|
+
|
|
138
|
+
- ✅ "Map what happens when an order is placed in this repo, as something I can click through"
|
|
139
|
+
- ✅ "Turn this description of our approval process into an interactive flowchart for the team"
|
|
140
|
+
- ✅ "Give me an interactive ERD of schema.sql"
|
|
141
|
+
- ✅ "Show what this branch changes in the architecture" (two specs and `--compare`)
|
|
142
|
+
|
|
143
|
+
## When NOT to use this skill
|
|
144
|
+
|
|
145
|
+
- ❌ A Mermaid, PlantUML or C4 diagram to paste into a doc — use `architecture-diagrams`
|
|
146
|
+
- ❌ An as-is architecture write-up in C4 levels from infrastructure files — use `reverse-architecture`
|
|
147
|
+
- ❌ Fixing or rendering an existing Mermaid diagram — use `mermaid-render`
|
|
148
|
+
- ❌ Charts of numbers, dashboards or metrics — this draws structure, not data
|
|
149
|
+
|
|
150
|
+
## Anti-patterns to avoid
|
|
151
|
+
|
|
152
|
+
- ❌ **The usual architecture.** A load balancer, CDN or auth service drawn because systems
|
|
153
|
+
like this have one.
|
|
154
|
+
- ❌ **README as evidence of behaviour.** "We use Kafka" in a README is a plan until code
|
|
155
|
+
calls it.
|
|
156
|
+
- ❌ **Deleting evidence to pass the check.** A failed citation means the line is wrong or
|
|
157
|
+
the part is an assumption.
|
|
158
|
+
- ❌ **Everything in the repo.** Forty boxes answer no question.
|
|
159
|
+
- ❌ **Hand-placed coordinates** or a hand-written SVG instead of the script.
|
|
160
|
+
- ❌ **A page that loads a library from a CDN.** It breaks offline and leaks the viewer's IP.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"query": "Make an interactive diagram of what happens when someone places an order in this repo", "should_trigger": true},
|
|
3
|
+
{"query": "Visualize our request flow as an HTML page I can click around and send to the team", "should_trigger": true},
|
|
4
|
+
{"query": "Turn this description of our purchase approval process into an interactive flowchart", "should_trigger": true},
|
|
5
|
+
{"query": "Give me an explorable ERD of schema.sql as a single HTML file", "should_trigger": true},
|
|
6
|
+
{"query": "Map how this service talks to the database and the queue, with links back to the code", "should_trigger": true},
|
|
7
|
+
{"query": "Show what this branch changes in the architecture compared with main, as an interactive diagram", "should_trigger": true},
|
|
8
|
+
{"query": "Write a Mermaid C4 container diagram for the design doc from this description", "should_trigger": false},
|
|
9
|
+
{"query": "My mermaid flowchart says parse error on line 3, can you fix it and export a PNG", "should_trigger": false},
|
|
10
|
+
{"query": "Reverse-engineer the as-is architecture from our Terraform and write it up in C4 levels", "should_trigger": false},
|
|
11
|
+
{"query": "Build a dashboard chart of weekly signups from this CSV", "should_trigger": false}
|
|
12
|
+
]
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "interactive-diagram",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "This is the Larder repo. I'm onboarding two new developers next week. Can you make an interactive diagram, one HTML file I can send them, of what happens when a customer places an order?",
|
|
7
|
+
"assertions": [
|
|
8
|
+
"An HTML file is written that works on its own offline: it loads no script, stylesheet or font from a CDN or any http(s) URL",
|
|
9
|
+
"The diagram shows the order path the code shows: the web checkout posting to the API's POST /orders, the API validating and inserting into Postgres, pushing an email job onto the Redis 'emails' list, and the worker popping it and posting to the mailer service",
|
|
10
|
+
"Kafka does not appear as part of the order path; if it is mentioned at all, it is described as planned in the README and not in the code",
|
|
11
|
+
"No payment step or payment provider appears in the order path (the README says payment is taken in the shop on collection)",
|
|
12
|
+
"It does not add parts the repo does not contain, such as a load balancer, CDN, auth service, cache or separate analytics service",
|
|
13
|
+
"The parts or connections in the diagram, or the page's text, name the files they come from (for example api/app.py, worker/worker.py, web/checkout.js, docker-compose.yml)",
|
|
14
|
+
"Anything drawn that the code does not show (for example who hosts the mailer, or what happens after the email is sent) is marked as an assumption, or left off",
|
|
15
|
+
"The reply opens with where the file is and what the diagram shows, in a few sentences, without a long account of how it was built"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 2,
|
|
20
|
+
"prompt": "Can you turn this into an interactive flowchart I can share with the team as a single file? Here's how expense claims work at our office: you fill in a claim in the finance portal and attach the receipts. Your line manager approves it. If it's over £500 it also needs the finance director. Finance then checks the receipts match and pays it in the next payroll run. Claims older than 90 days are rejected automatically when you submit them.",
|
|
21
|
+
"assertions": [
|
|
22
|
+
"An HTML file is written that works on its own offline, loading nothing from a CDN or any http(s) URL",
|
|
23
|
+
"The flow includes, in order: submit in the finance portal with receipts, the automatic rejection of claims older than 90 days, line manager approval, the over £500 decision leading to finance director approval, finance checking receipts, and payment in the next payroll run",
|
|
24
|
+
"The over £500 rule and the 90-day rule are drawn as decisions or branches, not as plain steps",
|
|
25
|
+
"What happens when the line manager or finance director declines, or when receipts don't match, is not stated in the description, so it is either left off or visibly marked as an assumption, never drawn as a definite step",
|
|
26
|
+
"It adds no steps, roles, systems or thresholds the description does not contain (for example no budget-holder step, no expense card, no second threshold)",
|
|
27
|
+
"The reply is short: where the file is, what it shows, and which paths were not covered by the description"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": 3,
|
|
32
|
+
"prompt": "I need an interactive ERD of schema.sql for the team wiki - something people can click on to see the columns. One self-contained HTML file.",
|
|
33
|
+
"assertions": [
|
|
34
|
+
"An HTML file is written that works on its own offline, loading nothing from a CDN or any http(s) URL",
|
|
35
|
+
"All five tables appear (clinics, practitioners, patients, appointments, appointment_notes) with every column the schema defines and no column it does not",
|
|
36
|
+
"The four foreign keys are drawn as relationships with the right direction: practitioners to clinics, appointments to practitioners, appointments to patients, appointment_notes to appointments",
|
|
37
|
+
"booked_by_user_id is shown as a column but no relationship is drawn for it to a users or staff table as if it existed; if it is mentioned, the reply or page says it has no table in this schema",
|
|
38
|
+
"Primary keys and foreign keys are marked on their columns, and appointment_notes.appointment_id is shown as both",
|
|
39
|
+
"appointment_notes to appointments is shown as one-to-one or at most one note per appointment, not one-to-many",
|
|
40
|
+
"It invents no tables, columns, indexes or constraints that schema.sql does not contain"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": 4,
|
|
45
|
+
"held_out": "2026-10-18",
|
|
46
|
+
"prompt": "This is castbox-media, the backend for our podcast hosting platform. I need to explain to the new on-call engineer what actually happens when a creator's episode upload finishes and the storage webhook hits us, up to the point where we stop being in control. Make me an interactive diagram of that path I can click through and send them as one file.",
|
|
47
|
+
"assertions": [
|
|
48
|
+
"Writes one self-contained HTML file that opens offline: no <script src>, <link href>, @import or font URL pointing at http(s), and the diagram's code and styles are inline",
|
|
49
|
+
"Shows the path in order: the object store's webhook to POST /webhooks/storage (src/server.js), handleStorageWebhook checking the x-storage-signature HMAC and the object.finalized event type (src/handlers/storageWebhook.js), the episodes row set to 'uploaded' in PostgreSQL, a 'transcribe-episode' job added to the Redis/BullMQ 'media' queue, the worker (src/worker.js) running transcribeEpisode (src/jobs/transcribeEpisode.js), submitTranscription POSTing to the transcription API's /v2/jobs (src/clients/transcription.js), the episode set to 'transcribing' with its transcription_job_id, and the processing email sent over SMTP via src/mailer.js",
|
|
50
|
+
"Shows at least one of the branches the code takes: bad signature returns 401, non-finalized events return 204 and are ignored, an unknown or already-taken upload_key is ignored, the email only goes out when notify_on_processing is true, or the episode is marked 'failed' after the 3 attempts are used up",
|
|
51
|
+
"Boxes and arrows cite the source file (and line where given) they came from, and every cited file is one that exists in the repo",
|
|
52
|
+
"Does not draw transcoding, the search indexing or the CDN purge as steps on this path: the README and config/default.json mention them but no code on the upload path calls them (search is only used by the nightly 'nightly-reindex' job, and transcoding and CDN purge appear in no code). If shown at all, they are marked as not called or as claims from the README",
|
|
53
|
+
"Keeps the other paths out of the main flow: the GET /feeds/:showId.xml RSS route and the 03:00 nightly-reindex job are either absent or clearly marked as separate from the upload path",
|
|
54
|
+
"Does not present what the transcription service does after accepting the job as fact: the callback to /webhooks/transcription is dashed, marked as an assumption or left out, and the reply or diagram notes that src/server.js registers no /webhooks/transcription route, so nothing in this repo receives the result or moves the episode to 'published'",
|
|
55
|
+
"The reply opens with where the HTML file is and the main takeaway (for example that the app's part ends once the job is submitted and the email sent, and the transcript callback has no handler), not with a long account of how the diagram was made"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": 5,
|
|
60
|
+
"held_out": "2026-10-18",
|
|
61
|
+
"prompt": "Can you make an interactive sequence diagram of how a repair request goes through at Fernhill Housing Co-op? I want to show it to our board next week as one file they can open. Here's how it works as far as I know:\n\nA tenant phones the contact centre or fills in the web form to report a repair. The contact centre logs it in our housing management system (HMS) and gives the tenant a reference number. Every weekday morning the repairs coordinator goes through the new jobs in HMS, decides the priority (emergency = attend within 24 hours, routine = within 20 working days) and assigns it to one of our two contractors by emailing them the job sheet. The contractor rings the tenant to book a visit, then does the work. After the visit the contractor marks the job complete in their own portal. At the end of each month the contractor sends us an invoice listing the jobs they finished, and finance closes those jobs in HMS when they pay the invoice.\n\nIf the contractor needs to order parts I'm honestly not sure what happens, I think they tell the coordinator? We used to post the tenant a confirmation letter when a job was closed but we stopped doing that in 2025. There's also the annual gas safety check programme but that's a different process, leave it out.",
|
|
62
|
+
"assertions": [
|
|
63
|
+
"Writes one self-contained HTML file that opens offline: no <script src>, <link href>, @import or font URL pointing at http(s), and the diagram's code and styles are inline",
|
|
64
|
+
"It is a sequence diagram with at least these participants: tenant, contact centre, HMS, repairs coordinator, contractor and finance (the contractor's portal may be its own participant or part of the contractor)",
|
|
65
|
+
"The messages run in this order: tenant reports by phone or web form; contact centre logs the job in HMS and gives the tenant a reference number; the coordinator reviews new jobs each weekday morning, sets the priority (emergency 24 hours, routine 20 working days) and emails the job sheet to a contractor; the contractor rings the tenant to book and does the visit; the contractor marks the job complete in its own portal; the contractor sends a monthly invoice to finance; finance closes the jobs in HMS on payment",
|
|
66
|
+
"The parts-ordering step is drawn dashed or labelled as an assumption or unconfirmed (the user said they are not sure), not as a solid confirmed message",
|
|
67
|
+
"The posted confirmation letter does not appear as a current step (absent, or shown only as stopped in 2025), and the gas safety check programme does not appear",
|
|
68
|
+
"Points out at least one hand-off gap the description reveals: nothing tells the tenant the repair is finished or closed; HMS only learns a job is done when finance pays the monthly invoice, so jobs stay open in HMS for weeks; or an emergency reported after the morning review waits until the next weekday morning before the coordinator sees it",
|
|
69
|
+
"Each message carries or cites the words from the user's description it came from, and the diagram adds no participants or systems the user did not describe (for example no SMS service, CRM, scheduling tool or tenant app)",
|
|
70
|
+
"The reply opens with where the HTML file is and the main takeaway (such as the gap found), not with a long account of how the diagram was made"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": 6,
|
|
75
|
+
"held_out": "2026-10-19",
|
|
76
|
+
"prompt": "Quote requests on our freight API have been slow since last week. I exported one of the slow traces to trace-quote-slow.jsonl and put my notes in notes.txt. Can you make me an interactive diagram showing where the time went? I want to send it to the rates team.",
|
|
77
|
+
"assertions": [
|
|
78
|
+
"The output is one self-contained .html file that works offline: it has no <script src>, <link href>, @import or font URL pointing at http(s) or a CDN, and its scripts and styles are inline",
|
|
79
|
+
"The request's total is given as 4,200 ms (4.2 s), the root span POST /v2/quotes from 09:41:07.300 to 09:41:11.500 UTC; the total is not given as 4,610 ms (the late end of emit quote.created) or as the sum of the span durations",
|
|
80
|
+
"The biggest contributor is named as the carrier_rates north-line call in rates-svc at 2,600 ms, about 62% of the 4,200 ms total",
|
|
81
|
+
"carrier_rates north-line (2,600 ms) and carrier_rates coastal (2,385 ms) are shown or described as running in parallel, with coastal entirely inside north-line's window; their sum (4,985 ms, the notes' '~5s') is not presented as time the request spent on carriers, and the carrier calls together take about 2,600 ms of wall-clock time",
|
|
82
|
+
"build_quote (4,090 ms) is distinguished as almost all waiting on its children, with under 100 ms of its own time, while price_and_rank (1,050 ms) is called out as about 1,040 ms of its own work (its only child, GET fx:EUR-USD, takes 8 ms), the second place to look after north-line",
|
|
83
|
+
"The emit quote.created span (notify-svc, PRODUCER) is flagged as ending at 4,610 ms, after its parent build_quote (4,150 ms) and the root (4,200 ms) end, so it is async or clock skew, and it is not counted in the 4.2 s the user waited",
|
|
84
|
+
"The rate limiter or Redis rate-limit check from the notes is said not to be in the trace; it is not drawn as a measured span or given a duration (if it is shown at all, it is marked as not in the trace or an assumption), and no other spans, services or timings are made up",
|
|
85
|
+
"The reply's first line is the path of, or a link to, the HTML file, followed by the takeaway (for example, north-line's carrier call is about 62% of the 4.2 s), not an account of how the diagram was built"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": 7,
|
|
90
|
+
"held_out": "2026-10-19",
|
|
91
|
+
"prompt": "Can you turn INC-0412 (the frozen arrival boards on Saturday night) into an interactive timeline I can drop into the review doc? system-log.txt is the export from the central log and oncall-notes.md is what I typed during the night. Review is Tuesday.",
|
|
92
|
+
"assertions": [
|
|
93
|
+
"The output is one self-contained .html file that works offline: it has no <script src>, <link href>, @import or font URL pointing at http(s) or a CDN, and its scripts and styles are inline",
|
|
94
|
+
"The notes' CDT times and the log's UTC times are on one clock (UTC = CDT + 5 h): the supervisor's 10:41pm call is placed at 03:41 UTC on 11 Oct, after the 00:03:40 UTC warning and before the 03:44:20 UTC page, not at 22:41 UTC on 10 Oct; the 12:05am all-clear is on 11 Oct and comes last, not before the evening events",
|
|
95
|
+
"The logged events appear at their correct times: v3.14.0 deploy at 23:58:12 UTC on 10 Oct (6:58pm CDT), the 'serving last-known positions' warning at 00:03:40 UTC, INC-0412 opened at 03:44:20 and acknowledged at 03:46:02, the feed recovering at 04:12:07, the rollback to v3.13.2 at 04:31:45 and the incident resolved at 05:05:40 UTC",
|
|
96
|
+
"Events from the system log and from the on-call notes are kept apart as two lanes or clearly labelled sources, and each event can be traced back to the file it came from",
|
|
97
|
+
"The quiet gap of about 3 h 37 min (00:03:40 UTC to the 03:41 UTC call; about 3 h 41 min to the 03:44:20 page) is shown or stated as a period with nothing logged and no alert, and it says the FeedStale alert never fired and a person found the problem; no events are invented inside the gap",
|
|
98
|
+
"The avl-ingest restart is shown as uncertain or approximate, around 11:05 to 11:15pm CDT (04:05 to 04:15 UTC), drawn dashed or labelled as not confirmed by any log, and is not given as a precise logged time",
|
|
99
|
+
"The rollback to v3.13.2 at 04:31:45 UTC is not presented as what fixed the boards, since the feed had already recovered at 04:12:07 (about 19 minutes earlier), and the v3.14.0 deploy is not stated as the confirmed cause; the boards are given as stale for about 4 h 8 min (00:03:40 to 04:12:07 UTC)",
|
|
100
|
+
"The reply's first line is the path of, or a link to, the HTML file, followed by the takeaway (for example, the boards were stale for about 4 h 8 min and no alert fired, so a person found it after about 3 h 37 min), not an account of how the timeline was built"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": 8,
|
|
105
|
+
"held_out": "2026-10-19",
|
|
106
|
+
"prompt": "Last night's nightly-sky-ingest run at the observatory took 25 minutes and the morning team wants to know where the time went. The orchestrator export is run-4471.json. My guess: it's the north site fetch again (their link has been flaky), plus the vacuum on catalog-db that kicks off around 1am. Calibrate is probably just sitting there waiting on the dark and flat loads. Can you make me an interactive diagram I can share with the team that shows where the time went?",
|
|
107
|
+
"assertions": [
|
|
108
|
+
"Writes one self-contained HTML file that opens offline: no <script src>, <link href>, @import or font URL pointing at http(s) or a CDN",
|
|
109
|
+
"Shows the run's wall-clock time as 25 minutes (1,500 s, 01:00:00 to 01:25:00 UTC) with the five top-level steps nested under it at their real durations: checkout_config 20 s, fetch_frames 600 s, calibrate 480 s, stack_and_publish 392 s, send_summary 8 s",
|
|
110
|
+
"Treats fetch_north, fetch_south and fetch_east as parallel (all start at 01:00:22): does not add their 1,084 s (or 1,092 s with verify_checksums) as time spent, and names fetch_south (588 s, finished 01:10:10) as the step that held fetch_frames to 600 s",
|
|
111
|
+
"Says the north site fetch was not the bottleneck: fetch_north took 278 s and finished at 01:05:00, about five minutes before fetch_south, contrary to the user's guess",
|
|
112
|
+
"Distinguishes calibrate, which is long because of its own work (about 420 s of its 480 s falls outside load_darks and load_flats, 30 s each), from fetch_frames, which is long only because it waits on its children (about 4 s of its own), and so contradicts the guess that calibrate is just waiting on the loads",
|
|
113
|
+
"Flags upload_thumbnails as detached or asynchronous: it finishes at 01:28:40, 228 s after its parent stack_and_publish ended (01:24:52) and 220 s after the run reported finished, and does not count those minutes in the 25-minute run time",
|
|
114
|
+
"Says the catalog-db vacuum does not appear anywhere in the export, so this data can neither confirm nor blame it; if it is drawn at all it is marked as an assumption, not as a measured step. Invents no other steps, durations, hosts or a 'usual' run time not in the file or the prompt",
|
|
115
|
+
"The reply's first line is the path of (or a link to) the HTML file, followed by the takeaway (for example that fetch_south and calibrate's own work account for most of the 25 minutes), not an account of how the diagram was built"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": 9,
|
|
120
|
+
"held_out": "2026-10-19",
|
|
121
|
+
"prompt": "We need a timeline of what happened with the lesson-sync downloads on the night of 14 October for Thursday's review. I've exported the team chat (chat-export.txt), the service log (lesson-sync.log) and the support ticket history (ticket-8812.csv). Make me an interactive diagram showing when things happened.",
|
|
122
|
+
"assertions": [
|
|
123
|
+
"Writes one self-contained HTML file that opens offline: no <script src>, <link href>, @import or font URL pointing at http(s) or a CDN",
|
|
124
|
+
"Puts all three sources on one labelled clock, converting the chat from Asia/Kolkata (UTC+05:30) and handling the date change: for example the chat's '15/10 03:55 rolling back' is shown as 14 Oct 22:25 UTC, between the deploy (21:40:12 UTC) and rollback complete (22:31:04 UTC), not as a separate set of events on 15 October after the log",
|
|
125
|
+
"Shows these events at the right times (UTC, or correctly converted): v4.12.0 deploy complete 21:40:12 on 14 Oct; first 'manifest checksum mismatch' 21:52:30; ticket 8812 opened 22:05; rollback to v4.11.3 complete 22:31:04; last checksum error 22:33:41; school confirms downloads working 22:48; max_retries 3 -> 5 config change 06:12 on 15 Oct; ticket resolved 06:40 on 15 Oct",
|
|
126
|
+
"Shows the quiet period with no events in any source, from about 22:50 UTC on 14 Oct to 06:12 UTC on 15 Oct (about 7 h 22 min), as a gap, and does not suggest the outage continued through it",
|
|
127
|
+
"Marks the CDN purge as uncertain (dashed, flagged or worded as unconfirmed) at about 22:20 UTC (03:50 IST), because dev-ravi's message hedges it and it does not appear in the log or the ticket; it is not presented as a confirmed event or as the fix",
|
|
128
|
+
"Does not credit the 06:12 max_retries change as the fix, despite the ticket's resolution note: errors stopped at 22:33:41, about 2.5 minutes after the rollback completed, the success rate was back to 99.6% at 22:40 and the school confirmed at 22:48, all more than 7 hours before the config change",
|
|
129
|
+
"Invents nothing: no root cause for why v4.12.0 broke checksums beyond what the sources say (the errors starting after the deploy and stopping after the rollback may be described as a correlation), and no events, people or times not in the three files, nor error or school counts beyond what can be counted from them (the log has 9 checksum-mismatch errors)",
|
|
130
|
+
"The reply's first line is the path of (or a link to) the HTML file, followed by the takeaway (for example that the errors began about 12 minutes after the v4.12.0 deploy and ended with the rollback, not the morning retry change), not an account of how the diagram was built"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": 10,
|
|
135
|
+
"held_out": "2026-10-19",
|
|
136
|
+
"prompt": "Last night's nightly build of our game took 46 minutes. build-4127-timing.json is the timing export from our CI. Make me an interactive diagram of where the time went that I can share with the team as one file. My guess is the new water shaders made shader compilation slow, or else we're stuck waiting for the signing machines. Someone on the team also reckons the debug-symbol upload holds up the rest of the build. Which of those is it?",
|
|
137
|
+
"assertions": [
|
|
138
|
+
"Writes one self-contained HTML file that opens offline: no CDN, and no http(s) script, stylesheet or font references",
|
|
139
|
+
"Shows all 15 steps nested under the right parents, with the right durations: build 46:00, sync_sources 2:20, compile 15:00, cook_assets 6:00, bake_lighting 10:40, package 12:00. compile_engine (15:00), compile_gameplay (8:00) and compile_editor_tools (5:30) are drawn as parallel bars starting together at 2:20, and compile is 15 minutes, set by compile_engine, not their 28:30 sum",
|
|
140
|
+
"Confirms the signing guess: package takes 12 minutes, but 9 minutes of that (540 s, 34:00 to 43:00) is spent waiting for a free agent in sign-pool. sign_binaries and make_installer take only 1:30 each, 3 minutes in all",
|
|
141
|
+
"Rejects the shader guess as not supported: compile_shaders took 3:00, running alongside cook_textures (6:00), so cook_assets' 6 minutes is set by cook_textures and a faster shader compile would not shorten the build. Mentioning the 61 water_surface permutations is fine, but they must not be blamed for the build time",
|
|
142
|
+
"Shows upload_debug_symbols (10:20 to 24:20, 14:00) running past the end of its parent compile (17:20) rather than cutting it off at the parent's end, and rejects the claim that it holds up the build: it is marked blocking=false and bake_lighting starts at 23:20 without waiting for it",
|
|
143
|
+
"Identifies bake_lighting (10:40, about 97% CPU, a leaf step with no children and no wait) as time spent on its own work, citing the lightmap cache miss on 38 of 38 levels, and does not call it waiting",
|
|
144
|
+
"Gives durations in minutes and seconds, not raw milliseconds such as 2760000. Invents nothing: no steps, causes or timings that are not in the export, and no claim about what changed since earlier builds, because the export covers one build only",
|
|
145
|
+
"The reply's first line is a link to or the path of the HTML file, followed by the takeaway: about 9 of the 46 minutes is queueing for a signing agent, and the shader and symbol-upload guesses are not supported"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"id": 11,
|
|
150
|
+
"held_out": "2026-10-19",
|
|
151
|
+
"prompt": "These are the core classes from our greenhouse controller, under src/. A new developer starts on Monday. Can you make them a class diagram they can click through, one file I can send them? It should show what implements or extends what, and which things a class owns versus just holds a reference to.",
|
|
152
|
+
"assertions": [
|
|
153
|
+
"Writes one self-contained HTML file that opens offline: no CDN, and no http(s) script, stylesheet or font references",
|
|
154
|
+
"Shows all seven types from the source and their kinds: Sensor is an interface; AbstractSensor is abstract and implements Sensor; SoilMoistureSensor and TemperatureSensor extend AbstractSensor (they do not implement Sensor directly); Zone, Greenhouse and AlertService are concrete classes",
|
|
155
|
+
"Draws Greenhouse to Zone as composition (ownership), because Greenhouse creates each Zone in addZone, holds them in a private list, and Zone's constructor is package-private. This is drawn differently from Greenhouse to AlertService, a plain reference to a shared service passed in through the constructor",
|
|
156
|
+
"Draws Zone to Sensor as an association or aggregation to the Sensor interface (sensors are created elsewhere and attached with attach()), not as composition and not as links to the concrete sensor classes",
|
|
157
|
+
"WateringSchedule, which appears only in Greenhouse's doc comment, is not drawn as a real class. Either it is left out, or it is drawn dashed and marked as not found in the source, and the reply says it does not exist in the code",
|
|
158
|
+
"Members shown are accurate: for example, AbstractSensor has the final read(), isOutOfRange(), id() and the abstract rawValue(); both concrete sensors have onSample(); SoilMoistureSensor has adcChannel. No invented classes, fields, methods or relations, such as a Reading class, setters, or a link from a sensor back to Zone",
|
|
159
|
+
"Each class and relation cites the file it came from, with a line where one applies (for example Greenhouse.java line 12 or 21 for the zones composition, AbstractSensor.java line 7 for implements Sensor)",
|
|
160
|
+
"The reply's first line is a link to or the path of the HTML file, followed by the takeaway: one interface, one abstract base and two sensors; Greenhouse owns its Zones but only references AlertService; and WateringSchedule is named in a comment but missing from the code"
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Larder
|
|
2
|
+
|
|
3
|
+
Grocery ordering for small shops. Customers order on the web, the shop gets an email.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
- `web/` - the storefront
|
|
8
|
+
- `api/` - order API (Flask)
|
|
9
|
+
- `worker/` - sends confirmation emails
|
|
10
|
+
- Order events go to Kafka so analytics can consume them (planned for Q3).
|
|
11
|
+
- Payments are taken in the shop on collection, not online.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import psycopg
|
|
5
|
+
import redis
|
|
6
|
+
from flask import Flask, jsonify, request
|
|
7
|
+
|
|
8
|
+
app = Flask(__name__)
|
|
9
|
+
db = psycopg.connect(os.environ["DATABASE_URL"])
|
|
10
|
+
queue = redis.Redis.from_url(os.environ["REDIS_URL"])
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def validate(order):
|
|
14
|
+
if not order.get("items"):
|
|
15
|
+
return "an order needs at least one item"
|
|
16
|
+
if not order.get("email"):
|
|
17
|
+
return "an order needs an email for the confirmation"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@app.post("/orders")
|
|
21
|
+
def place_order():
|
|
22
|
+
order = request.get_json()
|
|
23
|
+
problem = validate(order)
|
|
24
|
+
if problem:
|
|
25
|
+
# the first rule the order breaks, in words the storefront can show
|
|
26
|
+
return jsonify(error=problem), 400
|
|
27
|
+
with db.cursor() as cur:
|
|
28
|
+
cur.execute(
|
|
29
|
+
"insert into orders (shop_id, email, items) values (%s, %s, %s) returning id",
|
|
30
|
+
(order["shop_id"], order["email"], json.dumps(order["items"])),
|
|
31
|
+
)
|
|
32
|
+
order_id = cur.fetchone()[0]
|
|
33
|
+
db.commit()
|
|
34
|
+
queue.lpush("emails", json.dumps({"order_id": order_id, "to": order["email"]}))
|
|
35
|
+
return jsonify(id=order_id), 201
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@app.get("/orders/<int:order_id>")
|
|
39
|
+
def get_order(order_id):
|
|
40
|
+
with db.cursor() as cur:
|
|
41
|
+
cur.execute("select id, status from orders where id = %s", (order_id,))
|
|
42
|
+
row = cur.fetchone()
|
|
43
|
+
return jsonify(id=row[0], status=row[1]) if row else ("", 404)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
services:
|
|
2
|
+
web:
|
|
3
|
+
build: ./web
|
|
4
|
+
ports: ["8080:80"]
|
|
5
|
+
api:
|
|
6
|
+
build: ./api
|
|
7
|
+
environment:
|
|
8
|
+
DATABASE_URL: postgresql://larder@db/larder
|
|
9
|
+
REDIS_URL: redis://queue:6379/0
|
|
10
|
+
depends_on: [db, queue]
|
|
11
|
+
worker:
|
|
12
|
+
build: ./worker
|
|
13
|
+
environment:
|
|
14
|
+
REDIS_URL: redis://queue:6379/0
|
|
15
|
+
MAILER_URL: https://api.mailer.example/v1/send
|
|
16
|
+
depends_on: [queue]
|
|
17
|
+
db:
|
|
18
|
+
image: postgres:16
|
|
19
|
+
queue:
|
|
20
|
+
image: redis:7
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export async function placeOrder(cart, email, shopId) {
|
|
2
|
+
const res = await fetch("/api/orders", {
|
|
3
|
+
method: "POST",
|
|
4
|
+
headers: { "Content-Type": "application/json" },
|
|
5
|
+
body: JSON.stringify({ items: cart.items, email, shop_id: shopId }),
|
|
6
|
+
});
|
|
7
|
+
if (!res.ok) throw new Error((await res.json()).error);
|
|
8
|
+
return (await res.json()).id;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import redis
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
queue = redis.Redis.from_url(os.environ["REDIS_URL"])
|
|
8
|
+
MAILER_URL = os.environ["MAILER_URL"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def run():
|
|
12
|
+
while True:
|
|
13
|
+
_, raw = queue.brpop("emails")
|
|
14
|
+
job = json.loads(raw)
|
|
15
|
+
requests.post(MAILER_URL, json={
|
|
16
|
+
"to": job["to"],
|
|
17
|
+
"template": "order-confirmation",
|
|
18
|
+
"data": {"order_id": job["order_id"]},
|
|
19
|
+
}, timeout=10)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
run()
|