Add /architecture: diagrams of how the site fits together
Eight hand-drawn SVG diagrams across five sections (infrastructure, nginx, Go backend, Vue frontend, Python), sharing one diagram kit (diagram.css, DiagramFigure, DiagramDefs) built on the site's tokens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -60,6 +60,12 @@ const router = createRouter({
|
||||
name: "cheap-hotels",
|
||||
component: () => import("@/views/hotels/CheapHotels.vue"),
|
||||
},
|
||||
{
|
||||
path: "architecture",
|
||||
name: "architecture",
|
||||
component: () =>
|
||||
import("@/views/architecture/Architecture.vue"),
|
||||
},
|
||||
// /shrines and the shrines under it are canvas pages, made
|
||||
// from the admin panel's Pages tab and served by the catch-all
|
||||
// below. The old hand-written ones (views/home/shrines/) are
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/architecture` — how the whole site fits together, drawn.
|
||||
*
|
||||
* One long page of hand-written SVG diagrams, grouped into five sections
|
||||
* (sections/*Section.vue), each of which lists its diagrams
|
||||
* (diagrams/<section>/*.vue). Every diagram sits in a <DiagramFigure> and draws
|
||||
* with the `dg-` classes in diagram.css; DiagramDefs supplies the shared
|
||||
* arrowheads. No chart or graph library: the diagrams are static pictures of
|
||||
* the code, so plain SVG is the smallest thing that does the job.
|
||||
*
|
||||
* The diagrams describe the code as it was when they were drawn. When a
|
||||
* behaviour they show changes, redraw the diagram in the same commit.
|
||||
*/
|
||||
import "./diagram.css";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import DiagramDefs from "./DiagramDefs.vue";
|
||||
import InfraSection from "./sections/InfraSection.vue";
|
||||
import EdgeSection from "./sections/EdgeSection.vue";
|
||||
import BackendSection from "./sections/BackendSection.vue";
|
||||
import FrontendSection from "./sections/FrontendSection.vue";
|
||||
import ServicesSection from "./sections/ServicesSection.vue";
|
||||
|
||||
const SECTIONS = [
|
||||
{ id: "infra", label: "Infrastructure & deployment" },
|
||||
{ id: "edge", label: "The edge: nginx" },
|
||||
{ id: "backend", label: "Go backend" },
|
||||
{ id: "frontend", label: "Vue frontend" },
|
||||
{ id: "services", label: "Python & the other services" },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="architecture flex justify-center px-4 py-10">
|
||||
<DiagramDefs />
|
||||
<div class="max-w-6xl w-full flex flex-col gap-10">
|
||||
<section>
|
||||
<Header>How this site works</Header>
|
||||
<Paragraph>
|
||||
Everything behind this website, drawn. It is a couple of
|
||||
dozen Docker containers on one Ubuntu VM: nginx in front, a
|
||||
Go GraphQL backend, a Vue single-page app, a Python API that
|
||||
holds the Claude call and the scrapers, and a ring of
|
||||
self-hosted services (Gitea, SilverBullet notes, Garage
|
||||
object storage, Icecast radio, a job tracker) around them.
|
||||
Each diagram can be expanded to full screen.
|
||||
</Paragraph>
|
||||
<nav class="toc">
|
||||
<a v-for="s in SECTIONS" :key="s.id" :href="`#${s.id}`">
|
||||
{{ s.label }}
|
||||
</a>
|
||||
</nav>
|
||||
</section>
|
||||
|
||||
<InfraSection />
|
||||
<EdgeSection />
|
||||
<BackendSection />
|
||||
<FrontendSection />
|
||||
<ServicesSection />
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.toc {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 0.25rem;
|
||||
}
|
||||
.toc a {
|
||||
padding: 0.2rem 0.75rem;
|
||||
border: 1px solid var(--color-quaternary);
|
||||
text-decoration: none;
|
||||
}
|
||||
.toc a:hover {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
.architecture :deep(section) {
|
||||
scroll-margin-top: 4rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<!--
|
||||
The arrowhead markers every diagram on /architecture uses, declared once.
|
||||
diagram.css points the .dg-edge classes at these ids, so a diagram never
|
||||
declares its own <defs> (fifty inline SVGs repeating the same ids would
|
||||
collide).
|
||||
|
||||
Hidden by size rather than display:none — Firefox won't render markers
|
||||
that live in a display:none SVG.
|
||||
-->
|
||||
<template>
|
||||
<svg class="defs" aria-hidden="true" focusable="false">
|
||||
<defs>
|
||||
<marker
|
||||
v-for="m in markers"
|
||||
:id="m.id"
|
||||
:key="m.id"
|
||||
viewBox="0 0 10 10"
|
||||
refX="9"
|
||||
refY="5"
|
||||
markerWidth="7"
|
||||
markerHeight="7"
|
||||
:orient="m.start ? 'auto-start-reverse' : 'auto'"
|
||||
>
|
||||
<path d="M0,0 L10,5 L0,10 z" :style="{ fill: m.colour }" />
|
||||
</marker>
|
||||
</defs>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const colours = {
|
||||
"": "var(--color-primary)",
|
||||
"-pink": "var(--color-tertiary)",
|
||||
"-green": "var(--color-secondary)",
|
||||
"-muted": "var(--color-muted)",
|
||||
};
|
||||
|
||||
const markers = Object.entries(colours).flatMap(([suffix, colour]) => [
|
||||
{ id: `dg-arrow${suffix}`, colour, start: false },
|
||||
{ id: `dg-arrow-start${suffix}`, colour, start: true },
|
||||
]);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.defs {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,132 @@
|
||||
<!--
|
||||
Frame for one diagram on /architecture: numbered title, the SVG (default
|
||||
slot), and a caption (#caption slot).
|
||||
|
||||
The SVG scales to the column; below `minWidth` it stops shrinking and the
|
||||
frame scrolls sideways instead, so small text stays readable on a phone.
|
||||
Clicking "expand" lifts the figure into a full-screen overlay for the big
|
||||
ones. Escape or the button closes it.
|
||||
-->
|
||||
<template>
|
||||
<figure :id="id" class="figure" :class="{ expanded }">
|
||||
<figcaption class="head">
|
||||
<span class="title">
|
||||
<a v-if="id" :href="`#${id}`" class="anchor">#</a>
|
||||
{{ title }}
|
||||
</span>
|
||||
<button type="button" class="expand" @click="expanded = !expanded">
|
||||
{{ expanded ? "close ✕" : "expand ⤢" }}
|
||||
</button>
|
||||
</figcaption>
|
||||
<div class="canvas">
|
||||
<div class="inner" :style="{ minWidth: `${minWidth}px` }">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="$slots.caption" class="caption">
|
||||
<slot name="caption" />
|
||||
</div>
|
||||
</figure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onBeforeUnmount } from "vue";
|
||||
|
||||
defineProps({
|
||||
title: { type: String, required: true },
|
||||
// Anchor id, so a figure can be linked to directly.
|
||||
id: { type: String, default: "" },
|
||||
minWidth: { type: Number, default: 640 },
|
||||
});
|
||||
|
||||
const expanded = ref(false);
|
||||
|
||||
function onKey(e) {
|
||||
if (e.key === "Escape") expanded.value = false;
|
||||
}
|
||||
watch(expanded, (open) => {
|
||||
if (open) window.addEventListener("keydown", onKey);
|
||||
else window.removeEventListener("keydown", onKey);
|
||||
});
|
||||
onBeforeUnmount(() => window.removeEventListener("keydown", onKey));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.figure {
|
||||
margin: 0;
|
||||
border: 1px solid var(--color-quaternary);
|
||||
background: var(--color-surface-deep);
|
||||
scroll-margin-top: 4rem;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border-bottom: 1px solid var(--color-quaternary);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
.title {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 1.15rem;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
.anchor {
|
||||
background: none;
|
||||
color: var(--color-tertiary);
|
||||
text-decoration: none;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
.expand {
|
||||
font-family: var(--font-heading);
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--color-tertiary);
|
||||
background: var(--color-link-bg);
|
||||
border: 1px solid var(--color-quaternary);
|
||||
padding: 0.1rem 0.5rem;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.expand:hover {
|
||||
border-color: var(--color-tertiary);
|
||||
}
|
||||
.canvas {
|
||||
overflow-x: auto;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
.caption {
|
||||
padding: 0.5rem 0.75rem 0.75rem;
|
||||
border-top: 1px dotted var(--color-quaternary);
|
||||
color: var(--color-secondary);
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.caption :deep(code) {
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.expanded {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.expanded .canvas {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
}
|
||||
.expanded .inner {
|
||||
width: min(100%, 1600px);
|
||||
}
|
||||
.expanded .caption {
|
||||
max-height: 25vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* The diagram kit: every SVG on /architecture draws with these classes, so
|
||||
* fifty-odd diagrams written separately still read as one set. Colours come
|
||||
* from the site's design tokens (assets/styles.css), never literals.
|
||||
*
|
||||
* Not scoped: the classes are applied to elements inside each diagram
|
||||
* component's own template, and a scoped block would only reach its own file.
|
||||
* Everything is prefixed `dg-` so nothing leaks into the rest of the site.
|
||||
*
|
||||
* Arrowheads are <marker>s defined once on the page by DiagramDefs.vue and
|
||||
* referenced by the edge classes below, so diagrams never declare their own
|
||||
* (duplicate ids across many inline SVGs would collide).
|
||||
*/
|
||||
|
||||
.dg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
font-family: var(--font-body);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ---- Boxes -------------------------------------------------------- */
|
||||
|
||||
.dg-box {
|
||||
fill: var(--color-surface);
|
||||
stroke: var(--color-primary);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
.dg-box--pink {
|
||||
stroke: var(--color-tertiary);
|
||||
}
|
||||
.dg-box--green {
|
||||
stroke: var(--color-secondary);
|
||||
}
|
||||
.dg-box--teal {
|
||||
stroke: var(--color-quaternary);
|
||||
stroke-width: 2;
|
||||
}
|
||||
.dg-box--muted {
|
||||
stroke: var(--color-muted);
|
||||
stroke-dasharray: 4 3;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.dg-box--tint {
|
||||
fill: var(--color-surface-tint);
|
||||
}
|
||||
.dg-box--deep {
|
||||
fill: var(--color-surface-deep);
|
||||
}
|
||||
/* Solid accent fill: a highlighted node. Pair with .dg-text--ink. */
|
||||
.dg-box--solid {
|
||||
fill: var(--color-primary);
|
||||
}
|
||||
.dg-box--solid-pink {
|
||||
fill: var(--color-tertiary);
|
||||
stroke: var(--color-tertiary);
|
||||
}
|
||||
|
||||
/* A dashed container drawn around a set of boxes (a network, a container, a
|
||||
layer). Put it before its children so it sits underneath. */
|
||||
.dg-group {
|
||||
fill: none;
|
||||
stroke: var(--color-quaternary);
|
||||
stroke-width: 1.5;
|
||||
stroke-dasharray: 6 4;
|
||||
}
|
||||
.dg-group--pink {
|
||||
stroke: var(--color-tertiary);
|
||||
opacity: 0.7;
|
||||
}
|
||||
.dg-group--fill {
|
||||
fill: var(--color-surface-tint);
|
||||
fill-opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ---- Text --------------------------------------------------------- */
|
||||
|
||||
/* Box / node titles: the condensed heading face, uppercase by nature. */
|
||||
.dg-title {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 16px;
|
||||
letter-spacing: 0.04em;
|
||||
fill: var(--color-primary);
|
||||
}
|
||||
.dg-title--pink {
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-title--lg {
|
||||
font-size: 20px;
|
||||
}
|
||||
.dg-title--sm {
|
||||
font-size: 13px;
|
||||
}
|
||||
.dg-text {
|
||||
fill: var(--color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.dg-text--muted {
|
||||
fill: var(--color-muted);
|
||||
}
|
||||
.dg-text--pink {
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-text--mint {
|
||||
fill: var(--color-primary);
|
||||
}
|
||||
/* Dark text for use on .dg-box--solid / --solid-pink */
|
||||
.dg-text--ink {
|
||||
fill: var(--color-surface-deep);
|
||||
}
|
||||
.dg-small {
|
||||
fill: var(--color-muted);
|
||||
font-size: 10.5px;
|
||||
}
|
||||
.dg-code {
|
||||
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
||||
font-size: 11px;
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-group-label {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.06em;
|
||||
fill: var(--color-quaternary);
|
||||
filter: brightness(2.2);
|
||||
}
|
||||
/* Label sitting on a line: a halo in the page colour keeps it legible where
|
||||
it crosses an edge. */
|
||||
.dg-edge-label {
|
||||
font-size: 10.5px;
|
||||
fill: var(--color-muted);
|
||||
paint-order: stroke;
|
||||
stroke: var(--color-surface-deep);
|
||||
stroke-width: 4px;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.dg-edge-label--pink {
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-edge-label--mint {
|
||||
fill: var(--color-primary);
|
||||
}
|
||||
|
||||
/* ---- Edges -------------------------------------------------------- */
|
||||
|
||||
.dg-edge {
|
||||
fill: none;
|
||||
stroke: var(--color-primary);
|
||||
stroke-width: 1.5;
|
||||
marker-end: url(#dg-arrow);
|
||||
}
|
||||
.dg-edge--pink {
|
||||
stroke: var(--color-tertiary);
|
||||
marker-end: url(#dg-arrow-pink);
|
||||
}
|
||||
.dg-edge--green {
|
||||
stroke: var(--color-secondary);
|
||||
marker-end: url(#dg-arrow-green);
|
||||
}
|
||||
.dg-edge--muted {
|
||||
stroke: var(--color-muted);
|
||||
marker-end: url(#dg-arrow-muted);
|
||||
}
|
||||
.dg-edge--dashed {
|
||||
stroke-dasharray: 5 4;
|
||||
}
|
||||
/* Two-way: add an arrowhead at the start too. Combine with a colour class
|
||||
and the matching --both-* class, e.g. "dg-edge dg-edge--pink dg-edge--both-pink". */
|
||||
.dg-edge--both {
|
||||
marker-start: url(#dg-arrow-start);
|
||||
}
|
||||
.dg-edge--both-pink {
|
||||
marker-start: url(#dg-arrow-start-pink);
|
||||
}
|
||||
.dg-edge--both-green {
|
||||
marker-start: url(#dg-arrow-start-green);
|
||||
}
|
||||
.dg-edge--both-muted {
|
||||
marker-start: url(#dg-arrow-start-muted);
|
||||
}
|
||||
/* A line with no arrowhead: connectors, ER relationships, axes. */
|
||||
.dg-edge--plain {
|
||||
marker-end: none;
|
||||
}
|
||||
/* Marching ants for a live flow. Combine with any colour; motion stops for
|
||||
people who asked for less. */
|
||||
.dg-edge--flow {
|
||||
stroke-dasharray: 6 5;
|
||||
animation: dg-march 1.2s linear infinite;
|
||||
}
|
||||
@keyframes dg-march {
|
||||
to {
|
||||
stroke-dashoffset: -22;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.dg-edge--flow {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- Sequence diagrams ------------------------------------------- */
|
||||
|
||||
.dg-lifeline {
|
||||
stroke: var(--color-quaternary);
|
||||
stroke-width: 1.5;
|
||||
stroke-dasharray: 3 4;
|
||||
filter: brightness(1.8);
|
||||
}
|
||||
.dg-activation {
|
||||
fill: var(--color-quaternary);
|
||||
stroke: var(--color-primary);
|
||||
stroke-width: 1;
|
||||
}
|
||||
|
||||
/* ---- Small marks -------------------------------------------------- */
|
||||
|
||||
.dg-dot {
|
||||
fill: var(--color-primary);
|
||||
}
|
||||
.dg-dot--pink {
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-dot--green {
|
||||
fill: var(--color-secondary);
|
||||
}
|
||||
.dg-dot--muted {
|
||||
fill: var(--color-muted);
|
||||
}
|
||||
/* Numbered step badge: a circle with .dg-badge-text centred on it. */
|
||||
.dg-badge {
|
||||
fill: var(--color-tertiary);
|
||||
}
|
||||
.dg-badge-text {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 13px;
|
||||
fill: var(--color-surface-deep);
|
||||
text-anchor: middle;
|
||||
dominant-baseline: central;
|
||||
}
|
||||
/* Divider / separator lines inside a box (table rows in an ER box, etc.) */
|
||||
.dg-rule {
|
||||
stroke: var(--color-quaternary);
|
||||
stroke-width: 1;
|
||||
filter: brightness(1.8);
|
||||
}
|
||||
/* Shaded band, e.g. a highlighted lane or a time window */
|
||||
.dg-band {
|
||||
fill: var(--color-quaternary);
|
||||
opacity: 0.25;
|
||||
}
|
||||
.dg-band--pink {
|
||||
fill: var(--color-tertiary);
|
||||
opacity: 0.12;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<!--
|
||||
Request lifecycle through the Go backend: nginx strips /api, Gin matches the
|
||||
route, every chain starts with the traffic logger and Recovery, then the
|
||||
route group's middleware (open / protected / admin) or, for /graphql,
|
||||
AuthContextMiddleware -> gqlgen -> directive -> resolver. Everything ends at
|
||||
handlers.Store.
|
||||
Reflects: backend/main.go (r.Use, route groups, gqlSrv setup),
|
||||
handlers/handle_auth.go (AuthMiddlewear, AdminMiddleware),
|
||||
graph/middleware.go, graph/directives.go, nginx/nginx_routes.conf.template.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="backend-request-lifecycle" title="Request lifecycle: from nginx to a handler" :min-width="770">
|
||||
<svg class="dg" viewBox="0 0 1100 660" role="img" aria-labelledby="backend-request-lifecycle-t">
|
||||
<title id="backend-request-lifecycle-t">
|
||||
A request passes nginx, the Gin router, the logger and Recovery, then one of four
|
||||
middleware chains: open routes, the protected group, the admin group, or GraphQL.
|
||||
</title>
|
||||
|
||||
<!-- Top row: into the engine -->
|
||||
<rect class="dg-box dg-box--pink" x="20" y="50" width="100" height="75" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="70" y="82" text-anchor="middle">BROWSER</text>
|
||||
<text class="dg-small" x="70" y="102" text-anchor="middle">+ cookies</text>
|
||||
|
||||
<rect class="dg-box" x="150" y="50" width="200" height="75" rx="4" />
|
||||
<text class="dg-title" x="250" y="74" text-anchor="middle">NGINX</text>
|
||||
<text class="dg-code" x="250" y="94" text-anchor="middle">/api/graphql → /graphql</text>
|
||||
<text class="dg-small" x="250" y="112" text-anchor="middle">TLS · limit_req · strips /api</text>
|
||||
|
||||
<rect class="dg-group dg-group--fill" x="370" y="20" width="720" height="120" rx="6" />
|
||||
<text class="dg-group-label" x="384" y="38">GIN ENGINE · EVERY CHAIN STARTS LOGGER → RECOVERY</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="385" y="50" width="270" height="75" rx="4" />
|
||||
<text class="dg-title" x="520" y="74" text-anchor="middle">ROUTER</text>
|
||||
<text class="dg-code" x="520" y="94" text-anchor="middle">SetTrustedProxies(172.28.0.0/16)</text>
|
||||
<text class="dg-small" x="520" y="112" text-anchor="middle">match route → pick its handler chain</text>
|
||||
|
||||
<rect class="dg-box" x="685" y="50" width="190" height="75" rx="4" />
|
||||
<text class="dg-title" x="780" y="74" text-anchor="middle">LOGGER</text>
|
||||
<text class="dg-code" x="780" y="94" text-anchor="middle">TrafficLogFormatter</text>
|
||||
<text class="dg-small" x="780" y="112" text-anchor="middle">stdout + /backend/logs/go.log</text>
|
||||
|
||||
<rect class="dg-box" x="905" y="50" width="170" height="75" rx="4" />
|
||||
<text class="dg-title" x="990" y="74" text-anchor="middle">RECOVERY</text>
|
||||
<text class="dg-code" x="990" y="94" text-anchor="middle">gin.Recovery()</text>
|
||||
<text class="dg-small" x="990" y="112" text-anchor="middle">panic → 500</text>
|
||||
|
||||
<path class="dg-edge dg-edge--pink" d="M120,88 H146" />
|
||||
<path class="dg-edge" d="M350,88 H381" />
|
||||
<path class="dg-edge" d="M655,88 H681" />
|
||||
<path class="dg-edge" d="M875,88 H901" />
|
||||
|
||||
<!-- Trunk down to the four chains -->
|
||||
<path class="dg-edge dg-edge--plain" d="M990,125 V158 H60 V600" />
|
||||
<path class="dg-edge" d="M60,240 H96" />
|
||||
<path class="dg-edge" d="M60,360 H96" />
|
||||
<path class="dg-edge" d="M60,480 H96" />
|
||||
<path class="dg-edge dg-edge--flow" d="M60,600 H96" />
|
||||
|
||||
<!-- Lane 1: open -->
|
||||
<text class="dg-group-label" x="100" y="186">OPEN ROUTES · r.GET / r.POST</text>
|
||||
<rect class="dg-box dg-box--muted" x="100" y="210" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="195" y="236" text-anchor="middle">NO MIDDLEWARE</text>
|
||||
<text class="dg-small" x="195" y="254" text-anchor="middle">handler checks cookies itself</text>
|
||||
<path class="dg-edge" d="M290,240 H316" />
|
||||
<rect class="dg-box" x="320" y="195" width="610" height="90" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="340" y="216">HANDLER</text>
|
||||
<text class="dg-code" x="340" y="237">GET /rowing · POST /auth/login · POST /auth/refresh · POST /auth/logout</text>
|
||||
<text class="dg-code" x="340" y="256">GET /auth/check · GET /auth/validate-admin · GET /spotify/callback</text>
|
||||
<text class="dg-code" x="340" y="275">GET /spotify/listening · GET /spotify/recent · GET /ws · GET /</text>
|
||||
|
||||
<!-- Lane 2: protected -->
|
||||
<text class="dg-group-label" x="100" y="316">PROTECTED GROUP · r.Group("/", AuthMiddlewear)</text>
|
||||
<rect class="dg-box dg-box--pink" x="100" y="330" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm dg-title--pink" x="195" y="354" text-anchor="middle">AUTHMIDDLEWEAR</text>
|
||||
<text class="dg-text dg-text--pink" x="195" y="374" text-anchor="middle">bad token → 401</text>
|
||||
<path class="dg-edge" d="M290,360 H536" />
|
||||
<text class="dg-edge-label" x="415" y="352" text-anchor="middle">no admin check</text>
|
||||
<rect class="dg-box" x="540" y="325" width="390" height="70" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="560" y="346">HANDLER</text>
|
||||
<text class="dg-code" x="560" y="366">POST /uploads</text>
|
||||
<text class="dg-small" x="560" y="384">private=true checks the admin claim itself (requestIsAdmin)</text>
|
||||
|
||||
<!-- Lane 3: admin -->
|
||||
<text class="dg-group-label" x="100" y="426">ADMIN GROUP · AuthMiddlewear, AdminMiddleware</text>
|
||||
<rect class="dg-box dg-box--pink" x="100" y="450" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm dg-title--pink" x="195" y="474" text-anchor="middle">AUTHMIDDLEWEAR</text>
|
||||
<text class="dg-text dg-text--pink" x="195" y="494" text-anchor="middle">bad token → 401</text>
|
||||
<path class="dg-edge" d="M290,480 H316" />
|
||||
<rect class="dg-box dg-box--pink" x="320" y="450" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm dg-title--pink" x="415" y="474" text-anchor="middle">ADMINMIDDLEWARE</text>
|
||||
<text class="dg-text dg-text--pink" x="415" y="494" text-anchor="middle">admin ≠ true → 403</text>
|
||||
<path class="dg-edge" d="M510,480 H536" />
|
||||
<rect class="dg-box" x="540" y="435" width="390" height="90" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="560" y="456">HANDLER</text>
|
||||
<text class="dg-code" x="560" y="477">POST /rowing · GET /spotify/auth · GET /notes/*path</text>
|
||||
<text class="dg-code" x="560" y="496">POST /radio/upload · GET /radio/songs</text>
|
||||
<text class="dg-code" x="560" y="515">DELETE /radio/songs/:f · PATCH …/disable|enable</text>
|
||||
|
||||
<!-- Lane 4: GraphQL -->
|
||||
<text class="dg-group-label" x="100" y="556">POST /graphql · NO GUARDING MIDDLEWARE</text>
|
||||
<rect class="dg-box dg-box--tint" x="100" y="570" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="195" y="594" text-anchor="middle">AUTHCONTEXTMIDDLEWARE</text>
|
||||
<text class="dg-small" x="195" y="614" text-anchor="middle">never rejects; adds claims</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M290,600 H316" />
|
||||
<rect class="dg-box" x="320" y="570" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="415" y="594" text-anchor="middle">GQLGEN SERVER</text>
|
||||
<text class="dg-small" x="415" y="614" text-anchor="middle">complexity ≤ 200 · LRU 1000</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M510,600 H536" />
|
||||
<rect class="dg-box dg-box--pink" x="540" y="570" width="170" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm dg-title--pink" x="625" y="594" text-anchor="middle">DIRECTIVE</text>
|
||||
<text class="dg-code" x="625" y="614" text-anchor="middle">@admin @signedIn</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M710,600 H736" />
|
||||
<rect class="dg-box" x="740" y="570" width="190" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="835" y="594" text-anchor="middle">RESOLVER</text>
|
||||
<text class="dg-code" x="835" y="614" text-anchor="middle">graph/*.resolvers.go</text>
|
||||
|
||||
<!-- Store -->
|
||||
<rect class="dg-box dg-box--teal dg-box--deep" x="960" y="195" width="120" height="435" rx="4" />
|
||||
<text class="dg-title" x="1020" y="225" text-anchor="middle">STORE</text>
|
||||
<text class="dg-code" x="1020" y="245" text-anchor="middle">handlers.Store</text>
|
||||
<line class="dg-rule" x1="972" y1="258" x2="1068" y2="258" />
|
||||
<text class="dg-small" x="1020" y="280" text-anchor="middle">DB *gorm.DB</text>
|
||||
<text class="dg-small" x="1020" y="298" text-anchor="middle">Auth · Notes</text>
|
||||
<text class="dg-small" x="1020" y="316" text-anchor="middle">Uploads</text>
|
||||
<text class="dg-small" x="1020" y="334" text-anchor="middle">LoginLimiter</text>
|
||||
<text class="dg-small" x="1020" y="352" text-anchor="middle">SpotifyClient</text>
|
||||
<text class="dg-small" x="1020" y="370" text-anchor="middle">PythonURL</text>
|
||||
<text class="dg-small" x="1020" y="388" text-anchor="middle">TTL caches</text>
|
||||
<text class="dg-small" x="1020" y="406" text-anchor="middle">(cacheMu)</text>
|
||||
<path class="dg-edge" d="M930,240 H956" />
|
||||
<path class="dg-edge" d="M930,360 H956" />
|
||||
<path class="dg-edge" d="M930,480 H956" />
|
||||
<path class="dg-edge dg-edge--flow" d="M930,600 H956" />
|
||||
|
||||
<circle class="dg-badge" cx="100" cy="210" r="10" />
|
||||
<text class="dg-badge-text" x="100" y="210">1</text>
|
||||
<circle class="dg-badge" cx="100" cy="330" r="10" />
|
||||
<text class="dg-badge-text" x="100" y="330">2</text>
|
||||
<circle class="dg-badge" cx="100" cy="450" r="10" />
|
||||
<text class="dg-badge-text" x="100" y="450">3</text>
|
||||
<circle class="dg-badge" cx="100" cy="570" r="10" />
|
||||
<text class="dg-badge-text" x="100" y="570">4</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
nginx strips <code>/api</code>, so the backend's routes are written from <code>/</code>.
|
||||
Gin matches the route first, then runs its chain, which always begins with
|
||||
<code>TrafficLogFormatter</code> and <code>Recovery</code>. After that there are four kinds of chain:
|
||||
open routes ① that check cookies themselves if they need to, the <code>protected</code> group ②,
|
||||
the <code>admin</code> group ③ (whose <code>AdminMiddleware</code> reads the claims
|
||||
<code>AuthMiddlewear</code> stored, so the order matters), and GraphQL ④ (the animated path),
|
||||
which has no guard in front of it at all: each field's directive decides. Pink marks the auth
|
||||
checks. <code>SetTrustedProxies</code> pins the Docker network so <code>ClientIP()</code>, which
|
||||
the login rate limiter keys on, can't be spoofed with <code>X-Forwarded-For</code>.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,130 @@
|
||||
<!--
|
||||
How nginx/entrypoint.sh picks one of three configs at container start, then
|
||||
waits for the Vue build, starts the certificate watcher and execs nginx.
|
||||
Reflects nginx/entrypoint.sh, nginx/Dockerfile and the DEV_MODE switch in
|
||||
docker-compose.dev.yml. Re-check when the entrypoint's branches change.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="edge-entrypoint-flow" title="Container start: which nginx.conf gets written" :min-width="770">
|
||||
<svg class="dg" viewBox="0 0 1100 960" role="img" aria-labelledby="edge-entrypoint-flow-t">
|
||||
<title id="edge-entrypoint-flow-t">Flowchart of nginx/entrypoint.sh choosing the dev, production or setup config</title>
|
||||
|
||||
<!-- start -->
|
||||
<rect class="dg-box dg-box--solid" x="390" y="16" width="320" height="40" rx="20" />
|
||||
<text class="dg-title dg-text--ink" x="550" y="42" text-anchor="middle" style="fill: var(--color-surface-deep)">/ENTRYPOINT.SH STARTS</text>
|
||||
<path class="dg-edge" d="M550,56 V76" />
|
||||
|
||||
<!-- 1: routes partial -->
|
||||
<rect class="dg-box dg-box--tint" x="250" y="80" width="600" height="58" rx="4" />
|
||||
<text class="dg-code" x="550" y="104" text-anchor="middle">envsubst "$ENVSUBST_VARS" < nginx_routes.conf.template > /etc/nginx/nginx_routes.conf</text>
|
||||
<text class="dg-small" x="550" y="124" text-anchor="middle">done once, before the choice: dev and production include it, and the watcher's nginx -t needs it later</text>
|
||||
<circle class="dg-badge" cx="250" cy="80" r="10" />
|
||||
<text class="dg-badge-text" x="250" y="80">1</text>
|
||||
<path class="dg-edge" d="M550,138 V156" />
|
||||
|
||||
<!-- diamond 1: DEV_MODE -->
|
||||
<path class="dg-box" d="M550,160 L650,200 L550,240 L450,200 Z" />
|
||||
<text class="dg-code" x="550" y="197" text-anchor="middle">DEV_MODE</text>
|
||||
<text class="dg-code" x="550" y="212" text-anchor="middle">= "true"?</text>
|
||||
<circle class="dg-badge" cx="450" cy="200" r="10" />
|
||||
<text class="dg-badge-text" x="450" y="200">2</text>
|
||||
|
||||
<path class="dg-edge" d="M440,200 H190 V366" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="300" y="192" text-anchor="middle">yes</text>
|
||||
<path class="dg-edge" d="M550,240 V266" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="566" y="257">no</text>
|
||||
|
||||
<!-- diamond 2: cert present -->
|
||||
<path class="dg-box" d="M550,270 L680,312 L550,354 L420,312 Z" />
|
||||
<text class="dg-code" x="550" y="308" text-anchor="middle">fullchain.pem + privkey.pem</text>
|
||||
<text class="dg-code" x="550" y="323" text-anchor="middle">in live/$DOMAIN/ ?</text>
|
||||
<path class="dg-edge" d="M550,354 V366" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="566" y="364">yes</text>
|
||||
<path class="dg-edge" d="M680,312 H910 V366" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="795" y="304" text-anchor="middle">no</text>
|
||||
|
||||
<!-- three configs -->
|
||||
<rect class="dg-box dg-box--muted" x="30" y="370" width="320" height="160" rx="4" />
|
||||
<text class="dg-title" x="46" y="396">DEV · NGINX_DEV.CONF.TEMPLATE</text>
|
||||
<text class="dg-small" x="46" y="416">self-signed cert, minted once, kept in certbot/conf</text>
|
||||
<text class="dg-code" x="46" y="438">openssl req -x509 … -subj /CN=localhost</text>
|
||||
<text class="dg-code" x="46" y="458">envsubst → nginx_dev_common.conf</text>
|
||||
<text class="dg-code" x="46" y="476">envsubst → nginx.conf</text>
|
||||
<text class="dg-small" x="46" y="496">:80 and :443 both serve; / → vue:5173</text>
|
||||
<text class="dg-code" x="46" y="518" style="fill: var(--color-primary)">CONFIG_MODE=dev</text>
|
||||
|
||||
<rect class="dg-box" x="390" y="370" width="320" height="160" rx="4" />
|
||||
<text class="dg-title" x="406" y="396">PRODUCTION · NGINX.CONF.TEMPLATE</text>
|
||||
<text class="dg-small" x="406" y="416">steady state: the Let's Encrypt cert is on disk</text>
|
||||
<text class="dg-code" x="406" y="438">envsubst "$ENVSUBST_VARS"</text>
|
||||
<text class="dg-code" x="406" y="456"> < nginx.conf.template > nginx.conf</text>
|
||||
<text class="dg-small" x="406" y="478">:80 → 301 https · apex → www · TLS on :443</text>
|
||||
<text class="dg-small" x="406" y="496">includes nginx_routes.conf</text>
|
||||
<text class="dg-code" x="406" y="518" style="fill: var(--color-primary)">CONFIG_MODE=prod</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="750" y="370" width="320" height="160" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="766" y="396">SETUP · NGINX_SETUP.CONF.TEMPLATE</text>
|
||||
<text class="dg-small" x="766" y="416">first boot on a new host: no certificate yet</text>
|
||||
<text class="dg-code" x="766" y="438">envsubst '${DOMAIN}'</text>
|
||||
<text class="dg-code" x="766" y="456"> < nginx_setup.conf.template</text>
|
||||
<text class="dg-small" x="766" y="478">:80 only: ACME webroot, /nginx-health, 404</text>
|
||||
<text class="dg-small" x="766" y="496">no TLS, no upstreams: nothing can fail to load</text>
|
||||
<text class="dg-code" x="766" y="518" style="fill: var(--color-primary)">CONFIG_MODE=setup</text>
|
||||
|
||||
<!-- merge -->
|
||||
<path class="dg-edge dg-edge--plain" d="M190,530 V556 H910 V530" />
|
||||
<path class="dg-edge" d="M550,530 V576" />
|
||||
|
||||
<rect class="dg-box" x="370" y="580" width="360" height="44" rx="4" />
|
||||
<text class="dg-code" x="550" y="600" text-anchor="middle">chmod 755 /uploads</text>
|
||||
<text class="dg-small" x="550" y="616" text-anchor="middle">workers must traverse the volume the backend created</text>
|
||||
<path class="dg-edge" d="M550,624 V646" />
|
||||
|
||||
<!-- diamond 3 -->
|
||||
<path class="dg-box" d="M550,650 L640,684 L550,718 L460,684 Z" />
|
||||
<text class="dg-code" x="550" y="681" text-anchor="middle">DEV_MODE</text>
|
||||
<text class="dg-code" x="550" y="696" text-anchor="middle">= "true"?</text>
|
||||
<path class="dg-edge" d="M550,718 V746" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="566" y="738">no</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M640,684 H960 V922 H734" />
|
||||
<text class="dg-edge-label" x="800" y="676" text-anchor="middle">yes: Vite serves /, no watcher</text>
|
||||
|
||||
<rect class="dg-box" x="370" y="750" width="360" height="52" rx="4" />
|
||||
<text class="dg-text" x="550" y="771" text-anchor="middle">wait up to 120 s for /etc/nginx/html/index.html</text>
|
||||
<text class="dg-small" x="550" y="790" text-anchor="middle">vue_dist is filled by the one-shot vue build; then start anyway</text>
|
||||
<path class="dg-edge" d="M550,802 V822" />
|
||||
|
||||
<rect class="dg-box" x="370" y="826" width="360" height="52" rx="4" />
|
||||
<text class="dg-code" x="550" y="847" text-anchor="middle">cert_watcher &</text>
|
||||
<text class="dg-small" x="550" y="866" text-anchor="middle">background loop, every $CERT_WATCH_INTERVAL (60 s)</text>
|
||||
<circle class="dg-badge" cx="370" cy="826" r="10" />
|
||||
<text class="dg-badge-text" x="370" y="826">3</text>
|
||||
<path class="dg-edge" d="M550,878 V898" />
|
||||
|
||||
<rect class="dg-box dg-box--solid" x="370" y="902" width="360" height="40" rx="20" />
|
||||
<text class="dg-code" x="550" y="927" text-anchor="middle" style="fill: var(--color-surface-deep)">exec: nginx -g 'daemon off;' (PID 1)</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
No <code>nginx.conf</code> is baked into the image; three templates are,
|
||||
and the entrypoint writes exactly one of them on every start. Step
|
||||
<strong>1</strong> renders the shared route table first, whatever happens
|
||||
next. At <strong>2</strong>, <code>DEV_MODE</code> (set only by
|
||||
<code>docker-compose.dev.yml</code>) wins outright; otherwise the presence
|
||||
of a certificate decides, because the production config's
|
||||
<code>ssl_certificate</code> lines would stop nginx from starting without
|
||||
one. The <code>envsubst</code> allow-list is what keeps nginx's own
|
||||
<code>$host</code> and <code>$remote_addr</code> intact: only the named
|
||||
<code>${DOMAIN} ${BACKEND_HOST} …</code> variables are replaced. The
|
||||
watcher at <strong>3</strong> moves a setup-mode nginx onto the
|
||||
production config once certbot's first certificate lands (render to a
|
||||
temp file, <code>nginx -t</code>, install, <code>nginx -s reload</code>),
|
||||
and reloads after a renewal when certbot's <code>--deploy-hook</code>
|
||||
touches <code>/etc/letsencrypt/.nginx-reload</code>. Grey dashed = local
|
||||
dev only.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,229 @@
|
||||
<!--
|
||||
The whole production route table of the www server block: every location
|
||||
nginx matches, what it does to the request, and the container:port it lands
|
||||
on. Reflects nginx/nginx_routes.conf.template (shared routes),
|
||||
nginx/nginx.conf.template (/api/graphql, /uploads/, static blocks, apex /v2/)
|
||||
and the ports in docker-compose.yml / .env.example. Redraw when a location
|
||||
is added, gated or moved.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="edge-route-map" title="Every route nginx serves, and where it goes" :min-width="770">
|
||||
<svg class="dg" viewBox="0 0 1100 1086" role="img" aria-labelledby="edge-route-map-t">
|
||||
<title id="edge-route-map-t">Table of nginx locations, grouped by the upstream container each one proxies to, coloured by public, admin-gated, 404 and disk-served</title>
|
||||
<text class="dg-title dg-title--sm" x="36" y="46">LOCATION (MATCH TYPE)</text>
|
||||
<text class="dg-title dg-title--sm" x="390" y="46">WHAT NGINX DOES ON THE WAY</text>
|
||||
<text class="dg-title dg-title--sm" x="812" y="46">UPSTREAM CONTAINER:PORT</text>
|
||||
<line class="dg-rule" x1="16" y1="58" x2="1084" y2="58" />
|
||||
<rect class="dg-band" x="16" y="70" width="1068" height="140" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="73" width="280" height="134" rx="3" />
|
||||
<text class="dg-code" x="812" y="144" style="fill: var(--color-primary)">backend:8080</text>
|
||||
<text class="dg-small" x="1070" y="144" text-anchor="end">Go API</text>
|
||||
<circle class="dg-dot" cx="24" cy="85" r="4" />
|
||||
<text class="dg-code" x="36" y="89" style="fill: var(--color-secondary)">/api/ws</text>
|
||||
<text class="dg-small" x="390" y="89">strip /api · Upgrade · no rate limit</text>
|
||||
<path class="dg-edge" d="M712,85 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="107" r="4" />
|
||||
<text class="dg-code" x="36" y="111" style="fill: var(--color-secondary)">/api/auth/login</text>
|
||||
<text class="dg-small" x="390" y="111">strip /api · zone login</text>
|
||||
<path class="dg-edge" d="M712,107 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="129" r="4" />
|
||||
<text class="dg-code" x="36" y="133" style="fill: var(--color-secondary)">/api/uploads</text>
|
||||
<text class="dg-small" x="390" y="133">strip /api · zone upload</text>
|
||||
<path class="dg-edge" d="M712,129 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="151" r="4" />
|
||||
<text class="dg-code" x="36" y="155" style="fill: var(--color-secondary)">/api/graphql</text>
|
||||
<text class="dg-small" x="390" y="155">strip /api · zone graphql · production only</text>
|
||||
<path class="dg-edge" d="M712,151 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="173" r="4" />
|
||||
<text class="dg-code" x="36" y="177" style="fill: var(--color-secondary)">/api/</text>
|
||||
<text class="dg-small" x="390" y="177">strip /api · zone api</text>
|
||||
<path class="dg-edge" d="M712,173 H796" />
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="195" r="4" />
|
||||
<text class="dg-code" x="36" y="199" style="fill: var(--color-secondary)">= /internal/auth/admin-validate</text>
|
||||
<text class="dg-small" x="390" y="199">internal; rewritten to /auth/validate-admin</text>
|
||||
<path class="dg-edge dg-edge--pink dg-edge--dashed" d="M712,195 H796" />
|
||||
<rect class="dg-box" x="800" y="223" width="280" height="46" rx="3" />
|
||||
<text class="dg-code" x="812" y="250" style="fill: var(--color-primary)">icecast2:8000</text>
|
||||
<text class="dg-small" x="1070" y="250" text-anchor="end">radio stream</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="235" r="4" />
|
||||
<text class="dg-code" x="36" y="239" style="fill: var(--color-secondary)">/radio/admin/</text>
|
||||
<text class="dg-small" x="390" y="239">strip /radio · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,235 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="257" r="4" />
|
||||
<text class="dg-code" x="36" y="261" style="fill: var(--color-secondary)">/radio/</text>
|
||||
<text class="dg-small" x="390" y="261">strip /radio</text>
|
||||
<path class="dg-edge" d="M712,257 H796" />
|
||||
<rect class="dg-band" x="16" y="282" width="1068" height="74" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="285" width="280" height="68" rx="3" />
|
||||
<text class="dg-code" x="812" y="323" style="fill: var(--color-primary)">gitea:3000</text>
|
||||
<text class="dg-small" x="1070" y="323" text-anchor="end">git server</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="297" r="4" />
|
||||
<text class="dg-code" x="36" y="301" style="fill: var(--color-secondary)">~ /gitea/<o>/<r>/(…commit/|archive/|compare/)</text>
|
||||
<text class="dg-small" x="390" y="301">strip /gitea · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,297 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="319" r="4" />
|
||||
<text class="dg-code" x="36" y="323" style="fill: var(--color-secondary)">/gitea/</text>
|
||||
<text class="dg-small" x="390" y="323">strip /gitea</text>
|
||||
<path class="dg-edge" d="M712,319 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="341" r="4" />
|
||||
<text class="dg-code" x="36" y="345" style="fill: var(--color-secondary)">/v2/ (apex server block only)</text>
|
||||
<text class="dg-small" x="390" y="345">registry · no body limit · 900s</text>
|
||||
<path class="dg-edge" d="M712,341 H796" />
|
||||
<rect class="dg-box" x="800" y="369" width="280" height="90" rx="3" />
|
||||
<text class="dg-code" x="812" y="418" style="fill: var(--color-primary)">silverbullet-public:3000</text>
|
||||
<text class="dg-small" x="1070" y="418" text-anchor="end">public notes</text>
|
||||
<circle class="dg-dot" cx="24" cy="381" r="4" />
|
||||
<text class="dg-code" x="36" y="385" style="fill: var(--color-secondary)">/notes/</text>
|
||||
<text class="dg-small" x="390" y="385">prefix kept · Upgrade</text>
|
||||
<path class="dg-edge" d="M712,381 H796" />
|
||||
<circle class="dg-dot dg-dot--muted" cx="24" cy="403" r="4" />
|
||||
<text class="dg-code" x="36" y="407" style="fill: var(--color-secondary)">~* /notes/…/(private|templates)/</text>
|
||||
<text class="dg-small" x="390" y="407">privacy boundary</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M712,403 H742" />
|
||||
<text class="dg-text dg-text--muted" x="750" y="407">404</text>
|
||||
<circle class="dg-dot dg-dot--muted" cx="24" cy="425" r="4" />
|
||||
<text class="dg-code" x="36" y="429" style="fill: var(--color-secondary)">~ /notes/<x>/.<dot-segment></text>
|
||||
<text class="dg-small" x="390" y="429">hides .git, .obsidian …</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M712,425 H742" />
|
||||
<text class="dg-text dg-text--muted" x="750" y="429">404</text>
|
||||
<circle class="dg-dot dg-dot--muted" cx="24" cy="447" r="4" />
|
||||
<text class="dg-code" x="36" y="451" style="fill: var(--color-secondary)">^~ /notes/.revisions</text>
|
||||
<text class="dg-small" x="390" y="451">full history incl. private/</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M712,447 H742" />
|
||||
<text class="dg-text dg-text--muted" x="750" y="451">404</text>
|
||||
<rect class="dg-band" x="16" y="472" width="1068" height="30" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="475" width="280" height="24" rx="3" />
|
||||
<text class="dg-code" x="812" y="491" style="fill: var(--color-primary)">silverbullet:3000</text>
|
||||
<text class="dg-small" x="1070" y="491" text-anchor="end">notes editor</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="487" r="4" />
|
||||
<text class="dg-code" x="36" y="491" style="fill: var(--color-secondary)">/sb/</text>
|
||||
<text class="dg-small" x="390" y="491">prefix kept · Upgrade · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,487 H796" />
|
||||
<rect class="dg-box" x="800" y="515" width="280" height="68" rx="3" />
|
||||
<text class="dg-code" x="812" y="553" style="fill: var(--color-primary)">python:8000</text>
|
||||
<text class="dg-small" x="1070" y="553" text-anchor="end">FastAPI</text>
|
||||
<circle class="dg-dot" cx="24" cy="527" r="4" />
|
||||
<text class="dg-code" x="36" y="531" style="fill: var(--color-secondary)">~ ^/py/hotels/(search|scan)</text>
|
||||
<text class="dg-small" x="390" y="531">strip /py · zone hotel_search · unbuffered</text>
|
||||
<path class="dg-edge" d="M712,527 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="549" r="4" />
|
||||
<text class="dg-code" x="36" y="553" style="fill: var(--color-secondary)">/py/</text>
|
||||
<text class="dg-small" x="390" y="553">strip /py · zone api</text>
|
||||
<path class="dg-edge" d="M712,549 H796" />
|
||||
<circle class="dg-dot dg-dot--muted" cx="24" cy="571" r="4" />
|
||||
<text class="dg-code" x="36" y="575" style="fill: var(--color-secondary)">^~ /py/internal/</text>
|
||||
<text class="dg-small" x="390" y="575">Go calls it directly instead</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M712,571 H742" />
|
||||
<text class="dg-text dg-text--muted" x="750" y="575">404</text>
|
||||
<rect class="dg-band" x="16" y="596" width="1068" height="74" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="599" width="280" height="68" rx="3" />
|
||||
<text class="dg-code" x="812" y="637" style="fill: var(--color-primary)">jobs:8080</text>
|
||||
<text class="dg-small" x="1070" y="637" text-anchor="end">job tracker</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="611" r="4" />
|
||||
<text class="dg-code" x="36" y="615" style="fill: var(--color-secondary)">^~ /jobs/</text>
|
||||
<text class="dg-small" x="390" y="615">prefix kept · zone api · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,611 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="633" r="4" />
|
||||
<text class="dg-code" x="36" y="637" style="fill: var(--color-secondary)">^~ /jobs/api/capture</text>
|
||||
<text class="dg-small" x="390" y="637">zone api · bearer token checked by app</text>
|
||||
<path class="dg-edge" d="M712,633 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="655" r="4" />
|
||||
<text class="dg-code" x="36" y="659" style="fill: var(--color-secondary)">= /jobs/job-capture.user.js</text>
|
||||
<text class="dg-small" x="390" y="659">userscript update URL</text>
|
||||
<path class="dg-edge" d="M712,655 H796" />
|
||||
<rect class="dg-box" x="800" y="683" width="280" height="68" rx="3" />
|
||||
<text class="dg-code" x="812" y="721" style="fill: var(--color-primary)">activity-tracker:8080</text>
|
||||
<text class="dg-small" x="1070" y="721" text-anchor="end">activity tracker</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="695" r="4" />
|
||||
<text class="dg-code" x="36" y="699" style="fill: var(--color-secondary)">^~ /tracker/</text>
|
||||
<text class="dg-small" x="390" y="699">strip /tracker · zone api · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,695 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="717" r="4" />
|
||||
<text class="dg-code" x="36" y="721" style="fill: var(--color-secondary)">^~ /tracker/api/v1/</text>
|
||||
<text class="dg-small" x="390" y="721">strip /tracker · device keys checked by app</text>
|
||||
<path class="dg-edge" d="M712,717 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="739" r="4" />
|
||||
<text class="dg-code" x="36" y="743" style="fill: var(--color-secondary)">= /tracker/tracker.user.js</text>
|
||||
<text class="dg-small" x="390" y="743">strip /tracker</text>
|
||||
<path class="dg-edge" d="M712,739 H796" />
|
||||
<rect class="dg-band" x="16" y="764" width="1068" height="30" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="767" width="280" height="24" rx="3" />
|
||||
<text class="dg-code" x="812" y="783" style="fill: var(--color-primary)">usaco:8080</text>
|
||||
<text class="dg-small" x="1070" y="783" text-anchor="end">USACO log</text>
|
||||
<circle class="dg-dot" cx="24" cy="779" r="4" />
|
||||
<text class="dg-code" x="36" y="783" style="fill: var(--color-secondary)">^~ /usaco/</text>
|
||||
<text class="dg-small" x="390" y="783">prefix kept · zone api · 120s</text>
|
||||
<path class="dg-edge" d="M712,779 H796" />
|
||||
<rect class="dg-box" x="800" y="807" width="280" height="24" rx="3" />
|
||||
<text class="dg-code" x="812" y="823" style="fill: var(--color-primary)">dozzle:8080</text>
|
||||
<text class="dg-small" x="1070" y="823" text-anchor="end">log viewer</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="819" r="4" />
|
||||
<text class="dg-code" x="36" y="823" style="fill: var(--color-secondary)">/dozzle/</text>
|
||||
<text class="dg-small" x="390" y="823">prefix kept · SSE unbuffered · 1h</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,819 H796" />
|
||||
<rect class="dg-band" x="16" y="844" width="1068" height="30" opacity="0.18" />
|
||||
<rect class="dg-box" x="800" y="847" width="280" height="24" rx="3" />
|
||||
<text class="dg-code" x="812" y="863" style="fill: var(--color-primary)">garage-webui:3909</text>
|
||||
<text class="dg-small" x="1070" y="863" text-anchor="end">bucket admin</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="859" r="4" />
|
||||
<text class="dg-code" x="36" y="863" style="fill: var(--color-secondary)">/garage/</text>
|
||||
<text class="dg-small" x="390" y="863">prefix kept · body up to 2G · unbuffered</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,859 H796" />
|
||||
<rect class="dg-box" x="800" y="887" width="280" height="24" rx="3" />
|
||||
<text class="dg-code" x="812" y="903" style="fill: var(--color-primary)">garage:3902</text>
|
||||
<text class="dg-small" x="1070" y="903" text-anchor="end">S3 website endpoint</text>
|
||||
<circle class="dg-dot" cx="24" cy="899" r="4" />
|
||||
<text class="dg-code" x="36" y="903" style="fill: var(--color-secondary)">/uploads/</text>
|
||||
<text class="dg-small" x="390" y="903">strip · Host uploads.web.garage · 2s connect</text>
|
||||
<path class="dg-edge" d="M712,899 H796" />
|
||||
<rect class="dg-band" x="16" y="924" width="1068" height="52" opacity="0.18" />
|
||||
<rect class="dg-box dg-box--green" x="800" y="927" width="280" height="46" rx="3" />
|
||||
<text class="dg-code" x="812" y="954" style="fill: var(--color-primary)">uploads volume</text>
|
||||
<text class="dg-small" x="1070" y="954" text-anchor="end">/uploads on disk</text>
|
||||
<circle class="dg-dot dg-dot--green" cx="24" cy="939" r="4" />
|
||||
<text class="dg-code" x="36" y="943" style="fill: var(--color-secondary)">@uploads_disk</text>
|
||||
<text class="dg-small" x="390" y="943">named location · Garage 404/5xx lands here</text>
|
||||
<path class="dg-edge dg-edge--green" d="M712,939 H796" />
|
||||
<circle class="dg-dot dg-dot--pink" cx="24" cy="961" r="4" />
|
||||
<text class="dg-code" x="36" y="965" style="fill: var(--color-secondary)">/uploads/private/</text>
|
||||
<text class="dg-small" x="390" y="965">alias /uploads/private/ · auth_request</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M712,961 H796" />
|
||||
<rect class="dg-box dg-box--green" x="800" y="989" width="280" height="46" rx="3" />
|
||||
<text class="dg-code" x="812" y="1016" style="fill: var(--color-primary)">vue_dist volume</text>
|
||||
<text class="dg-small" x="1070" y="1016" text-anchor="end">/etc/nginx/html</text>
|
||||
<circle class="dg-dot dg-dot--green" cx="24" cy="1001" r="4" />
|
||||
<text class="dg-code" x="36" y="1005" style="fill: var(--color-secondary)">/</text>
|
||||
<text class="dg-small" x="390" y="1005">try_files $uri $uri/ /index.html</text>
|
||||
<path class="dg-edge dg-edge--green" d="M712,1001 H796" />
|
||||
<circle class="dg-dot dg-dot--green" cx="24" cy="1023" r="4" />
|
||||
<text class="dg-code" x="36" y="1027" style="fill: var(--color-secondary)">/assets/ /fonts/ /img/ /sound/</text>
|
||||
<text class="dg-small" x="390" y="1027">expires 1y / 30d / 7d / 7d</text>
|
||||
<path class="dg-edge dg-edge--green" d="M712,1023 H796" />
|
||||
<circle class="dg-dot" cx="24" cy="1066" r="5" />
|
||||
<text class="dg-small" x="36" y="1070">public, proxied</text>
|
||||
<circle class="dg-dot dg-dot--pink" cx="169.0" cy="1066" r="5" />
|
||||
<text class="dg-small" x="181.0" y="1070">admin-gated (auth_request)</text>
|
||||
<circle class="dg-dot dg-dot--muted" cx="382.20000000000005" cy="1066" r="5" />
|
||||
<text class="dg-small" x="394.20000000000005" y="1070">answered 404 by nginx</text>
|
||||
<circle class="dg-dot dg-dot--green" cx="564.4000000000001" cy="1066" r="5" />
|
||||
<text class="dg-small" x="576.4000000000001" y="1070">served by nginx from a volume</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
Read it right to left: each box is one container on <code>app-network</code>
|
||||
(or a volume nginx reads itself), and the rows beside it are the
|
||||
locations that reach it. Pink rows run the admin gate first; grey rows
|
||||
never leave nginx. Upstreams are written as <code>set $upstream_* …</code>
|
||||
variables, so nginx resolves container names per request through Docker's
|
||||
DNS (<code>resolver 127.0.0.11 valid=10s</code>) and still boots when one of
|
||||
them is down. Every proxied row also gets the bare-prefix twin
|
||||
(<code>/gitea</code> → 301 <code>/gitea/</code>) that is left out here; in
|
||||
dev, <code>/</code> goes to <code>vue:5173</code> instead of
|
||||
<code>vue_dist</code>, and <code>/api/graphql</code> falls into
|
||||
<code>/api/</code>.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,106 @@
|
||||
<!--
|
||||
Sequence of a cold load of "/": index.html → main.js → router + Pinia →
|
||||
Landing → BoxCanvas, and the three GraphQL requests the canvas fires
|
||||
(me, boxes, background), with the home query only when a widget asks.
|
||||
Reflects: vue/index.html, src/main.js, router/index.js,
|
||||
views/landing/Landing.vue, views/home3/BoxCanvas.vue, stores/auth.js,
|
||||
stores/boxes.js, stores/background.js, stores/homeData.js, graphql.js.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="frontend-boot-sequence" title="Cold load of the landing page" :min-width="770">
|
||||
<svg class="dg" viewBox="0 0 1100 800" role="img" aria-labelledby="frontend-boot-sequence-t">
|
||||
<title id="frontend-boot-sequence-t">
|
||||
Sequence diagram: index.html loads main.js, which installs the router and Pinia and mounts the
|
||||
app; the router passes the landing route, Landing loads BoxCanvas, which asks the auth, boxes and
|
||||
background stores for data over three GraphQL requests
|
||||
</title>
|
||||
|
||||
<!-- Lifelines -->
|
||||
<g v-for="l in lanes" :key="l.label">
|
||||
<line class="dg-lifeline" :x1="l.x" y1="66" :x2="l.x" y2="780" />
|
||||
<rect class="dg-box" :class="l.cls" :x="l.x - l.w / 2" y="18" :width="l.w" height="48" rx="4" />
|
||||
<text class="dg-title dg-title--sm" :class="l.titleCls" :x="l.x" y="38" text-anchor="middle">{{ l.label }}</text>
|
||||
<text class="dg-code" :x="l.x" y="56" text-anchor="middle">{{ l.sub }}</text>
|
||||
</g>
|
||||
|
||||
<!-- Activations -->
|
||||
<rect class="dg-activation" x="265" y="132" width="10" height="140" />
|
||||
<rect class="dg-activation" x="435" y="172" width="10" height="150" />
|
||||
<rect class="dg-activation" x="615" y="332" width="10" height="400" />
|
||||
<rect class="dg-activation" x="795" y="412" width="10" height="330" />
|
||||
<rect class="dg-activation" x="985" y="442" width="10" height="200" />
|
||||
|
||||
<!-- Messages -->
|
||||
<g v-for="(m, i) in messages" :key="i">
|
||||
<template v-if="m.self">
|
||||
<path
|
||||
class="dg-edge" :class="m.cls"
|
||||
:d="`M${m.from + 5},${m.y - 8} H${m.from + 34} V${m.y + 6} H${m.from + 9}`"
|
||||
/>
|
||||
<text class="dg-edge-label" :class="m.labelCls" :x="m.from + 40" :y="m.y + 2">{{ m.label }}</text>
|
||||
</template>
|
||||
<template v-else>
|
||||
<path
|
||||
class="dg-edge" :class="m.cls"
|
||||
:d="`M${m.from + (m.to > m.from ? 5 : -5)},${m.y} H${m.to + (m.to > m.from ? -9 : 9)}`"
|
||||
/>
|
||||
<text class="dg-edge-label" :class="m.labelCls" :x="(m.from + m.to) / 2" :y="m.y - 6" text-anchor="middle">{{ m.label }}</text>
|
||||
</template>
|
||||
<circle class="dg-badge" cx="26" :cy="m.y" r="10" />
|
||||
<text class="dg-badge-text" x="26" :y="m.y">{{ i + 1 }}</text>
|
||||
</g>
|
||||
|
||||
<!-- Notes -->
|
||||
<rect class="dg-band" x="40" y="298" width="1050" height="24" />
|
||||
<text class="dg-small" x="460" y="314">blank until here: RouterView renders nothing while the initial navigation is pending</text>
|
||||
<rect class="dg-band dg-band--pink" x="40" y="688" width="1050" height="84" />
|
||||
<text class="dg-small" x="830" y="768">only if a widget box mounts</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
<code>main.js</code> installs the router (3) <em>before</em> Pinia (4), and the router's install
|
||||
starts the first navigation at once. That works only because navigation guards run in a promise
|
||||
chain, so by the time <code>beforeEach</code> calls <code>useAuthStore()</code> (6) Pinia is active.
|
||||
On <code>/</code> the guard has nothing to wait for. The canvas then fires three independent
|
||||
GraphQL POSTs (9–14). It asks for <code>me</code> on its own rather than through the home query,
|
||||
so the landing page never fans out to Spotify, Steam and Gitea just to decide whether to show an
|
||||
Edit button. The nine-field <code>HomeData</code> query (pink band, 17–18) is sent only as a side
|
||||
effect of the first <code>useHomeDataStore()</code> call, which happens when a widget box mounts.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
|
||||
const X = { html: 110, main: 270, router: 440, view: 620, stores: 800, gql: 990 };
|
||||
|
||||
const lanes = [
|
||||
{ x: X.html, w: 130, label: "INDEX.HTML", sub: "<body id=app>", cls: "dg-box--pink", titleCls: "dg-title--pink" },
|
||||
{ x: X.main, w: 130, label: "MAIN.JS", sub: "createApp" },
|
||||
{ x: X.router, w: 140, label: "ROUTER", sub: "router/index.js" },
|
||||
{ x: X.view, w: 170, label: "LANDING → CANVAS", sub: "BoxCanvas.vue" },
|
||||
{ x: X.stores, w: 160, label: "PINIA STORES", sub: "auth · boxes · bg" },
|
||||
{ x: X.gql, w: 180, label: "GQL()", sub: "POST /api/graphql" },
|
||||
];
|
||||
|
||||
const messages = [
|
||||
{ from: X.html, to: X.main, y: 100, label: "loads /src/main.js" },
|
||||
{ from: X.main, y: 132, self: true, label: "createApp(App)" },
|
||||
{ from: X.main, to: X.router, y: 172, label: "app.use(router)" },
|
||||
{ from: X.main, to: X.stores, y: 210, label: "app.use(createPinia())" },
|
||||
{ from: X.main, to: X.html, y: 250, label: "mount('#app')", cls: "dg-edge--pink", labelCls: "dg-edge-label--pink" },
|
||||
{ from: X.router, y: 282, self: true, label: "beforeEach: no requiresAdmin → pass" },
|
||||
{ from: X.router, to: X.view, y: 340, label: "render Landing" },
|
||||
{ from: X.view, y: 372, self: true, label: "import() BoxCanvas" },
|
||||
{ from: X.view, to: X.stores, y: 420, label: "auth.ensureLoaded()" },
|
||||
{ from: X.stores, to: X.gql, y: 450, label: "query Me { me }", cls: "dg-edge--flow" },
|
||||
{ from: X.view, to: X.stores, y: 490, label: "boxes:index .fetch()" },
|
||||
{ from: X.stores, to: X.gql, y: 520, label: "boxes(page: \"index\")", cls: "dg-edge--flow" },
|
||||
{ from: X.view, to: X.stores, y: 560, label: "background.show(\"index\")" },
|
||||
{ from: X.stores, to: X.gql, y: 590, label: "background(page)", cls: "dg-edge--flow" },
|
||||
{ from: X.gql, to: X.stores, y: 630, label: "3 answers, any order", cls: "dg-edge--green dg-edge--dashed", labelCls: "" },
|
||||
{ from: X.stores, to: X.view, y: 660, label: "BoxFrames render", cls: "dg-edge--green dg-edge--dashed" },
|
||||
{ from: X.view, to: X.stores, y: 710, label: "useHomeDataStore()", cls: "dg-edge--pink dg-edge--dashed", labelCls: "dg-edge-label--pink" },
|
||||
{ from: X.stores, to: X.gql, y: 742, label: "query HomeData", cls: "dg-edge--pink dg-edge--dashed", labelCls: "dg-edge-label--pink" },
|
||||
];
|
||||
</script>
|
||||
@@ -0,0 +1,130 @@
|
||||
<!--
|
||||
The route table as a tree: the router, the three top-level records (two
|
||||
layout shells and the bare /stp2), and every leaf route with its name, its
|
||||
component file and whether it is bundled in the entry or code-split.
|
||||
Reflects: vue/src/router/index.js, App.vue, layouts/DefaultLayout.vue,
|
||||
layouts/CVLayout.vue. (/architecture itself is left out on purpose.)
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="frontend-route-tree" title="The route tree and its layouts" :min-width="800">
|
||||
<svg class="dg" viewBox="0 0 1140 640" role="img" aria-labelledby="frontend-route-tree-t">
|
||||
<title id="frontend-route-tree-t">
|
||||
Vue Router table: DefaultLayout holding the landing page, /stp, admin routes, automata, hotels and
|
||||
the catch-all CanvasPage; /stp2 with no layout; /cv inside CVLayout
|
||||
</title>
|
||||
|
||||
<!-- Router -->
|
||||
<rect class="dg-box dg-box--tint" x="20" y="250" width="190" height="100" rx="4" />
|
||||
<text class="dg-title" x="115" y="276" text-anchor="middle">ROUTER</text>
|
||||
<text class="dg-code" x="115" y="298" text-anchor="middle">createWebHistory()</text>
|
||||
<text class="dg-small" x="115" y="318" text-anchor="middle">App.vue is only</text>
|
||||
<text class="dg-code" x="115" y="336" text-anchor="middle"><RouterView /></text>
|
||||
|
||||
<path class="dg-edge dg-edge--plain" d="M210,300 H230" />
|
||||
<path class="dg-edge dg-edge--plain" d="M230,211 V523" />
|
||||
<path class="dg-edge" d="M230,211 H246" />
|
||||
<path class="dg-edge dg-edge--muted" d="M230,453 H246" />
|
||||
<path class="dg-edge" d="M230,523 H246" />
|
||||
|
||||
<!-- Layouts -->
|
||||
<rect class="dg-box" x="250" y="121" width="200" height="180" rx="4" />
|
||||
<text class="dg-title" x="350" y="146" text-anchor="middle">DEFAULTLAYOUT</text>
|
||||
<text class="dg-code" x="350" y="166" text-anchor="middle">path: "/"</text>
|
||||
<line class="dg-rule" x1="262" y1="178" x2="438" y2="178" />
|
||||
<text class="dg-small" x="264" y="198">Navbar · <main> · Footer</text>
|
||||
<text class="dg-small" x="264" y="218">dark theme, .halftone</text>
|
||||
<text class="dg-small" x="264" y="238"><Transition name="slide"></text>
|
||||
<text class="dg-small" x="264" y="258">:key="$route.path" remounts</text>
|
||||
<text class="dg-small" x="264" y="278">paints background.style</text>
|
||||
|
||||
<rect class="dg-box dg-box--muted" x="250" y="430" width="200" height="46" rx="4" />
|
||||
<text class="dg-text dg-text--muted" x="350" y="451" text-anchor="middle">(no layout)</text>
|
||||
<text class="dg-small" x="350" y="467" text-anchor="middle">top-level record</text>
|
||||
|
||||
<rect class="dg-box" x="250" y="500" width="200" height="46" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="350" y="519" text-anchor="middle">CVLAYOUT</text>
|
||||
<text class="dg-small" x="350" y="537" text-anchor="middle">path: "/cv" · light tokens</text>
|
||||
|
||||
<!-- Trunk to DefaultLayout children -->
|
||||
<path class="dg-edge dg-edge--plain" d="M450,211 H475" />
|
||||
<path class="dg-edge dg-edge--plain" d="M475,43 V379" />
|
||||
<path class="dg-edge" d="M475,43 H496" />
|
||||
<path class="dg-edge" d="M475,99 H496" />
|
||||
<path class="dg-edge" d="M475,155 H496" />
|
||||
<path class="dg-edge dg-edge--pink" d="M475,211 H496" />
|
||||
<path class="dg-edge" d="M475,267 H496" />
|
||||
<path class="dg-edge" d="M475,323 H496" />
|
||||
<path class="dg-edge" d="M475,379 H496" />
|
||||
<path class="dg-edge dg-edge--muted" d="M450,453 H496" />
|
||||
<path class="dg-edge" d="M450,523 H496" />
|
||||
|
||||
<!-- Leaves -->
|
||||
<g v-for="r in rows" :key="r.path">
|
||||
<rect
|
||||
class="dg-box"
|
||||
:class="{ 'dg-box--teal dg-box--tint': r.static, 'dg-box--pink': r.admin, 'dg-box--muted': r.bare }"
|
||||
x="500" :y="r.y" width="620" height="46" rx="4"
|
||||
/>
|
||||
<text class="dg-code" x="514" :y="r.y + 19">{{ r.path }}</text>
|
||||
<text class="dg-text" x="634" :y="r.y + 19">{{ r.name }}</text>
|
||||
<text class="dg-code" x="760" :y="r.y + 19" style="fill: var(--color-secondary)">{{ r.file }}</text>
|
||||
<text
|
||||
:class="r.static ? 'dg-text dg-text--mint' : 'dg-small'"
|
||||
x="1106" :y="r.y + 19" text-anchor="end"
|
||||
>{{ r.static ? "STATIC" : "import()" }}</text>
|
||||
<text class="dg-small" x="514" :y="r.y + 37" :style="r.admin ? 'fill: var(--color-tertiary)' : ''">{{ r.note }}</text>
|
||||
</g>
|
||||
|
||||
<!-- Column heads -->
|
||||
<text class="dg-small" x="514" y="12">path</text>
|
||||
<text class="dg-small" x="634" y="12">name (a contract)</text>
|
||||
<text class="dg-small" x="760" y="12">component</text>
|
||||
|
||||
<!-- Legend -->
|
||||
<rect class="dg-box dg-box--teal dg-box--tint" x="20" y="586" width="30" height="18" rx="3" />
|
||||
<text class="dg-small" x="58" y="599">in the entry bundle (first paint)</text>
|
||||
<rect class="dg-box" x="270" y="586" width="30" height="18" rx="3" />
|
||||
<text class="dg-small" x="308" y="599">dynamic import(): its own Vite chunk</text>
|
||||
<rect class="dg-box dg-box--pink" x="540" y="586" width="30" height="18" rx="3" />
|
||||
<text class="dg-small" x="578" y="599">guarded by meta.requiresAdmin</text>
|
||||
<rect class="dg-box dg-box--muted" x="790" y="586" width="30" height="18" rx="3" />
|
||||
<text class="dg-small" x="828" y="599">outside both layouts</text>
|
||||
<text class="dg-small" x="20" y="628">Vue Router ranks the catch-all below every static path, so a static route always wins over a canvas page at the same address.</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
<code>App.vue</code> is an empty <code><RouterView /></code>; all chrome lives in the
|
||||
layouts the router mounts. Only <code>Landing.vue</code> is imported statically, because it is
|
||||
the first paint, and even it pulls <code>BoxCanvas</code> in as a separate chunk. Every other view
|
||||
is a dynamic <code>import()</code>. Pages made in the browser have no entry here: the catch-all
|
||||
looks the path up as a <code>Page</code>, which is why the backend's <code>validateSlug</code>
|
||||
refuses slugs whose first segment a static route or nginx already answers. Route
|
||||
<code>name</code>s are used by <code>RouterLink</code> and <code>router.push</code>, and
|
||||
<code>Login.vue</code> checks for the name <code>"404"</code>, so renaming one breaks links.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
|
||||
const rows = [
|
||||
{ y: 20, path: "/", name: "landing", file: "views/landing/Landing.vue", static: true,
|
||||
note: "BoxCanvas page=\"index\"; the canvas itself is a defineAsyncComponent chunk" },
|
||||
{ y: 76, path: "/stp", name: "home", file: "views/home3/Home3.vue",
|
||||
note: "BoxCanvas page=\"stp\" with the defaultLayout.js starter" },
|
||||
{ y: 132, path: "/admin/login", name: "admin-login", file: "views/admin/Login.vue",
|
||||
note: "not guarded: calls auth.ensureLoaded() itself for its \"Already signed in\" card" },
|
||||
{ y: 188, path: "/admin", name: "admin", file: "views/admin/Admin.vue", admin: true,
|
||||
note: "meta: { requiresAdmin: true }, the only flag the beforeEach guard acts on" },
|
||||
{ y: 244, path: "/automata", name: "mobile-automata", file: "views/automata/MobileAutomata.vue",
|
||||
note: "Turing machine / mobile automaton drawn to a <canvas>" },
|
||||
{ y: 300, path: "/hotels", name: "cheap-hotels", file: "views/hotels/CheapHotels.vue",
|
||||
note: "Travelodge price scanner over /py/hotels (NDJSON streams via fetch)" },
|
||||
{ y: 356, path: "/:pathMatch(.*)*", name: "404", file: "views/canvas/CanvasPage.vue",
|
||||
note: "any other path: query page(slug) → BoxCanvas for that slug, else the 404 view" },
|
||||
{ y: 430, path: "/stp2", name: "home2", file: "views/home2/Home2.vue", bare: true,
|
||||
note: "static full-bleed CSS mock: no navbar, no footer, unlinked" },
|
||||
{ y: 500, path: "/cv", name: "cv", file: "views/CV/CV.vue",
|
||||
note: "template picker + Print; Jobs button leaves the SPA for /jobs/" },
|
||||
];
|
||||
</script>
|
||||
@@ -0,0 +1,296 @@
|
||||
<!--
|
||||
The big picture: every container docker-compose.yml runs on stpvm, grouped
|
||||
by role, and who talks to whom. Reflects docker-compose.yml (services,
|
||||
networks, ports, network_mode, ipv4_address, aliases, environment URLs),
|
||||
nginx/nginx_routes.conf.template (the `set $upstream_*` targets and their
|
||||
locations), nginx/nginx.conf.template (/v2/ on the apex), DEPLOYMENT.md §1
|
||||
and gitea-runner/run.sh. Re-check when a service is added or removed, a
|
||||
route moves, or a port is published.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="infra-host-overview" title="Every container on stpvm, and who talks to whom" :min-width="840">
|
||||
<svg class="dg" viewBox="0 0 1200 920" role="img" aria-labelledby="infra-host-overview-t">
|
||||
<title id="infra-host-overview-t">
|
||||
Twenty containers on one host: nginx fans requests out to twelve services; backend, gitea and the trackers
|
||||
share one Postgres; garage holds uploads; the CI runner and two socket-holding containers sit off the network.
|
||||
</title>
|
||||
|
||||
<!-- ===== Outside the host ===== -->
|
||||
<text class="dg-group-label" x="16" y="56">INTERNET</text>
|
||||
<rect class="dg-box dg-box--pink" x="16" y="76" width="150" height="66" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="91" y="102" text-anchor="middle">CLOUDFLARE</text>
|
||||
<text class="dg-small" x="91" y="120" text-anchor="middle">edge · tunnel</text>
|
||||
<text class="dg-small" x="91" y="134" text-anchor="middle">DNS API</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="16" y="220" width="150" height="56" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="91" y="245" text-anchor="middle">VISITOR</text>
|
||||
<text class="dg-small" x="91" y="263" text-anchor="middle">browser</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="16" y="546" width="150" height="56" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="91" y="571" text-anchor="middle">LET'S ENCRYPT</text>
|
||||
<text class="dg-small" x="91" y="589" text-anchor="middle">ACME CA</text>
|
||||
|
||||
<!-- ===== Host ===== -->
|
||||
<rect class="dg-group dg-group--pink" x="186" y="16" width="998" height="846" rx="8" />
|
||||
<text class="dg-group-label" x="200" y="36" style="fill: var(--color-tertiary)">HOST · STPVM — X86-64 UBUNTU VM</text>
|
||||
|
||||
<rect class="dg-group dg-group--fill" x="200" y="46" width="800" height="800" rx="6" />
|
||||
<text class="dg-group-label" x="214" y="64">APP-NETWORK · BRIDGE 172.28.0.0/16</text>
|
||||
|
||||
<!-- ---- Column A: the edge ---- -->
|
||||
<rect class="dg-box" x="216" y="76" width="160" height="66" rx="4" />
|
||||
<text class="dg-title" x="296" y="100" text-anchor="middle">CLOUDFLARED</text>
|
||||
<text class="dg-code" x="296" y="117" text-anchor="middle">172.28.255.250</text>
|
||||
<text class="dg-small" x="296" y="133" text-anchor="middle">dials out, no ports</text>
|
||||
|
||||
<rect class="dg-box dg-box--teal dg-box--tint" x="216" y="176" width="160" height="232" rx="4" />
|
||||
<text class="dg-title dg-title--lg" x="296" y="204" text-anchor="middle">NGINX</text>
|
||||
<text class="dg-code" x="296" y="224" text-anchor="middle">:80 :443 → host</text>
|
||||
<text class="dg-text" x="296" y="245" text-anchor="middle">TLS · SPA · proxy</text>
|
||||
<line class="dg-rule" x1="226" y1="258" x2="366" y2="258" />
|
||||
<text class="dg-small" x="296" y="276" text-anchor="middle">network aliases</text>
|
||||
<text class="dg-code" x="296" y="293" text-anchor="middle">DOMAIN</text>
|
||||
<text class="dg-code" x="296" y="309" text-anchor="middle">www.DOMAIN</text>
|
||||
<line class="dg-rule" x1="226" y1="322" x2="366" y2="322" />
|
||||
<text class="dg-small" x="296" y="340" text-anchor="middle">auth_request on admin</text>
|
||||
<text class="dg-small" x="296" y="354" text-anchor="middle">routes → backend</text>
|
||||
<text class="dg-code" x="296" y="370" text-anchor="middle">/auth/validate-admin</text>
|
||||
<text class="dg-small" x="296" y="394" text-anchor="middle">label autoheal=true</text>
|
||||
|
||||
<rect class="dg-box" x="216" y="444" width="160" height="56" rx="4" />
|
||||
<text class="dg-title" x="296" y="468" text-anchor="middle">VUE</text>
|
||||
<text class="dg-small" x="296" y="486" text-anchor="middle">one-shot vite build, exits 0</text>
|
||||
|
||||
<rect class="dg-box" x="216" y="540" width="160" height="66" rx="4" />
|
||||
<text class="dg-title" x="296" y="564" text-anchor="middle">CERTBOT</text>
|
||||
<text class="dg-small" x="296" y="581" text-anchor="middle">certonly, then renew</text>
|
||||
<text class="dg-small" x="296" y="595" text-anchor="middle">every 12h</text>
|
||||
|
||||
<rect class="dg-box dg-box--muted" x="216" y="640" width="160" height="70" rx="4" />
|
||||
<text class="dg-small" x="296" y="662" text-anchor="middle">nginx and certbot share</text>
|
||||
<text class="dg-code" x="296" y="680" text-anchor="middle">./certbot/conf</text>
|
||||
<text class="dg-code" x="296" y="697" text-anchor="middle">./certbot/www</text>
|
||||
|
||||
<!-- ingress edges -->
|
||||
<path class="dg-edge dg-edge--pink dg-edge--flow" d="M91,220 V146" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="98" y="190">HTTPS</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M166,109 H212" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="190" y="101" text-anchor="middle">tunnel</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M296,142 V172" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="302" y="162">https://www.DOMAIN</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M166,248 H212" />
|
||||
<text class="dg-edge-label" x="190" y="240" text-anchor="middle">direct</text>
|
||||
<path class="dg-edge dg-edge--green" d="M296,444 V412" />
|
||||
<text class="dg-edge-label" x="302" y="432">vue_dist</text>
|
||||
<path class="dg-edge dg-edge--muted" d="M216,573 H170" />
|
||||
<text class="dg-edge-label" x="191" y="565" text-anchor="middle">ACME</text>
|
||||
|
||||
<!-- ---- The proxy trunk ---- -->
|
||||
<path class="dg-edge dg-edge--plain" d="M376,292 H400" />
|
||||
<line class="dg-edge dg-edge--plain" x1="400" y1="92" x2="400" y2="812" />
|
||||
|
||||
<!-- ---- Column C: everything nginx proxies to ---- -->
|
||||
<g>
|
||||
<rect class="dg-box dg-box--tint" x="480" y="60" width="180" height="64" rx="4" />
|
||||
<text class="dg-title" x="570" y="82" text-anchor="middle">BACKEND</text>
|
||||
<text class="dg-code" x="570" y="99" text-anchor="middle">:8080 · Go / Gin</text>
|
||||
<text class="dg-small" x="570" y="115" text-anchor="middle">GraphQL + REST</text>
|
||||
<path class="dg-edge" d="M400,92 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="85" text-anchor="middle">/api/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="150" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="170" text-anchor="middle">PYTHON</text>
|
||||
<text class="dg-code" x="570" y="187" text-anchor="middle">:8000 · FastAPI</text>
|
||||
<path class="dg-edge" d="M400,173 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="166" text-anchor="middle">/py/</text>
|
||||
<path class="dg-edge" d="M510,124 V146" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="516" y="140">CallPython</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="218" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="238" text-anchor="middle">JOBS</text>
|
||||
<text class="dg-small" x="570" y="255" text-anchor="middle">published image · :8080</text>
|
||||
<path class="dg-edge" d="M400,241 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="234" text-anchor="middle">/jobs/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="280" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="300" text-anchor="middle">ACTIVITY-TRACKER</text>
|
||||
<text class="dg-small" x="570" y="317" text-anchor="middle">published image · :8080</text>
|
||||
<path class="dg-edge" d="M400,303 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="296" text-anchor="middle">/tracker/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="342" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="362" text-anchor="middle">USACO</text>
|
||||
<text class="dg-small" x="570" y="379" text-anchor="middle">published image · :8080</text>
|
||||
<path class="dg-edge" d="M400,365 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="358" text-anchor="middle">/usaco/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box dg-box--tint" x="480" y="414" width="180" height="56" rx="4" />
|
||||
<text class="dg-title" x="570" y="434" text-anchor="middle">GITEA</text>
|
||||
<text class="dg-code" x="570" y="451" text-anchor="middle">:3000 http · :2222 ssh</text>
|
||||
<text class="dg-small" x="570" y="465" text-anchor="middle" style="fill: var(--color-tertiary)">both published</text>
|
||||
<path class="dg-edge" d="M400,437 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="430" text-anchor="middle">/gitea/</text>
|
||||
<path class="dg-edge dg-edge--green dg-edge--both-green" d="M520,392 V410" />
|
||||
<text class="dg-edge-label" x="528" y="405">clone · push webhook</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="490" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="510" text-anchor="middle">ICECAST2</text>
|
||||
<text class="dg-small" x="570" y="527" text-anchor="middle">+ liquidsoap · harbor 8001 published</text>
|
||||
<path class="dg-edge" d="M400,513 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="506" text-anchor="middle">/radio/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="552" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="572" text-anchor="middle">SILVERBULLET</text>
|
||||
<text class="dg-small" x="570" y="589" text-anchor="middle">editor · vault read-write</text>
|
||||
<path class="dg-edge" d="M400,575 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="568" text-anchor="middle">/sb/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="614" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="634" text-anchor="middle">SILVERBULLET-PUBLIC</text>
|
||||
<text class="dg-small" x="570" y="651" text-anchor="middle">public · vault read-only</text>
|
||||
<path class="dg-edge" d="M400,637 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="630" text-anchor="middle">/notes/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="676" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="696" text-anchor="middle">GARAGE-WEBUI</text>
|
||||
<text class="dg-code" x="570" y="713" text-anchor="middle">:3909</text>
|
||||
<path class="dg-edge" d="M400,699 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="692" text-anchor="middle">/garage/</text>
|
||||
</g>
|
||||
<g>
|
||||
<rect class="dg-box" x="480" y="738" width="180" height="46" rx="4" />
|
||||
<text class="dg-title" x="570" y="758" text-anchor="middle">DOZZLE</text>
|
||||
<text class="dg-small" x="570" y="775" text-anchor="middle">:8080 · docker.sock :ro</text>
|
||||
<path class="dg-edge" d="M400,761 H476" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="440" y="754" text-anchor="middle">/dozzle/</text>
|
||||
</g>
|
||||
<!-- /uploads/ passes under column C straight to garage's website port -->
|
||||
<path class="dg-edge" d="M400,812 H736" />
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="570" y="805" text-anchor="middle">/uploads/ → :3902 (then the uploads volume)</text>
|
||||
|
||||
<!-- ---- Column D: state ---- -->
|
||||
<rect class="dg-box dg-box--deep" x="740" y="96" width="200" height="380" rx="4" style="stroke: var(--color-secondary)" />
|
||||
<text class="dg-title" x="840" y="122" text-anchor="middle" style="fill: var(--color-secondary)">DB · POSTGRES:16</text>
|
||||
<text class="dg-small" x="840" y="138" text-anchor="middle">one instance, four databases</text>
|
||||
<line class="dg-rule" x1="750" y1="146" x2="930" y2="146" />
|
||||
<rect class="dg-band" x="742" y="226" width="196" height="30" />
|
||||
<text class="dg-code" x="756" y="245">jobs</text>
|
||||
<text class="dg-small" x="924" y="245" text-anchor="end">own role</text>
|
||||
<rect class="dg-band" x="742" y="288" width="196" height="30" />
|
||||
<text class="dg-code" x="756" y="307">tracker</text>
|
||||
<text class="dg-small" x="924" y="307" text-anchor="end">own role</text>
|
||||
<rect class="dg-band" x="742" y="422" width="196" height="30" />
|
||||
<text class="dg-code" x="756" y="441">gitea</text>
|
||||
<text class="dg-small" x="924" y="441" text-anchor="end">made by hand</text>
|
||||
<rect class="dg-band" x="742" y="160" width="196" height="30" />
|
||||
<text class="dg-code" x="756" y="179">POSTGRES_DB (site)</text>
|
||||
<text class="dg-small" x="840" y="368" text-anchor="middle">healthcheck pg_isready</text>
|
||||
<text class="dg-small" x="840" y="383" text-anchor="middle">volume dbdata</text>
|
||||
|
||||
<!-- database edges (green = data) -->
|
||||
<path class="dg-edge dg-edge--green" d="M660,108 H700 V175 H736" />
|
||||
<path class="dg-edge dg-edge--green" d="M660,241 H736" />
|
||||
<path class="dg-edge dg-edge--green" d="M660,303 H736" />
|
||||
<path class="dg-edge dg-edge--green" d="M660,437 H736" />
|
||||
|
||||
<rect class="dg-box" x="740" y="540" width="200" height="60" rx="4" />
|
||||
<text class="dg-title" x="840" y="562" text-anchor="middle">SILVERBULLET-GIT</text>
|
||||
<text class="dg-small" x="840" y="578" text-anchor="middle">commit · pull --rebase · push</text>
|
||||
<text class="dg-small" x="840" y="592" text-anchor="middle">every 300s, vault = notes repo</text>
|
||||
<path class="dg-edge dg-edge--green dg-edge--dashed" d="M740,570 H700 V456 H664" />
|
||||
<text class="dg-edge-label" x="706" y="520">ssh</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="740" y="676" width="200" height="154" rx="4" style="stroke: var(--color-secondary)" />
|
||||
<text class="dg-title" x="840" y="700" text-anchor="middle" style="fill: var(--color-secondary)">GARAGE</text>
|
||||
<text class="dg-small" x="840" y="716" text-anchor="middle">S3 object store</text>
|
||||
<text class="dg-code" x="756" y="740">:3900 S3 API</text>
|
||||
<text class="dg-code" x="756" y="760">:3903 admin API</text>
|
||||
<text class="dg-code" x="756" y="816">:3902 website</text>
|
||||
<text class="dg-small" x="924" y="760" text-anchor="end">← webui</text>
|
||||
<text class="dg-small" x="924" y="740" text-anchor="end">← backend</text>
|
||||
<path class="dg-edge dg-edge--green" d="M660,699 H700 V756 H736" />
|
||||
|
||||
<!-- backend → garage over S3, round the right of the db -->
|
||||
<path class="dg-edge dg-edge--green" d="M660,74 H970 V736 H944" />
|
||||
<text class="dg-edge-label" x="820" y="68" text-anchor="middle">S3 PUT · S3_ENDPOINT=http://garage:3900</text>
|
||||
|
||||
<!-- ---- Column E: host level, off the network ---- -->
|
||||
<rect class="dg-group dg-group--pink" x="1014" y="60" width="158" height="210" rx="6" />
|
||||
<text class="dg-group-label" x="1024" y="80" style="fill: var(--color-tertiary)">NETWORK_MODE: NONE</text>
|
||||
<rect class="dg-box" x="1024" y="92" width="138" height="62" rx="4" />
|
||||
<text class="dg-title" x="1093" y="114" text-anchor="middle">TRAFFIC</text>
|
||||
<text class="dg-small" x="1093" y="130" text-anchor="middle">tail -F the nginx</text>
|
||||
<text class="dg-small" x="1093" y="144" text-anchor="middle">payload log</text>
|
||||
<rect class="dg-box dg-box--pink" x="1024" y="172" width="138" height="86" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="1093" y="194" text-anchor="middle">AUTOHEAL</text>
|
||||
<text class="dg-small" x="1093" y="210" text-anchor="middle">restarts containers</text>
|
||||
<text class="dg-small" x="1093" y="224" text-anchor="middle">labelled autoheal</text>
|
||||
<text class="dg-small" x="1093" y="238" text-anchor="middle">pinned by digest</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink dg-box--deep" x="1014" y="310" width="158" height="46" rx="4" />
|
||||
<text class="dg-code" x="1093" y="338" text-anchor="middle">/var/run/docker.sock</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M1093,258 V306" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="1099" y="288">rw</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="1014" y="400" width="158" height="104" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="1093" y="422" text-anchor="middle">ACT_RUNNER</text>
|
||||
<text class="dg-small" x="1093" y="439" text-anchor="middle">outside Docker, host mode</text>
|
||||
<text class="dg-code" x="1093" y="457" text-anchor="middle">gitea-runner/run.sh</text>
|
||||
<text class="dg-small" x="1093" y="475" text-anchor="middle">polls localhost:3000,</text>
|
||||
<text class="dg-small" x="1093" y="489" text-anchor="middle">runs docker compose</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M1093,400 V360" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="1099" y="384">compose up</text>
|
||||
|
||||
<!-- published ports table -->
|
||||
<rect class="dg-box dg-box--deep" x="1014" y="548" width="158" height="164" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="1093" y="568" text-anchor="middle">PUBLISHED TO HOST</text>
|
||||
<line class="dg-rule" x1="1022" y1="578" x2="1164" y2="578" />
|
||||
<text class="dg-code" x="1024" y="598">80, 443</text>
|
||||
<text class="dg-small" x="1162" y="598" text-anchor="end">nginx</text>
|
||||
<text class="dg-code" x="1024" y="620">3000</text>
|
||||
<text class="dg-small" x="1162" y="620" text-anchor="end">gitea http</text>
|
||||
<text class="dg-code" x="1024" y="642">2222</text>
|
||||
<text class="dg-small" x="1162" y="642" text-anchor="end">gitea ssh</text>
|
||||
<text class="dg-code" x="1024" y="664">8001</text>
|
||||
<text class="dg-small" x="1162" y="664" text-anchor="end">liquidsoap harbor</text>
|
||||
<text class="dg-small" x="1093" y="694" text-anchor="middle">all else: app-network only</text>
|
||||
|
||||
<!-- legend -->
|
||||
<g transform="translate(200,886)">
|
||||
<line class="dg-edge dg-edge--plain" x1="0" y1="0" x2="34" y2="0" />
|
||||
<text class="dg-small" x="42" y="4">request path (proxied)</text>
|
||||
<line class="dg-edge dg-edge--green dg-edge--plain" x1="200" y1="0" x2="234" y2="0" />
|
||||
<text class="dg-small" x="242" y="4">data: SQL, S3, git</text>
|
||||
<line class="dg-edge dg-edge--pink dg-edge--plain" x1="380" y1="0" x2="414" y2="0" />
|
||||
<text class="dg-small" x="422" y="4">visitor / host control</text>
|
||||
<line class="dg-edge dg-edge--muted dg-edge--dashed dg-edge--plain" x1="570" y1="0" x2="604" y2="0" />
|
||||
<text class="dg-small" x="612" y="4">optional path</text>
|
||||
<line class="dg-edge dg-edge--flow dg-edge--plain" x1="720" y1="0" x2="754" y2="0" />
|
||||
<text class="dg-small" x="762" y="4">the live ingress (tunnel)</text>
|
||||
</g>
|
||||
</svg>
|
||||
<template #caption>
|
||||
Twenty containers on one bridge network, <code>app-network</code>, plus the CI runner on the host itself.
|
||||
Requests come in through the Cloudflare tunnel (<code>cloudflared</code> dials out, so nothing has to be
|
||||
forwarded) or directly on 80/443. Either way they land on <strong>nginx</strong>, the only thing that sees the
|
||||
internet, which fans them out by path prefix to twelve upstreams it finds by container name. Behind it,
|
||||
<code>backend</code>, <code>gitea</code>, <code>jobs</code> and <code>activity-tracker</code> share one
|
||||
Postgres with a database each. Only four ports are published: 80/443 for nginx, 3000/2222 for Gitea (the runner and
|
||||
git clients need them), and liquidsoap's harbor for live DJs. The two containers that hold the Docker socket
|
||||
read-write (<code>autoheal</code>) or tail a file (<code>traffic</code>) get no network at all.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!--
|
||||
Reference example for the diagram kit. Not used on the page.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="example" title="Example: a request through two services">
|
||||
<svg class="dg" viewBox="0 0 760 260" role="img" aria-labelledby="ex-t">
|
||||
<title id="ex-t">Browser to nginx to backend, with a database</title>
|
||||
<rect class="dg-group dg-group--fill" x="200" y="20" width="540" height="220" rx="6" />
|
||||
<text class="dg-group-label" x="214" y="40">DOCKER NETWORK · app-network</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="20" y="100" width="130" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="85" y="126" text-anchor="middle">BROWSER</text>
|
||||
<text class="dg-small" x="85" y="144" text-anchor="middle">visitor</text>
|
||||
|
||||
<rect class="dg-box" x="240" y="100" width="150" height="60" rx="4" />
|
||||
<text class="dg-title" x="315" y="126" text-anchor="middle">NGINX</text>
|
||||
<text class="dg-code" x="315" y="144" text-anchor="middle">:80 / :443</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="470" y="70" width="230" height="120" rx="4" />
|
||||
<text class="dg-title" x="585" y="96" text-anchor="middle">BACKEND</text>
|
||||
<text class="dg-text" x="490" y="122">Gin router</text>
|
||||
<line class="dg-rule" x1="480" y1="132" x2="690" y2="132" />
|
||||
<text class="dg-code" x="490" y="152">POST /api/graphql</text>
|
||||
<text class="dg-code" x="490" y="172">GET /api/ws</text>
|
||||
|
||||
<path class="dg-edge dg-edge--pink" d="M150,130 H236" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="193" y="122" text-anchor="middle">HTTPS</text>
|
||||
<path class="dg-edge dg-edge--flow" d="M390,130 H466" />
|
||||
<text class="dg-edge-label" x="428" y="122" text-anchor="middle">proxy</text>
|
||||
|
||||
<circle class="dg-badge" cx="240" cy="100" r="10" />
|
||||
<text class="dg-badge-text" x="240" y="100">1</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
Captions explain what the picture shows and why it is that way, with
|
||||
<code>code</code> names where they help.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,125 @@
|
||||
<!--
|
||||
The Python API's route map: which /py/ paths nginx proxies (and how), the
|
||||
public routes FastAPI serves after the prefix strip, the one internal route
|
||||
and its two locks, and which module each route hands work to.
|
||||
Reflects: nginx/nginx_routes.conf.template (the /py locations),
|
||||
python/app/main.py (routes, _internal_only, _internal_claude_route),
|
||||
python/app/{travelodge,rowing,claude}.py, docker-compose.yml (python service),
|
||||
backend/services/python_call.go.
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="services-python-route-map" title="The Python API: routes, prefix strip and the internal door" :min-width="790">
|
||||
<svg class="dg" viewBox="0 0 1120 560" role="img" aria-labelledby="services-python-route-map-t">
|
||||
<title id="services-python-route-map-t">nginx proxies /py/ to FastAPI with the prefix stripped; /py/internal/ is a 404 at nginx, and the internal rowing route is only reachable by the Go backend directly</title>
|
||||
|
||||
<!-- Callers -->
|
||||
<rect class="dg-box dg-box--pink" x="20" y="90" width="150" height="60" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="95" y="116" text-anchor="middle">BROWSER</text>
|
||||
<text class="dg-small" x="95" y="134" text-anchor="middle">/hotels page, /py/docs</text>
|
||||
|
||||
<rect class="dg-box dg-box--green" x="20" y="440" width="170" height="70" rx="4" />
|
||||
<text class="dg-title" x="105" y="466" text-anchor="middle">GO BACKEND</text>
|
||||
<text class="dg-code" x="105" y="484" text-anchor="middle">CreateRowing</text>
|
||||
<text class="dg-small" x="105" y="500" text-anchor="middle">admin-only POST /api/rowing</text>
|
||||
|
||||
<!-- nginx -->
|
||||
<rect class="dg-box" x="220" y="50" width="300" height="350" rx="4" />
|
||||
<text class="dg-title" x="370" y="76" text-anchor="middle">NGINX</text>
|
||||
<text class="dg-small" x="370" y="94" text-anchor="middle">nginx_routes.conf.template</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="234" y="110" width="272" height="62" rx="3" />
|
||||
<text class="dg-code" x="246" y="130">~ ^/py/hotels/(search|scan)</text>
|
||||
<text class="dg-small" x="246" y="148">zone hotel_search 3r/m, burst 2</text>
|
||||
<text class="dg-small" x="246" y="164">proxy_buffering off · read 300s</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink dg-box--tint" x="234" y="188" width="272" height="54" rx="3" />
|
||||
<text class="dg-code" x="246" y="208">^~ /py/internal/</text>
|
||||
<text class="dg-text dg-text--pink" x="246" y="228">return 404 (never proxied)</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="234" y="258" width="272" height="48" rx="3" />
|
||||
<text class="dg-code" x="246" y="278">/py/</text>
|
||||
<text class="dg-small" x="246" y="296">zone api 30r/s, burst 20 · read 300s</text>
|
||||
|
||||
<line class="dg-rule" x1="234" y1="324" x2="506" y2="324" />
|
||||
<text class="dg-small" x="246" y="344">both proxied blocks:</text>
|
||||
<text class="dg-code" x="246" y="362">rewrite ^/py/(.*)$ /$1 break</text>
|
||||
<text class="dg-small" x="246" y="382">sets X-Real-IP, X-Forwarded-For</text>
|
||||
|
||||
<path class="dg-edge dg-edge--pink" d="M170,120 H195 V141 H230" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="176" y="112">/py/…</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M195,141 V214 H230" />
|
||||
<path class="dg-edge dg-edge--pink" d="M195,214 V282 H230" />
|
||||
|
||||
<!-- Python container -->
|
||||
<rect class="dg-group dg-group--fill" x="560" y="40" width="320" height="400" rx="6" />
|
||||
<text class="dg-group-label" x="574" y="62">CONTAINER · python</text>
|
||||
<text class="dg-code" x="574" y="82">uvicorn :8000 --root-path /py</text>
|
||||
|
||||
<rect class="dg-box" x="574" y="96" width="292" height="196" rx="3" />
|
||||
<text class="dg-text dg-text--mint" x="588" y="116">PUBLIC (written relative to /)</text>
|
||||
<text class="dg-code" x="588" y="138">GET / · /health · /hello/{name}</text>
|
||||
<text class="dg-code" x="588" y="158">GET /docs · /openapi.json</text>
|
||||
<text class="dg-code" x="588" y="178">GET /hotels/origins</text>
|
||||
<line class="dg-rule" x1="584" y1="190" x2="856" y2="190" />
|
||||
<text class="dg-code" x="588" y="210">POST /hotels/search</text>
|
||||
<text class="dg-small" x="588" y="226">blocking: 429 busy, 502 upstream</text>
|
||||
<text class="dg-code" x="588" y="248">POST /hotels/search/stream</text>
|
||||
<text class="dg-code" x="588" y="268">POST /hotels/scan/stream</text>
|
||||
<text class="dg-small" x="588" y="284">NDJSON, always 200</text>
|
||||
|
||||
<rect class="dg-box dg-box--pink" x="574" y="310" width="292" height="116" rx="3" />
|
||||
<text class="dg-text dg-text--pink" x="588" y="330">INTERNAL · _internal_claude_route</text>
|
||||
<text class="dg-code" x="588" y="352">POST /internal/rowing/read</text>
|
||||
<text class="dg-small" x="588" y="372">Depends(_internal_only): 404 if the request</text>
|
||||
<text class="dg-small" x="588" y="388">carries X-Real-IP or X-Forwarded-For</text>
|
||||
<text class="dg-small" x="588" y="410">ReadError → 502 · NotConfigured → 503</text>
|
||||
|
||||
<path class="dg-edge" d="M506,141 H570" />
|
||||
<path class="dg-edge" d="M506,282 H540 V160 H570" />
|
||||
|
||||
<!-- Backend direct call -->
|
||||
<path class="dg-edge dg-edge--green dg-edge--flow" d="M190,475 H545 V380 H570" />
|
||||
<text class="dg-edge-label" x="370" y="466" text-anchor="middle">services.CallPython → http://python:8000 (no proxy headers)</text>
|
||||
|
||||
<!-- Modules -->
|
||||
<rect class="dg-box dg-box--tint" x="910" y="110" width="190" height="96" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="1005" y="132" text-anchor="middle">TRAVELODGE.PY</text>
|
||||
<text class="dg-small" x="922" y="154">run_search · run_scan</text>
|
||||
<text class="dg-small" x="922" y="172">→ Travelodge /api/v2/hotel</text>
|
||||
<text class="dg-small" x="922" y="190">→ TfL Journey Planner</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="910" y="300" width="190" height="50" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="1005" y="322" text-anchor="middle">ROWING.PY</text>
|
||||
<text class="dg-code" x="1005" y="340" text-anchor="middle">read_display</text>
|
||||
|
||||
<rect class="dg-box dg-box--tint" x="910" y="380" width="190" height="62" rx="4" />
|
||||
<text class="dg-title dg-title--sm" x="1005" y="402" text-anchor="middle">CLAUDE.PY</text>
|
||||
<text class="dg-code" x="1005" y="420" text-anchor="middle">ask_json</text>
|
||||
<text class="dg-small" x="1005" y="436" text-anchor="middle">model = CLAUDE_MODEL</text>
|
||||
|
||||
<rect class="dg-box dg-box--muted" x="910" y="474" width="190" height="44" rx="4" />
|
||||
<text class="dg-text" x="1005" y="501" text-anchor="middle">Anthropic Messages API</text>
|
||||
|
||||
<path class="dg-edge" d="M866,230 H888 V158 H906" />
|
||||
<path class="dg-edge dg-edge--pink" d="M866,352 H888 V325 H906" />
|
||||
<path class="dg-edge dg-edge--pink" d="M1005,350 V376" />
|
||||
<path class="dg-edge dg-edge--pink" d="M1005,442 V470" />
|
||||
<text class="dg-small" x="910" y="546">none of the three modules imports FastAPI</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
nginx strips <code>/py</code> with <code>rewrite ^/py/(.*)$ /$1 break</code>, so FastAPI's
|
||||
routes are written relative to <code>/</code> and <code>--root-path /py</code> only exists to
|
||||
keep <code>/py/docs</code> pointing at the right OpenAPI URL. The hotel streams get their own
|
||||
location because nginx would otherwise buffer the whole NDJSON response. The pink route spends
|
||||
a paid Claude call and has no auth of its own, so it has two locks: nginx answers
|
||||
<code>/py/internal/</code> with a 404, and <code>_internal_only</code> 404s anything carrying
|
||||
the <code>X-Real-IP</code>/<code>X-Forwarded-For</code> headers nginx always adds. The Go
|
||||
backend (green) calls the container directly and sends neither. The guard is a dependency, so
|
||||
a request from outside gets the 404 before its body is validated.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,134 @@
|
||||
<!--
|
||||
The rowing photo reader end to end, as a sequence: the admin's upload, the Go
|
||||
handler's checks, the direct Go→Python call, how claude.py shapes the request
|
||||
for the configured model, and the sanity bounds before the insert.
|
||||
Reflects: vue/src/views/admin/CreateRowing.vue, backend/main.go (admin group),
|
||||
backend/handlers/handle_rowing.go, backend/services/python_call.go,
|
||||
python/app/main.py (rowing_read, _internal_only, _claude_failed),
|
||||
python/app/rowing.py, python/app/claude.py (MODEL, _model_options, ask_json).
|
||||
-->
|
||||
<template>
|
||||
<DiagramFigure id="services-rowing-claude-call" title="Reading a rowing display: browser to Claude and back" :min-width="790">
|
||||
<svg class="dg" viewBox="0 0 1120 770" role="img" aria-labelledby="services-rowing-claude-call-t">
|
||||
<title id="services-rowing-claude-call-t">Sequence of the admin rowing upload through nginx, the Go backend, Postgres, the Python service and the Claude API</title>
|
||||
|
||||
<!-- Lifeline heads -->
|
||||
<rect class="dg-box dg-box--pink" x="15" y="20" width="130" height="50" rx="4" />
|
||||
<text class="dg-title dg-title--pink" x="80" y="42" text-anchor="middle">BROWSER</text>
|
||||
<text class="dg-code" x="80" y="60" text-anchor="middle">CreateRowing.vue</text>
|
||||
<rect class="dg-box" x="185" y="20" width="130" height="50" rx="4" />
|
||||
<text class="dg-title" x="250" y="42" text-anchor="middle">NGINX</text>
|
||||
<text class="dg-code" x="250" y="60" text-anchor="middle">/api/ location</text>
|
||||
<rect class="dg-box dg-box--green" x="355" y="20" width="150" height="50" rx="4" />
|
||||
<text class="dg-title" x="430" y="42" text-anchor="middle">GO BACKEND</text>
|
||||
<text class="dg-code" x="430" y="60" text-anchor="middle">CreateRowing</text>
|
||||
<rect class="dg-box" x="535" y="20" width="130" height="50" rx="4" />
|
||||
<text class="dg-title" x="600" y="42" text-anchor="middle">POSTGRES</text>
|
||||
<text class="dg-code" x="600" y="60" text-anchor="middle">models.Rowing</text>
|
||||
<rect class="dg-box dg-box--teal" x="720" y="20" width="140" height="50" rx="4" />
|
||||
<text class="dg-title" x="790" y="42" text-anchor="middle">PYTHON</text>
|
||||
<text class="dg-code" x="790" y="60" text-anchor="middle">rowing_read</text>
|
||||
<rect class="dg-box dg-box--muted" x="935" y="20" width="150" height="50" rx="4" />
|
||||
<text class="dg-title" x="1010" y="42" text-anchor="middle">CLAUDE API</text>
|
||||
<text class="dg-code" x="1010" y="60" text-anchor="middle">messages.create</text>
|
||||
|
||||
<line class="dg-lifeline" x1="80" y1="70" x2="80" y2="750" />
|
||||
<line class="dg-lifeline" x1="250" y1="70" x2="250" y2="750" />
|
||||
<line class="dg-lifeline" x1="430" y1="70" x2="430" y2="750" />
|
||||
<line class="dg-lifeline" x1="600" y1="70" x2="600" y2="750" />
|
||||
<line class="dg-lifeline" x1="790" y1="70" x2="790" y2="750" />
|
||||
<line class="dg-lifeline" x1="1010" y1="70" x2="1010" y2="750" />
|
||||
|
||||
<rect class="dg-activation" x="425" y="150" width="10" height="580" />
|
||||
<rect class="dg-activation" x="785" y="330" width="10" height="282" />
|
||||
<rect class="dg-activation" x="1005" y="458" width="10" height="40" />
|
||||
|
||||
<!-- 1 upload -->
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="165" y="94" text-anchor="middle">POST /api/rowing</text>
|
||||
<text class="dg-edge-label" x="165" y="107" text-anchor="middle">multipart field "image"</text>
|
||||
<path class="dg-edge dg-edge--pink" d="M80,116 H246" />
|
||||
<text class="dg-edge-label" x="340" y="128" text-anchor="middle">POST /rowing</text>
|
||||
<text class="dg-edge-label" x="340" y="141" text-anchor="middle">/api stripped</text>
|
||||
<path class="dg-edge" d="M250,150 H421" />
|
||||
|
||||
<!-- 2 checks -->
|
||||
<rect class="dg-box dg-box--tint" x="445" y="160" width="270" height="74" rx="3" />
|
||||
<text class="dg-small" x="455" y="180">AuthMiddlewear → AdminMiddleware</text>
|
||||
<text class="dg-small" x="455" y="198">exif.Decode → DateTime, else 400</text>
|
||||
<text class="dg-small" x="455" y="216">≤ 10MB · jpeg / png / gif / webp only</text>
|
||||
|
||||
<!-- 3 duplicate -->
|
||||
<text class="dg-edge-label" x="515" y="256" text-anchor="middle">WHERE date = ?</text>
|
||||
<path class="dg-edge" d="M435,264 H596" />
|
||||
<text class="dg-edge-label" x="515" y="284" text-anchor="middle">not found (found → 409)</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M600,292 H439" />
|
||||
|
||||
<!-- 4 call python -->
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="610" y="312" text-anchor="middle">services.CallPython · POST /internal/rowing/read</text>
|
||||
<text class="dg-edge-label" x="610" y="325" text-anchor="middle">{media_type, data: base64} · client timeout 2 min</text>
|
||||
<path class="dg-edge dg-edge--green dg-edge--flow" d="M435,334 H781" />
|
||||
|
||||
<!-- 5 shape request -->
|
||||
<rect class="dg-box dg-box--pink dg-box--tint" x="805" y="344" width="300" height="94" rx="3" />
|
||||
<text class="dg-text dg-text--pink" x="815" y="362">claude._model_options(MODEL, 256)</text>
|
||||
<text class="dg-small" x="815" y="380">MODEL = CLAUDE_MODEL or claude-sonnet-5-5</text>
|
||||
<text class="dg-small" x="815" y="398">claude-haiku-4-5 → max_tokens 256</text>
|
||||
<text class="dg-small" x="815" y="416">any other → max_tokens 256 + 4000,</text>
|
||||
<text class="dg-small" x="815" y="432">output_config.effort "low"</text>
|
||||
|
||||
<!-- 6 create -->
|
||||
<text class="dg-edge-label" x="900" y="455" text-anchor="middle">image block + PROMPT</text>
|
||||
<text class="dg-edge-label" x="900" y="468" text-anchor="middle">30s timeout · 2 SDK retries</text>
|
||||
<path class="dg-edge" d="M795,474 H1001" />
|
||||
<text class="dg-edge-label" x="900" y="496" text-anchor="middle">reply: content blocks</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M1005,504 H799" />
|
||||
|
||||
<!-- 7 parse -->
|
||||
<rect class="dg-box dg-box--tint" x="805" y="516" width="300" height="62" rx="3" />
|
||||
<text class="dg-small" x="815" y="534">first text block → strip_markdown_fence</text>
|
||||
<text class="dg-small" x="815" y="550">→ RowingReading (missing keys = 0)</text>
|
||||
<text class="dg-small" x="815" y="566">refusal / no text / bad JSON → ReadError</text>
|
||||
|
||||
<text class="dg-edge-label dg-edge-label--mint" x="610" y="590" text-anchor="middle">200 {timeMinutes, timeSeconds, distance}</text>
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="610" y="603" text-anchor="middle">or 502 {detail} → *PythonError</text>
|
||||
<path class="dg-edge dg-edge--muted dg-edge--dashed" d="M785,612 H439" />
|
||||
|
||||
<!-- 8 bounds -->
|
||||
<rect class="dg-box dg-box--tint" x="445" y="622" width="270" height="62" rx="3" />
|
||||
<text class="dg-small" x="455" y="640">distance 100–100000 m, time 30–7200 s</text>
|
||||
<text class="dg-small" x="455" y="656">pace 80–150 s per 500 m, else 400</text>
|
||||
<text class="dg-small" x="455" y="672">calories = distance / 7500 × 500</text>
|
||||
|
||||
<!-- 9 insert + reply -->
|
||||
<text class="dg-edge-label" x="515" y="700" text-anchor="middle">INSERT</text>
|
||||
<path class="dg-edge" d="M435,706 H596" />
|
||||
<text class="dg-edge-label dg-edge-label--pink" x="255" y="716" text-anchor="middle">201 rowing · or 500 {error: Python's detail}</text>
|
||||
<path class="dg-edge dg-edge--pink dg-edge--dashed" d="M425,726 H84" />
|
||||
|
||||
<!-- badges -->
|
||||
<circle class="dg-badge" cx="22" cy="116" r="9" /><text class="dg-badge-text" x="22" y="116">1</text>
|
||||
<circle class="dg-badge" cx="22" cy="190" r="9" /><text class="dg-badge-text" x="22" y="190">2</text>
|
||||
<circle class="dg-badge" cx="22" cy="264" r="9" /><text class="dg-badge-text" x="22" y="264">3</text>
|
||||
<circle class="dg-badge" cx="22" cy="334" r="9" /><text class="dg-badge-text" x="22" y="334">4</text>
|
||||
<circle class="dg-badge" cx="22" cy="394" r="9" /><text class="dg-badge-text" x="22" y="394">5</text>
|
||||
<circle class="dg-badge" cx="22" cy="474" r="9" /><text class="dg-badge-text" x="22" y="474">6</text>
|
||||
<circle class="dg-badge" cx="22" cy="548" r="9" /><text class="dg-badge-text" x="22" y="548">7</text>
|
||||
<circle class="dg-badge" cx="22" cy="652" r="9" /><text class="dg-badge-text" x="22" y="652">8</text>
|
||||
<circle class="dg-badge" cx="22" cy="716" r="9" /><text class="dg-badge-text" x="22" y="716">9</text>
|
||||
</svg>
|
||||
<template #caption>
|
||||
Everything that needs the session or the database stays in Go (steps 2, 3, 8, 9); Python
|
||||
only turns pixels into three numbers. The duplicate check (3) runs <em>before</em> the paid call,
|
||||
keyed on the photo's EXIF timestamp, so a re-upload costs nothing. Step 5 is where
|
||||
<code>CLAUDE_MODEL</code> matters: models that think get 4,000 tokens of headroom and
|
||||
<code>effort: "low"</code>, while Haiku 4.5 rejects the effort setting and gets neither. The
|
||||
timeouts nest on purpose: Python's 30s per attempt with two SDK retries sits inside Go's
|
||||
2-minute client, so a slow Claude surfaces as Python's fixed message, which Go relays to the
|
||||
admin only when it came back as a 502.
|
||||
</template>
|
||||
</DiagramFigure>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DiagramFigure from "../../DiagramFigure.vue";
|
||||
</script>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup>
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import RequestLifecycle from "../diagrams/backend/RequestLifecycle.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="backend" class="flex flex-col gap-6">
|
||||
<Header>Go backend</Header>
|
||||
<Paragraph>
|
||||
A Gin server with a GraphQL API at <code>/api/graphql</code> and a
|
||||
handful of REST endpoints. Every request passes through the same
|
||||
middleware chain before it reaches a handler or resolver.
|
||||
</Paragraph>
|
||||
<RequestLifecycle />
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import EntrypointFlow from "../diagrams/edge/EntrypointFlow.vue";
|
||||
import RouteMap from "../diagrams/edge/RouteMap.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="edge" class="flex flex-col gap-6">
|
||||
<Header>The edge: nginx</Header>
|
||||
<Paragraph>
|
||||
Every request enters through nginx. Its config is chosen when the
|
||||
container starts, and one shared routes file decides which
|
||||
container each path is handed to.
|
||||
</Paragraph>
|
||||
<EntrypointFlow />
|
||||
<RouteMap />
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import RouteTree from "../diagrams/frontend/RouteTree.vue";
|
||||
import BootSequence from "../diagrams/frontend/BootSequence.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="frontend" class="flex flex-col gap-6">
|
||||
<Header>Vue frontend</Header>
|
||||
<Paragraph>
|
||||
A Vue 3 single-page app: a small route table with two layout
|
||||
shells, a catch-all that serves admin-made canvas pages, and Pinia
|
||||
stores that load data over GraphQL.
|
||||
</Paragraph>
|
||||
<RouteTree />
|
||||
<BootSequence />
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup>
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import HostOverview from "../diagrams/infra/HostOverview.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="infra" class="flex flex-col gap-6">
|
||||
<Header>Infrastructure & deployment</Header>
|
||||
<Paragraph>
|
||||
The whole site is one Docker Compose stack on a single Ubuntu VM,
|
||||
<code>stpvm</code>. Only nginx (and the Cloudflare tunnel) faces
|
||||
the internet; everything else talks over the internal Docker
|
||||
network.
|
||||
</Paragraph>
|
||||
<HostOverview />
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
import PythonRouteMap from "../diagrams/services/PythonRouteMap.vue";
|
||||
import RowingClaudeCall from "../diagrams/services/RowingClaudeCall.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="services" class="flex flex-col gap-6">
|
||||
<Header>Python & the other services</Header>
|
||||
<Paragraph>
|
||||
The FastAPI service holds the scrapers and the site's one Claude
|
||||
call. Public routes are reached through nginx at
|
||||
<code>/py/</code>; internal ones only from the Go backend.
|
||||
</Paragraph>
|
||||
<PythonRouteMap />
|
||||
<RowingClaudeCall />
|
||||
</section>
|
||||
</template>
|
||||
Reference in New Issue
Block a user