Spaces:
Sleeping
Sleeping
Commit ·
545bd83
1
Parent(s): 4e11540
docs: add §4.1 plain-English user-journey diagram; renumber 4.x
Browse filesNew §4.1 'The user's journey' — a Mermaid flowchart of the end-user
path (open → fact-find → personalised shortlist → explore/compare/ask/
upload → live premium → decide), placed before any technical content.
Existing subsections demoted: shape→4.2, architecture diagrams→4.3,
…, profile→4.7. No code touched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
README.md
CHANGED
|
@@ -113,7 +113,39 @@ This is the full architecture. It is described here because the architecture
|
|
| 113 |
*is* the product — this README is the single source of truth for how the
|
| 114 |
system works today.
|
| 115 |
|
| 116 |
-
### 4.1 The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
A **Next.js** browser app talks to a **FastAPI** backend. Every chat turn goes
|
| 119 |
to a **single LLM "brain"** (Google **Gemini**) that has been given a small set
|
|
@@ -125,7 +157,7 @@ falls back to an **NVIDIA NIM** open-model chain. Voice in/out is handled by
|
|
| 125 |
**Sarvam** (Indian-language STT/TTS). Heavy data (PDF corpus + prebuilt
|
| 126 |
vectors) lives in a separate Hugging Face **dataset**, not in the code repo.
|
| 127 |
|
| 128 |
-
### 4.
|
| 129 |
|
| 130 |
> These render natively on GitHub. They are the authoritative visual map
|
| 131 |
> of the system; a compact plain-text version of the core path is kept
|
|
@@ -319,7 +351,7 @@ flowchart LR
|
|
| 319 |
|
| 320 |
---
|
| 321 |
|
| 322 |
-
### 4.
|
| 323 |
|
| 324 |
```
|
| 325 |
┌──────────────────────────────────────────────┐
|
|
@@ -362,7 +394,7 @@ flowchart LR
|
|
| 362 |
Every turn appends one JSON line to logs/turns.jsonl for replay/audit.
|
| 363 |
```
|
| 364 |
|
| 365 |
-
### 4.
|
| 366 |
|
| 367 |
Earlier designs split the work across several LLM passes (a separate
|
| 368 |
fact-find brain, a QA brain, a faithfulness-judge). That scaffolding was
|
|
@@ -372,7 +404,7 @@ there is exactly **one** brain call per turn plus its tool calls. Faithfulness
|
|
| 372 |
is enforced structurally — the brain can only state what `retrieve_policies`
|
| 373 |
returned — rather than by a second grader model.
|
| 374 |
|
| 375 |
-
### 4.
|
| 376 |
|
| 377 |
The brain's primary is Gemini (`gemini-2.5-flash-lite`). On a real Gemini
|
| 378 |
failure or a cold-start 503, the turn falls back to an NVIDIA NIM chain of
|
|
@@ -383,7 +415,7 @@ user gets an explicit "service degraded" message, never a silently wrong
|
|
| 383 |
answer. (A separate LLM "judge" existed historically and has been retired —
|
| 384 |
the single-brain design made it redundant.)
|
| 385 |
|
| 386 |
-
### 4.
|
| 387 |
|
| 388 |
The browser shows a live interim transcript via the Web Speech API while
|
| 389 |
`MediaRecorder` captures the authoritative audio, which is sent to
|
|
@@ -397,7 +429,7 @@ the bot (barge-in) pauses that audio **and** aborts the in-flight
|
|
| 397 |
push-to-talk (the hold-SPACE shortcut was removed); the live interim
|
| 398 |
transcript accumulates the full utterance while you speak.
|
| 399 |
|
| 400 |
-
### 4.
|
| 401 |
|
| 402 |
Your answers build a session profile (`backend/session_state.py`,
|
| 403 |
`profile_store.py`, `profile_persistence.py`). The profile is also embedded as
|
|
|
|
| 113 |
*is* the product — this README is the single source of truth for how the
|
| 114 |
system works today.
|
| 115 |
|
| 116 |
+
### 4.1 The user's journey (plain English — no tech)
|
| 117 |
+
|
| 118 |
+
Before the engineering detail, here is what actually happens for the
|
| 119 |
+
person using it. No code, no jargon — just the path from opening the app
|
| 120 |
+
to deciding with confidence.
|
| 121 |
+
|
| 122 |
+
```mermaid
|
| 123 |
+
flowchart TD
|
| 124 |
+
S["🌐 You open the app — web or mobile, nothing to install"] --> R{"Used it before?"}
|
| 125 |
+
R -->|"Returning"| WB["👋 "Welcome back, <name>?" — your earlier profile is offered back"]
|
| 126 |
+
R -->|"First time"| TELL
|
| 127 |
+
WB -->|"yes, that's me"| KNOWN["Picks up with your saved profile — no re-typing"]
|
| 128 |
+
WB -->|"no / not me"| TELL
|
| 129 |
+
KNOWN --> REC
|
| 130 |
+
TELL["🗣️ Tell it about you — a short chat, typed OR spoken, English / Hindi-Hinglish<br/>age · family · budget · health · what you care about"] --> ASK["❓ It asks just 2–3 clarifying questions<br/>(a real conversation, never a long form)"]
|
| 131 |
+
ASK --> REC["🎯 A personalised shortlist — plans ranked for YOUR fit, each with the reason it fits"]
|
| 132 |
+
REC --> WHY["🔍 Open any plan: every fact is backed by the exact clause in the real policy PDF<br/>an honest "not stated in the document" instead of a guess"]
|
| 133 |
+
WHY --> EXPLORE{"Want to dig deeper?"}
|
| 134 |
+
EXPLORE -->|"Compare"| CMP["⚖️ Compare up to 4 plans side by side · full scorecard per plan"]
|
| 135 |
+
EXPLORE -->|"Browse"| MKT["📚 Browse the full indexed marketplace"]
|
| 136 |
+
EXPLORE -->|"Ask"| QA["💬 Ask follow-up questions — answered only from the actual documents"]
|
| 137 |
+
EXPLORE -->|"My own policy"| UP["📄 Upload your own policy PDF — ask about YOUR document (private to your session)"]
|
| 138 |
+
CMP --> PREM
|
| 139 |
+
MKT --> PREM
|
| 140 |
+
QA --> PREM
|
| 141 |
+
UP --> PREM
|
| 142 |
+
PREM["💸 A live premium estimate that updates as you change your profile"] --> DONE["✅ Decide with confidence — no lead capture, no commission bias"]
|
| 143 |
+
VOICE["🎙️ Optional the whole way: speak instead of type — it speaks the answers back"] -.-> TELL
|
| 144 |
+
VOICE -.-> QA
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
### 4.2 The shape, in one paragraph
|
| 149 |
|
| 150 |
A **Next.js** browser app talks to a **FastAPI** backend. Every chat turn goes
|
| 151 |
to a **single LLM "brain"** (Google **Gemini**) that has been given a small set
|
|
|
|
| 157 |
**Sarvam** (Indian-language STT/TTS). Heavy data (PDF corpus + prebuilt
|
| 158 |
vectors) lives in a separate Hugging Face **dataset**, not in the code repo.
|
| 159 |
|
| 160 |
+
### 4.3 Architecture diagrams (every layer, every link)
|
| 161 |
|
| 162 |
> These render natively on GitHub. They are the authoritative visual map
|
| 163 |
> of the system; a compact plain-text version of the core path is kept
|
|
|
|
| 351 |
|
| 352 |
---
|
| 353 |
|
| 354 |
+
### 4.3-text Request flow (a single turn) — plain-text fallback
|
| 355 |
|
| 356 |
```
|
| 357 |
┌──────────────────────────────────────────────┐
|
|
|
|
| 394 |
Every turn appends one JSON line to logs/turns.jsonl for replay/audit.
|
| 395 |
```
|
| 396 |
|
| 397 |
+
### 4.4 Why a single brain (not a multi-model pipeline)
|
| 398 |
|
| 399 |
Earlier designs split the work across several LLM passes (a separate
|
| 400 |
fact-find brain, a QA brain, a faithfulness-judge). That scaffolding was
|
|
|
|
| 404 |
is enforced structurally — the brain can only state what `retrieve_policies`
|
| 405 |
returned — rather than by a second grader model.
|
| 406 |
|
| 407 |
+
### 4.5 The fallback chain
|
| 408 |
|
| 409 |
The brain's primary is Gemini (`gemini-2.5-flash-lite`). On a real Gemini
|
| 410 |
failure or a cold-start 503, the turn falls back to an NVIDIA NIM chain of
|
|
|
|
| 415 |
answer. (A separate LLM "judge" existed historically and has been retired —
|
| 416 |
the single-brain design made it redundant.)
|
| 417 |
|
| 418 |
+
### 4.6 Voice
|
| 419 |
|
| 420 |
The browser shows a live interim transcript via the Web Speech API while
|
| 421 |
`MediaRecorder` captures the authoritative audio, which is sent to
|
|
|
|
| 429 |
push-to-talk (the hold-SPACE shortcut was removed); the live interim
|
| 430 |
transcript accumulates the full utterance while you speak.
|
| 431 |
|
| 432 |
+
### 4.7 Profile & personalisation
|
| 433 |
|
| 434 |
Your answers build a session profile (`backend/session_state.py`,
|
| 435 |
`profile_store.py`, `profile_persistence.py`). The profile is also embedded as
|