🏗️ Arquitectura - ¿Quién quiere ser Millonario?

graph TD classDef gold fill:#FFD700,stroke:#FF8C00,stroke-width:2px,color:#1a0533; classDef cloudflare fill:#f38020,stroke:#fff,stroke-width:2px,color:#fff; classDef db fill:#1a0533,stroke:#FFD700,stroke-width:2px,color:#FFD700; User["👤 Jugador"] -->|HTTPS + Turnstile| CF["☁️ Cloudflare Network"] CF -->|Routing| Worker["⚙️ Worker millonario Hono.js"] subgraph "¿Quién quiere ser Millonario? App" Worker -->|Static Assets| Assets["📂 HTML/CSS Imágenes"] Worker -->|SQL Query| D1["🛢️ D1 Database Preguntas Quiz"] Worker -->|Validación| TS["🛡️ Turnstile Bot Protection"] Worker -->|1· embedding de la pregunta| EMB["🔢 bge-m3 multilingüe ES/EN/CA"] EMB -->|vector 1024d| VEC["🧭 Vectorize millonario-knowledge 48 fragmentos"] VEC -->|2· top-4 filtrado por idioma| Worker Worker -.->|respaldo si Vectorize falla| KV["🗄️ KV Store fallback"] Worker -->|3a· caché ON| GW["🔀 AI Gateway millonario-gw · caché 300s respuesta entera"] GW -->|inferencia| AI["🧠 Workers AI modelo seleccionable"] Worker -->|3b· caché OFF: directo| AI AI -->|SSE token a token| Worker end CF -->|snippets embebidos| AS["🔎 AI Search gestionado instancia millonario"] AS -->|indexa solo| R2["🪣 R2 millonario-knowledge-docs 48 documentos"] class User gold; class CF,Worker,AI,GW,EMB,AS cloudflare; class D1,KV,VEC,R2 db; class TS gold;

What to watch in the demo

  1. Real retrieval. The question is embedded with bge-m3 and matched against 48 chunks in Vectorize, filtered by language. The metrics bar shows how many chunks fed the answer.
  2. Streaming. Tokens are painted as they arrive over SSE, so you see time-to-first-token, not just the total.
  3. Cache versus streaming. The two pull against each other, and the toggle in the chat shows it. Cache on: the call goes through the AI Gateway, which must hold the whole answer to store it, so there is no streaming — but ask the same question twice and the second reply returns in tens of milliseconds instead of seconds. Cache off: the Worker calls the model directly and the first token lands in around 700 ms.
  4. Model switching. The selector swaps the model live across four vendors. The server validates it against an allow-list.
  5. Hand-built RAG versus managed product. Two assistants run side by side on purpose. The one on the left of the game is ours: we wrote the embedding, retrieval and prompt code. The one on the right is Cloudflare AI Search, which indexes an R2 bucket on its own and serves chat and search with no retrieval code of ours. Same corpus, same question — compare the answers and the effort each one cost.
← Back