IDKHowToCodeFr commited on
Commit
0a4bd1a
·
verified ·
1 Parent(s): 72f87bd

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. ARCHITECTURE.md +102 -61
ARCHITECTURE.md CHANGED
@@ -11,67 +11,108 @@ By aggressively decoupling the presentation layer (Client), the orchestration an
11
  ## 🏗 High-Level Architecture Diagram
12
 
13
  ```mermaid
14
- graph TD
15
- %% Define styles
16
- classDef frontend fill:#111,stroke:#111,stroke-width:2px,color:#fff,font-family:monospace;
17
- classDef backend fill:#fff,stroke:#111,stroke-width:2px,color:#111,font-family:monospace;
18
- classDef ml_node fill:#e61919,stroke:#e61919,stroke-width:2px,color:#fff,font-family:monospace;
19
- classDef edge_tech fill:#f3f3f2,stroke:#111,stroke-width:2px,color:#111,font-family:monospace;
20
- classDef data fill:#94a3b8,stroke:#475569,stroke-width:2px,color:#fff,font-family:monospace;
21
-
22
- subgraph Client [Client Application / Next.js 16]
23
- UI[React 19 Dashboard]:::frontend
24
- WS_Client[WebSocket Context]:::frontend
25
- HTTP_Client[Axios/Fetch HTTP]:::frontend
26
- end
27
-
28
- subgraph Core [FastAPI Core / Python 3.10+]
29
- WS_Server[Async WebSocket Broker]:::backend
30
- REST_API[RESTful API Router]:::backend
31
- Inference[Stateful Inference Preprocessor]:::backend
32
- MLOps[Background MLOps Engine]:::backend
33
- DB[(aiosqlite Asynchronous DB)]:::backend
34
- end
35
-
36
- subgraph ML_Layer [Intelligence Pipeline / Scikit-Learn]
37
- Ensemble{Soft-Voting Aggregator}:::ml_node
38
- Models[RF, SVM, KNN, LogReg, MLP]:::ml_node
39
- SHAP[SHAP Feature Explainer]:::ml_node
40
- EdgeCompiler[INT8 AST C-Compiler]:::ml_node
41
- end
42
-
43
- subgraph Hardware [Edge Target / Embedded Silicon]
44
- HEADER((tinyml_model.h)):::edge_tech
45
- MCU[ESP32 / Cortex-M Node]:::edge_tech
46
- end
47
-
48
- subgraph Storage [Persistent Persistence Layer]
49
- ModelWeights[Serialized Weights / LRU .pkl]:::data
50
- CSV[Immutable Patient Dataset .csv]:::data
51
- end
52
-
53
- %% Edge Flows
54
- UI -->|Framer Motion Layouts| WS_Client
55
- UI -->|Config / Retrain Requests| HTTP_Client
56
-
57
- WS_Client <-->|ws:// 60Hz Telemetry Stream| WS_Server
58
- HTTP_Client -->|POST /retrain, GET /export| REST_API
59
-
60
- WS_Server -->|Event Loop Execution| Inference
61
- REST_API -->|Threaded Task| MLOps
62
- REST_API -->|Triggers Generation| EdgeCompiler
63
-
64
- Inference -->|Standardized Vector| Ensemble
65
- Ensemble --> Models
66
- Ensemble --> SHAP
67
-
68
- MLOps -->|LRU State Override| ModelWeights
69
- MLOps -->|Append Only| CSV
70
- EdgeCompiler -->|Parses Structure| Models
71
- Inference -->|Reads Memory-Mapped| ModelWeights
72
-
73
- EdgeCompiler -->|Emits Dependency-Free C| HEADER
74
- HEADER -.->|Flash via UART| MCU
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  ```
76
 
77
  ---
 
11
  ## 🏗 High-Level Architecture Diagram
12
 
13
  ```mermaid
14
+ %% Generated by https://gitdiagram.com/idkhowtocodefr/heartflow_os
15
+ flowchart TD
16
+
17
+ subgraph group_client["Telemetry interface"]
18
+ node_dashboard["Live dashboard<br/>[page.tsx]"]
19
+ node_telemetry_context["Telemetry context"]
20
+ node_history_ui["History view<br/>[page.tsx]"]
21
+ node_analytics["Analytics view<br/>[page.tsx]"]
22
+ node_simulator_ui["Simulator view<br/>[page.tsx]"]
23
+ node_mlops_ui["MLOps view<br/>[page.tsx]"]
24
+ node_edge_ui["Edge export view<br/>[page.tsx]"]
25
+ node_architecture_ui["Architecture view<br/>[page.tsx]"]
26
+ node_shap_chart["SHAP chart<br/>[ShapChart.tsx]"]
27
+ end
28
+
29
+ subgraph group_api["API orchestration"]
30
+ node_api["FastAPI routes<br/>[main.py]"]
31
+ node_simulator["Vitals simulator<br/>[simulator.py]"]
32
+ end
33
+
34
+ subgraph group_ml["Prediction and MLOps"]
35
+ node_inference["Inference pipeline<br/>[inference.py]"]
36
+ node_preprocessing["Feature preprocessing<br/>[preprocessing.py]"]
37
+ node_ensemble["Soft-voting ensemble<br/>[ensemble.py]"]
38
+ node_training["Model training<br/>[models.py]"]
39
+ node_export["C code exporter<br/>[export.py]"]
40
+ node_model_files["Trained model files"]
41
+ node_dataset["Patient dataset"]
42
+ end
43
+
44
+ subgraph group_state["Persistence and sync"]
45
+ node_database[("Prediction history<br/>[database.py]")]
46
+ node_sqlite[("SQLite history store<br/>[patient_history.db]")]
47
+ end
48
+
49
+ node_clinician(("Clinical user"))
50
+ node_hub["Hugging Face Hub"]
51
+
52
+ node_clinician -.->|"monitors"| node_dashboard
53
+ node_clinician -.->|"reviews"| node_history_ui
54
+ node_clinician -.->|"explores"| node_analytics
55
+ node_clinician -.->|"uses"| node_simulator_ui
56
+ node_clinician -.->|"manages"| node_mlops_ui
57
+ node_clinician -.->|"exports"| node_edge_ui
58
+ node_clinician -.->|"views"| node_architecture_ui
59
+ node_dashboard -->|"uses"| node_telemetry_context
60
+ node_clinician -.->|"submits vitals"| node_api
61
+ node_dashboard -.->|"streams telemetry"| node_api
62
+ node_history_ui -.->|"requests history"| node_api
63
+ node_analytics -.->|"requests data"| node_api
64
+ node_mlops_ui -.->|"uploads retraining data"| node_api
65
+ node_edge_ui -.->|"requests C export"| node_api
66
+ node_api -->|"initializes and queries"| node_database
67
+ node_api -->|"streams generated vitals"| node_simulator
68
+ node_api -->|"evaluates vitals"| node_inference
69
+ node_api -->|"prepares explanations"| node_preprocessing
70
+ node_api -->|"generates C code"| node_export
71
+ node_api -->|"loads and refreshes"| node_ensemble
72
+ node_api -->|"starts background retraining"| node_training
73
+ node_inference -->|"transforms features"| node_preprocessing
74
+ node_inference -.->|"predicts probabilities"| node_ensemble
75
+ node_ensemble -->|"resolves model directory"| node_preprocessing
76
+ node_training -->|"splits and transforms data"| node_preprocessing
77
+ node_training -->|"reads training data"| node_dataset
78
+ node_training -->|"writes trained models"| node_model_files
79
+ node_ensemble -->|"loads model artifacts"| node_model_files
80
+ node_database -->|"reads and writes"| node_sqlite
81
+ node_database -->|"syncs history"| node_hub
82
+
83
+ click node_dashboard "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/dashboard/page.tsx"
84
+ click node_telemetry_context "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/context/TelemetryContext.tsx"
85
+ click node_history_ui "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/history/page.tsx"
86
+ click node_analytics "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/analytics/page.tsx"
87
+ click node_simulator_ui "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/simulator/page.tsx"
88
+ click node_mlops_ui "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/mlops/page.tsx"
89
+ click node_edge_ui "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/edge/page.tsx"
90
+ click node_architecture_ui "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/app/architecture/page.tsx"
91
+ click node_shap_chart "https://github.com/idkhowtocodefr/heartflow_os/blob/main/frontend/src/components/ShapChart.tsx"
92
+ click node_api "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/main.py"
93
+ click node_simulator "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/simulator.py"
94
+ click node_inference "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/inference.py"
95
+ click node_preprocessing "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/preprocessing.py"
96
+ click node_ensemble "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/ensemble.py"
97
+ click node_training "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/models.py"
98
+ click node_export "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/export.py"
99
+ click node_model_files "https://github.com/idkhowtocodefr/heartflow_os/tree/main/model"
100
+ click node_dataset "https://github.com/idkhowtocodefr/heartflow_os/blob/main/data/patient_dataset.csv"
101
+ click node_database "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/database.py"
102
+ click node_sqlite "https://github.com/idkhowtocodefr/heartflow_os/blob/main/backend/patient_history.db"
103
+
104
+ classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
105
+ classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
106
+ classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
107
+ classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
108
+ classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
109
+ classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
110
+ classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
111
+ class node_dashboard,node_telemetry_context,node_history_ui,node_analytics,node_simulator_ui,node_mlops_ui,node_edge_ui,node_architecture_ui,node_shap_chart,node_clinician toneBlue
112
+ class node_api,node_simulator toneAmber
113
+ class node_inference,node_preprocessing,node_ensemble,node_training,node_export,node_model_files,node_dataset toneMint
114
+ class node_database,node_sqlite toneRose
115
+ class node_hub toneIndigo
116
  ```
117
 
118
  ---