@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
astro 133 lines 4.47 KB
Raw
1 ---
2 /**
3 * `<BoundedContext />` — a Domain model as a bounded context, and the Api as
4 * the only way in. HTTP, MCP and CLI clients all reach the model through
5 * `BankApi`, which exposes two commands and a view. The aggregate, the other
6 * view, the policy, the projection and the external system stay private.
7 */
8 import DomainNode from "../domain/DomainNode.astro";
9 import type { Kind } from "../domain/kinds.ts";
10
11 const W = 900;
12 const H = 420;
13 const NW = 176;
14 const NH = 46;
15
16 const box = { x: 300, y: 12, w: W - 300 - 12, h: H - 24 };
17
18 const clients: Array<{ label: string; type: string; y: number; icon: ReadonlyArray<string> }> = [
19 { label: "HTTP client", type: "toHttpApi", y: 112, icon: ["M3 5h18v14H3z", "M3 9h18", "M6 7h.01", "M9 7h.01"] },
20 { label: "Agent", type: "toMcp", y: 197, icon: ["M11 3l2 5.5L18.5 10.5 13 12.5 11 18l-2-5.5L3.5 10.5 9 8.5z", "M19 15l.9 2.1L22 18l-2.1.9L19 21l-.9-2.1L16 18l2.1-.9z"] },
21 { label: "Terminal", type: "toCli", y: 282, icon: ["M4 17l6-6-6-6", "M12 19h8"] },
22 ];
23 const api = { x: box.x - NW / 2, y: 197 };
24
25 const exposed: Array<{ kind: Kind; label: string; y: number }> = [
26 { kind: "command", label: "DepositMoney", y: 112 },
27 { kind: "command", label: "WithdrawMoney", y: 197 },
28 { kind: "view", label: "AccountSummary", y: 282 },
29 ];
30 const privateParts: Array<{ kind: Kind; label: string; y: number }> = [
31 { kind: "aggregate", label: "Account", y: 84 },
32 { kind: "view", label: "Statement", y: 148 },
33 { kind: "policy", label: "FraudReview", y: 212 },
34 { kind: "projection", label: "Ledger", y: 276 },
35 { kind: "external", label: "FraudCheck", y: 340 },
36 ];
37 const exposedX = 530;
38 const privateX = 730;
39
40 const curve = (x1: number, y1: number, x2: number, y2: number) => {
41 const mx = (x1 + x2) / 2;
42 return `M${x1} ${y1}C${mx} ${y1} ${mx} ${y2} ${x2} ${y2}`;
43 };
44 ---
45
46 <figure class="bc not-content">
47 <svg viewBox={`0 0 ${W} ${H}`} role="img" aria-label="Clients reach the Bank model only through BankApi, which exposes two commands and a view">
48 <rect class="bc-box" x={box.x} y={box.y} width={box.w} height={box.h} rx="18" />
49 <text class="bc-title" x={box.x + 18} y={box.y + box.h - 16}>Bank · bounded context</text>
50 <text class="bc-col" x={exposedX} y={box.y + 32}>exposed</text>
51 <text class="bc-col" x={privateX + NW / 2 - 8} y={box.y + 32}>private</text>
52
53 {clients.map((c) => <path class="bc-edge" d={curve(16 + NW, c.y, api.x, api.y)} />)}
54 {exposed.map((e) => <path class="bc-edge" d={curve(api.x + NW, api.y, exposedX - NW / 2, e.y)} />)}
55
56 {
57 clients.map((c) => (
58 <g transform={`translate(16 ${c.y - NH / 2})`}>
59 <DomainNode kind="client" width={NW} height={NH} label={c.label} type={c.type} icon={c.icon} />
60 </g>
61 ))
62 }
63 <g transform={`translate(${api.x} ${api.y - NH / 2})`}>
64 <DomainNode kind="api" width={NW} height={NH} label="BankApi" type="the only way in" />
65 </g>
66 {
67 exposed.map((e) => (
68 <g transform={`translate(${exposedX - NW / 2} ${e.y - NH / 2})`}>
69 <DomainNode kind={e.kind} width={NW} height={NH} label={e.label} />
70 </g>
71 ))
72 }
73 {
74 privateParts.map((p) => (
75 <g class="bc-private" transform={`translate(${privateX - 8} ${p.y - NH / 2 + 6})`}>
76 <DomainNode kind={p.kind} width={NW - 16} height={NH - 12} label={p.label} />
77 </g>
78 ))
79 }
80 </svg>
81 <figcaption class="bc-cap">
82 Clients reach only what the Api lists. The aggregate, the policy, the projection and the external system stay inside,
83 free to change.
84 </figcaption>
85 </figure>
86
87 <style is:global>
88 .bc {
89 margin: 2rem 0;
90 padding: 12px 14px 10px;
91 background: var(--alc-bg-elev-1);
92 border: 1px solid var(--alc-hairline-2);
93 border-radius: 12px;
94 }
95 .bc svg {
96 display: block;
97 width: 100%;
98 height: auto;
99 }
100 .bc-box {
101 fill: color-mix(in srgb, var(--alc-accent) 5%, transparent);
102 stroke: var(--alc-accent);
103 stroke-width: 1.4;
104 stroke-dasharray: 6 5;
105 }
106 .bc-title {
107 font: 700 13px var(--alc-font-mono);
108 fill: var(--alc-fg-1);
109 text-anchor: start;
110 }
111 .bc-col {
112 font: 600 11px var(--alc-font-mono);
113 fill: var(--alc-fg-3);
114 text-anchor: middle;
115 letter-spacing: 0.06em;
116 text-transform: uppercase;
117 }
118 .bc-edge {
119 fill: none;
120 stroke: var(--alc-accent);
121 stroke-width: 1.4;
122 stroke-opacity: 0.7;
123 }
124 .bc-private {
125 opacity: 0.5;
126 }
127 .bc-cap {
128 margin-top: 6px;
129 font: 13px/1.5 var(--alc-font-sans);
130 color: var(--alc-fg-3);
131 text-align: center;
132 }
133 </style>