From 603d42ad3f21e2cec81b51afbf31c513ff1517c0 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Sun, 22 Feb 2026 17:29:32 +0100 Subject: [PATCH] add diagram via beautiful-mermaid --- README.md | 43 +++++++++++++++++ diagrams/.gitignore | 34 +++++++++++++ diagrams/CLAUDE.md | 106 +++++++++++++++++++++++++++++++++++++++++ diagrams/README.md | 15 ++++++ diagrams/bun.lock | 34 +++++++++++++ diagrams/index.ts | 13 +++++ diagrams/package.json | 15 ++++++ diagrams/tsconfig.json | 29 +++++++++++ 8 files changed, 289 insertions(+) create mode 100644 diagrams/.gitignore create mode 100644 diagrams/CLAUDE.md create mode 100644 diagrams/README.md create mode 100644 diagrams/bun.lock create mode 100644 diagrams/index.ts create mode 100644 diagrams/package.json create mode 100644 diagrams/tsconfig.json diff --git a/README.md b/README.md index 763797d..bc4dc15 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,49 @@ Weatherproof Enclosure: [weatherproof-cover-for-outdoor-sensors](https://shop.pi _Note: I would not recommend buying from pimoroni from EU as shipping tax is huge!_ +``` +┌────────────────────────────────────────────┐ +│ Node1 │ +│ │ +│ │ +│ ┌────────────────────────┐ ┌─────────┐ │ +│ │ │ │ │ │ +│ │ bme280 │ │ pms5003 │ │ +│ │ │ │ │ │ +│ └────────────┬───────────┘ └────┬────┘ │ +│ │ │ │ +│ │ │ │ +│ i2c │ │ +│ │ uart │ +│ ▼ │ │ +│ ┌────────────────────────┐ │ │ +│ │ │ │ │ +│ │ rp2040 │◄─────────┘ │ +│ │ │ │ +│ └────────────┬───────────┘ │ +│ │ │ +└──────────────┼─────────────────────────────┘ + Custom TCP + │ + ▼ + ┌────────────────────────┐ + │ │ + │ Event Proxy │ + │ │ + └────────────┬───────────┘ + │ + │ + mqtt + │ + ▼ + ┌────────────────────────┐ + │ │ + │ Home Assistant Servier │ + │ │ + └────────────────────────┘ +``` + + ## Helpful links - [pico mqtt Example](https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/mqtt/README) diff --git a/diagrams/.gitignore b/diagrams/.gitignore new file mode 100644 index 0000000..a14702c --- /dev/null +++ b/diagrams/.gitignore @@ -0,0 +1,34 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/diagrams/CLAUDE.md b/diagrams/CLAUDE.md new file mode 100644 index 0000000..1ee6890 --- /dev/null +++ b/diagrams/CLAUDE.md @@ -0,0 +1,106 @@ + +Default to using Bun instead of Node.js. + +- Use `bun ` instead of `node ` or `ts-node ` +- Use `bun test` instead of `jest` or `vitest` +- Use `bun build ` instead of `webpack` or `esbuild` +- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` +- Use `bun run + + +``` + +With the following `frontend.tsx`: + +```tsx#frontend.tsx +import React from "react"; + +// import .css files directly and it works +import './index.css'; + +import { createRoot } from "react-dom/client"; + +const root = createRoot(document.body); + +export default function Frontend() { + return

Hello, world!

; +} + +root.render(); +``` + +Then, run index.ts + +```sh +bun --hot ./index.ts +``` + +For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`. diff --git a/diagrams/README.md b/diagrams/README.md new file mode 100644 index 0000000..f74baa0 --- /dev/null +++ b/diagrams/README.md @@ -0,0 +1,15 @@ +# diagrams + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.2.21. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime. diff --git a/diagrams/bun.lock b/diagrams/bun.lock new file mode 100644 index 0000000..d48655f --- /dev/null +++ b/diagrams/bun.lock @@ -0,0 +1,34 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "diagrams", + "dependencies": { + "beautiful-mermaid": "^0.1.3", + }, + "devDependencies": { + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + }, + "packages": { + "@dagrejs/dagre": ["@dagrejs/dagre@1.1.8", "", { "dependencies": { "@dagrejs/graphlib": "2.2.4" } }, "sha512-5SEDlndt4W/LaVzPYJW+bSmSEZc9EzTf8rJ20WCKvjS5EAZAN0b+x0Yww7VMT4R3Wootkg+X9bUfUxazYw6Blw=="], + + "@dagrejs/graphlib": ["@dagrejs/graphlib@2.2.4", "", {}, "sha512-mepCf/e9+SKYy1d02/UkvSy6+6MoyXhVxP8lLDfA7BPE1X1d4dR0sZznmbM8/XVJ1GPM+Svnx7Xj6ZweByWUkw=="], + + "@types/bun": ["@types/bun@1.3.9", "", { "dependencies": { "bun-types": "1.3.9" } }, "sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw=="], + + "@types/node": ["@types/node@25.3.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A=="], + + "beautiful-mermaid": ["beautiful-mermaid@0.1.3", "", { "dependencies": { "@dagrejs/dagre": "^1.1.8" } }, "sha512-lVEHCnlVLtVRbO03T+D9kY5BZlkpvFU6F18LEu2N2VLB0eo5evG1FJWg3SvREErKY+zZ7j9f+cNsgtiOhYI2Nw=="], + + "bun-types": ["bun-types@1.3.9", "", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + + "undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="], + } +} diff --git a/diagrams/index.ts b/diagrams/index.ts new file mode 100644 index 0000000..3b22ee6 --- /dev/null +++ b/diagrams/index.ts @@ -0,0 +1,13 @@ +import { renderMermaidAscii } from "beautiful-mermaid"; + +const ascii = renderMermaidAscii(` + flowchart TD + subgraph Node1 + bme280 -->|i2c| rp2040 + pms5003 -->|uart| rp2040 + end + rp2040 -->|Custom TCP| proxy[Event Proxy] + proxy -->|mqtt| ha[Home Assistant Servier] + +`); +console.log(ascii); diff --git a/diagrams/package.json b/diagrams/package.json new file mode 100644 index 0000000..4ee2738 --- /dev/null +++ b/diagrams/package.json @@ -0,0 +1,15 @@ +{ + "name": "diagrams", + "module": "index.ts", + "type": "module", + "private": true, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + }, + "dependencies": { + "beautiful-mermaid": "^0.1.3" + } +} diff --git a/diagrams/tsconfig.json b/diagrams/tsconfig.json new file mode 100644 index 0000000..bfa0fea --- /dev/null +++ b/diagrams/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "Preserve", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}