Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
frontend/src/app/architecture/page.tsx
CHANGED
|
@@ -17,11 +17,77 @@ import {
|
|
| 17 |
ShieldCheck,
|
| 18 |
Binary,
|
| 19 |
FileSpreadsheet,
|
| 20 |
-
Copy
|
|
|
|
| 21 |
} from "lucide-react";
|
| 22 |
import MermaidChart from "@/components/MermaidChart";
|
| 23 |
|
| 24 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
subgraph S1["1. RAW TELEMETRY & FILE INGESTION"]
|
| 26 |
CSV["📄 patient_data.csv / batch_upload.csv<br/>(Continuous Vitals Observations)"]
|
| 27 |
AFE["⚡ Physical Biosensors<br/>AD8232 Lead-II ECG (250 Hz) + MAX30102 PPG"]
|
|
@@ -91,6 +157,7 @@ P(\\text{Class}_c \\mid f_c(X)) = \\frac{1}{1 + \\exp(A_c \\cdot f_c(X) + B_c)}`
|
|
| 91 |
export default function Architecture() {
|
| 92 |
const [activeStage, setActiveStage] = useState<number>(1);
|
| 93 |
const [copiedId, setCopiedId] = useState<string | null>(null);
|
|
|
|
| 94 |
|
| 95 |
const handleCopy = (id: string, text: string) => {
|
| 96 |
navigator.clipboard.writeText(text);
|
|
@@ -270,10 +337,20 @@ export default function Architecture() {
|
|
| 270 |
</p>
|
| 271 |
</div>
|
| 272 |
|
| 273 |
-
<div className="flex items-center gap-2 self-start sm:self-auto">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
<button
|
| 275 |
-
onClick={() => handleCopy("mermaid-spec",
|
| 276 |
-
className="btn-tactile text-[11px] font-bold uppercase tracking-wider border-2 border-ink px-3 py-1.5 bg-white hover:bg-ink hover:text-white transition-colors flex items-center gap-1.5"
|
| 277 |
>
|
| 278 |
{copiedId === "mermaid-spec" ? (
|
| 279 |
<>
|
|
@@ -293,8 +370,8 @@ export default function Architecture() {
|
|
| 293 |
{/* PRIMARY VISUAL MERMAID FLOWCHART RENDERER */}
|
| 294 |
<div className="mb-8">
|
| 295 |
<MermaidChart
|
| 296 |
-
chart={
|
| 297 |
-
title=
|
| 298 |
/>
|
| 299 |
</div>
|
| 300 |
|
|
|
|
| 17 |
ShieldCheck,
|
| 18 |
Binary,
|
| 19 |
FileSpreadsheet,
|
| 20 |
+
Copy,
|
| 21 |
+
SlidersHorizontal
|
| 22 |
} from "lucide-react";
|
| 23 |
import MermaidChart from "@/components/MermaidChart";
|
| 24 |
|
| 25 |
+
const MERMAID_PIPELINE_GRAPH_LR = `flowchart LR
|
| 26 |
+
subgraph S1["1. RAW INGESTION"]
|
| 27 |
+
direction TB
|
| 28 |
+
AFE["⚡ AD8232 ECG + MAX30102 PPG"]
|
| 29 |
+
CSV["📄 patient_data.csv (60,000 Records)"]
|
| 30 |
+
MCU["ESP32-S3 Firmware (C99)<br/>12-bit SAR ADC Sampling"]
|
| 31 |
+
SERIAL["W3C navigator.serial (115.2k)<br/>Frame: $HR,SPO2,SYS,DIA,TEMP*CRC"]
|
| 32 |
+
INGEST["backend/main.py & mlops/page.tsx<br/>Schema Ingestion Engine"]
|
| 33 |
+
|
| 34 |
+
AFE --> MCU --> SERIAL --> INGEST
|
| 35 |
+
CSV --> INGEST
|
| 36 |
+
end
|
| 37 |
+
|
| 38 |
+
subgraph S2["2. FEATURE ENGINEERING"]
|
| 39 |
+
direction TB
|
| 40 |
+
LEAKAGE["Target Leakage Protection<br/>Strip alarms, patient_id"]
|
| 41 |
+
DEGREE["Character Encoding Repair<br/>Fix corrupt ISO-8859 (°C)"]
|
| 42 |
+
SYNTH["Risk Severity Synthesis<br/>I(HR > 105) + I(SpO2 < 94)"]
|
| 43 |
+
SCALE["StandardScaler Affine Transform<br/>z_j = (x_j - μ_j) / σ_j"]
|
| 44 |
+
|
| 45 |
+
LEAKAGE --> DEGREE --> SYNTH --> SCALE
|
| 46 |
+
end
|
| 47 |
+
|
| 48 |
+
subgraph S3["3. 5-MODEL ENSEMBLE"]
|
| 49 |
+
direction TB
|
| 50 |
+
subgraph ESTIMATORS["Parallel Classifiers (< 20 µs)"]
|
| 51 |
+
direction TB
|
| 52 |
+
RF["Random Forest (25% | 95.4%)"]
|
| 53 |
+
MLP["Small-NN MLP (25% | 94.9%)"]
|
| 54 |
+
LOGREG["Logistic Reg (20% | 92.2%)"]
|
| 55 |
+
SVM["Linear SVM (15% | 93.5%)"]
|
| 56 |
+
KNN["KNN k=5 (15% | 91.8%)"]
|
| 57 |
+
end
|
| 58 |
+
SOFTVOTE["Calibrated Soft-Voting Arbitration<br/>P(Class_c | X) = Σ w_i · P_i"]
|
| 59 |
+
ESTIMATORS --> SOFTVOTE
|
| 60 |
+
end
|
| 61 |
+
|
| 62 |
+
subgraph S4["4. C99 & INT8 QUANT"]
|
| 63 |
+
direction TB
|
| 64 |
+
EXPORT["backend/export.py<br/>Scikit-Learn AST Transpiler"]
|
| 65 |
+
QUANT["INT8 Symmetric Quantization<br/>-76.4% SRAM (34.8 KB → 8.2 KB)"]
|
| 66 |
+
HEADER["📁 firmware/include/model.h<br/>Zero-Malloc predict() C99 ABI"]
|
| 67 |
+
|
| 68 |
+
EXPORT --> QUANT --> HEADER
|
| 69 |
+
end
|
| 70 |
+
|
| 71 |
+
subgraph S5["5. MULTI-PLANE RUNTIME"]
|
| 72 |
+
direction TB
|
| 73 |
+
BAREMETAL["Plane A: ESP32-S3 Firmware<br/>Bare-Metal Flash ROM (< 20 µs)"]
|
| 74 |
+
TINYML["Plane B: Browser TinyML Client<br/>V8 In-Memory Engine (< 20 µs)"]
|
| 75 |
+
CLOUD["Plane C: Secondary Cloud REST<br/>FastAPI Container (35 ms)"]
|
| 76 |
+
MONITOR["Real-Time Oscillograph & Audit<br/>60 FPS Canvas + Diagnostic Matrix"]
|
| 77 |
+
|
| 78 |
+
BAREMETAL --> MONITOR
|
| 79 |
+
TINYML --> MONITOR
|
| 80 |
+
CLOUD --> MONITOR
|
| 81 |
+
end
|
| 82 |
+
|
| 83 |
+
INGEST --> LEAKAGE
|
| 84 |
+
SCALE --> ESTIMATORS
|
| 85 |
+
SOFTVOTE --> EXPORT
|
| 86 |
+
HEADER --> BAREMETAL
|
| 87 |
+
HEADER --> TINYML
|
| 88 |
+
EXPORT --> CLOUD`;
|
| 89 |
+
|
| 90 |
+
const MERMAID_PIPELINE_GRAPH_TD = `flowchart TD
|
| 91 |
subgraph S1["1. RAW TELEMETRY & FILE INGESTION"]
|
| 92 |
CSV["📄 patient_data.csv / batch_upload.csv<br/>(Continuous Vitals Observations)"]
|
| 93 |
AFE["⚡ Physical Biosensors<br/>AD8232 Lead-II ECG (250 Hz) + MAX30102 PPG"]
|
|
|
|
| 157 |
export default function Architecture() {
|
| 158 |
const [activeStage, setActiveStage] = useState<number>(1);
|
| 159 |
const [copiedId, setCopiedId] = useState<string | null>(null);
|
| 160 |
+
const [diagramLayout, setDiagramLayout] = useState<"LR" | "TD">("LR");
|
| 161 |
|
| 162 |
const handleCopy = (id: string, text: string) => {
|
| 163 |
navigator.clipboard.writeText(text);
|
|
|
|
| 337 |
</p>
|
| 338 |
</div>
|
| 339 |
|
| 340 |
+
<div className="flex flex-wrap items-center gap-2 self-start sm:self-auto">
|
| 341 |
+
{/* Diagram Layout Orientation Switcher */}
|
| 342 |
+
<button
|
| 343 |
+
onClick={() => setDiagramLayout(diagramLayout === "LR" ? "TD" : "LR")}
|
| 344 |
+
className="btn-tactile text-[11px] font-bold uppercase tracking-wider border-2 border-ink px-3 py-1.5 bg-canvas-cream hover:bg-ink hover:text-white transition-colors flex items-center gap-1.5 cursor-pointer"
|
| 345 |
+
title="Toggle diagram layout between compact horizontal pipeline and expanded vertical view"
|
| 346 |
+
>
|
| 347 |
+
<SlidersHorizontal size={13} className="text-hazard" />
|
| 348 |
+
<span>{diagramLayout === "LR" ? "Compact Horizontal (Default)" : "Expanded Vertical"}</span>
|
| 349 |
+
</button>
|
| 350 |
+
|
| 351 |
<button
|
| 352 |
+
onClick={() => handleCopy("mermaid-spec", diagramLayout === "LR" ? MERMAID_PIPELINE_GRAPH_LR : MERMAID_PIPELINE_GRAPH_TD)}
|
| 353 |
+
className="btn-tactile text-[11px] font-bold uppercase tracking-wider border-2 border-ink px-3 py-1.5 bg-white hover:bg-ink hover:text-white transition-colors flex items-center gap-1.5 cursor-pointer"
|
| 354 |
>
|
| 355 |
{copiedId === "mermaid-spec" ? (
|
| 356 |
<>
|
|
|
|
| 370 |
{/* PRIMARY VISUAL MERMAID FLOWCHART RENDERER */}
|
| 371 |
<div className="mb-8">
|
| 372 |
<MermaidChart
|
| 373 |
+
chart={diagramLayout === "LR" ? MERMAID_PIPELINE_GRAPH_LR : MERMAID_PIPELINE_GRAPH_TD}
|
| 374 |
+
title={`TELEMETRY INGESTION TO DUAL-PLANE INFERENCE PIPELINE (${diagramLayout === "LR" ? "COMPACT HORIZONTAL" : "VERTICAL STACK"})`}
|
| 375 |
/>
|
| 376 |
</div>
|
| 377 |
|
frontend/src/components/MermaidChart.tsx
CHANGED
|
@@ -168,7 +168,7 @@ export default function MermaidChart({ chart, title = "SYSTEM ARCHITECTURE PIPEL
|
|
| 168 |
</div>
|
| 169 |
|
| 170 |
{/* Main View Area */}
|
| 171 |
-
<div className={`relative overflow-auto p-4 md:p-6 bg-canvas-cream flex items-center justify-center min-h-
|
| 172 |
{isLoading && (
|
| 173 |
<div className="flex flex-col items-center justify-center gap-3 text-slate py-12">
|
| 174 |
<div className="w-6 h-6 border-2 border-hazard border-t-transparent animate-spin rounded-full" />
|
|
|
|
| 168 |
</div>
|
| 169 |
|
| 170 |
{/* Main View Area */}
|
| 171 |
+
<div className={`relative overflow-auto p-4 md:p-6 bg-canvas-cream flex items-center justify-center min-h-75 max-h-[580px] ${isFullscreen ? "flex-1 !max-h-none" : ""}`}>
|
| 172 |
{isLoading && (
|
| 173 |
<div className="flex flex-col items-center justify-center gap-3 text-slate py-12">
|
| 174 |
<div className="w-6 h-6 border-2 border-hazard border-t-transparent animate-spin rounded-full" />
|