IDKHowToCodeFr commited on
Commit
c86035c
·
1 Parent(s): f63a171

docs: add comprehensive system architecture mermaid diagram

Browse files
Files changed (1) hide show
  1. architecture.md +83 -25
architecture.md CHANGED
@@ -10,32 +10,90 @@ A common anti-pattern in AI composition engines is feeding a massive 500KB JSON
10
 
11
  ```mermaid
12
  flowchart TD
13
- subgraph Data Input
14
- A[JSON Context: 500KB] --> B[FastAPI Endpoint]
15
- end
16
-
17
- subgraph Stage 1: The Python Caveman
18
- B --> C{Context Distiller}
19
- C -->|Extracts Metrics| D[Views, CTR, Offers]
20
- C -->|Selects Tone| E[Professional/Hinglish]
21
- C -->|Identifies Compulsion| F[Loss Aversion/Urgency]
22
- end
23
-
24
- subgraph Stage 2: The LLM Expander
25
- D & E & F --> G[Compressed Fact Sheet]
26
- G --> H{Provider Adapter Registry}
27
- H -->|Tier 1-3 Cloud| I[NVIDIA / Groq / Gemini]
28
- H -->|Tier 4 Fallback| J[Local Llama-CPP 3B]
29
- I & J --> K[Strict JSON Output]
30
- end
31
-
32
- K --> L((WhatsApp Message & CTA))
33
 
34
- %% Modern UI Colors
35
- style C fill:#3b82f6,stroke:#1e3a8a,stroke-width:2px,color:#fff
36
- style G fill:#8b5cf6,stroke:#4c1d95,stroke-width:2px,color:#fff
37
- style K fill:#10b981,stroke:#064e3b,stroke-width:2px,color:#fff
38
- style L fill:#f59e0b,stroke:#78350f,stroke-width:2px,color:#fff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ```
40
 
41
  ### Separation of Concerns (Two-Stage Pipeline):
 
10
 
11
  ```mermaid
12
  flowchart TD
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ subgraph group_api["API and Context"]
15
+ node_context_api["Context Ingestion<br/>[app.py]"]
16
+ node_context_store[("Context State<br/>[app.py]")]
17
+ node_tick_api["Trigger API<br/>[app.py]"]
18
+ node_reply_api["Reply API<br/>[app.py]"]
19
+ node_health_metadata["Health and Metadata<br/>[app.py]"]
20
+ end
21
+
22
+ subgraph group_engagement["Engagement Workflow"]
23
+ node_trigger_processing["Trigger Processing<br/>[app.py]"]
24
+ node_reply_classification["Reply Classification<br/>[app.py]"]
25
+ end
26
+
27
+ subgraph group_composition["Message Composition"]
28
+ node_composer["Context Distiller<br/>[composer.py]"]
29
+ node_prompt_builder["Prompt Builder<br/>[prompts.py]"]
30
+ node_output_validation["Validation and Repair<br/>[composer.py]"]
31
+ end
32
+
33
+ subgraph group_inference["Model Inference"]
34
+ node_model_router["Fallback Composer<br/>[composer.py]"]
35
+ node_llm_adapter["Model Adapters<br/>[llm.py]"]
36
+ node_local_model["Local Qwen Model<br/>[llm.py]"]
37
+ end
38
+
39
+ node_client(("Challenge Client"))
40
+ node_nvidia["NVIDIA NIM"]
41
+ node_groq["Groq"]
42
+ node_gemini["Gemini"]
43
+ node_seed_data["Challenge Seed Data"]
44
+
45
+ node_client -->|"pushes context"| node_context_api
46
+ node_context_api -->|"stores payloads"| node_context_store
47
+ node_client -->|"submits triggers"| node_tick_api
48
+ node_tick_api -->|"reads contexts"| node_context_store
49
+ node_tick_api -->|"dispatches"| node_trigger_processing
50
+ node_trigger_processing -->|"loads context"| node_context_store
51
+ node_trigger_processing -->|"composes message"| node_composer
52
+ node_composer -->|"builds local prompt"| node_prompt_builder
53
+ node_composer -->|"requests generation"| node_model_router
54
+ node_model_router -->|"tries model tiers"| node_llm_adapter
55
+ node_llm_adapter -->|"calls first"| node_nvidia
56
+ node_llm_adapter -->|"falls back"| node_groq
57
+ node_llm_adapter -->|"falls back"| node_gemini
58
+ node_llm_adapter -->|"falls back"| node_local_model
59
+ node_model_router -->|"validates and repairs"| node_output_validation
60
+ node_output_validation -->|"returns result"| node_model_router
61
+ node_trigger_processing -->|"returns action"| node_tick_api
62
+ node_client -->|"posts reply"| node_reply_api
63
+ node_reply_api -->|"classifies message"| node_reply_classification
64
+ node_reply_classification -->|"generates response"| node_model_router
65
+ node_reply_api -->|"returns decision"| node_client
66
+ node_client -->|"requests status"| node_health_metadata
67
+ node_seed_data -.->|"supplies test contexts"| node_client
68
+
69
+ click node_context_api "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
70
+ click node_context_store "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
71
+ click node_tick_api "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
72
+ click node_reply_api "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
73
+ click node_health_metadata "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
74
+ click node_trigger_processing "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
75
+ click node_reply_classification "https://github.com/idkhowtocodefr/vera-engine/blob/main/app.py"
76
+ click node_composer "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/composer.py"
77
+ click node_prompt_builder "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/prompts.py"
78
+ click node_output_validation "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/composer.py"
79
+ click node_model_router "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/composer.py"
80
+ click node_llm_adapter "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/llm.py"
81
+ click node_local_model "https://github.com/idkhowtocodefr/vera-engine/blob/main/scripts/llm.py"
82
+ click node_seed_data "https://github.com/idkhowtocodefr/vera-engine/tree/main/dataset"
83
+
84
+ classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
85
+ classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
86
+ classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
87
+ classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
88
+ classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
89
+ classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
90
+ classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
91
+ class node_context_api,node_context_store,node_tick_api,node_reply_api,node_health_metadata,node_client toneBlue
92
+ class node_trigger_processing,node_reply_classification toneAmber
93
+ class node_composer,node_prompt_builder,node_output_validation toneMint
94
+ class node_model_router,node_llm_adapter,node_local_model toneRose
95
+ class node_nvidia,node_groq,node_gemini toneIndigo
96
+ class node_seed_data toneTeal
97
  ```
98
 
99
  ### Separation of Concerns (Two-Stage Pipeline):