Arquitectura, componentes y flujo lógico de
Vicente el Agente Presuntamente Inteligente

graph TD %% Componentes Principales User((Usuario)) subgraph Frontend ["Frontend (HTML5/JS/CSS) Port: 8000"] UI[Interfaz de Usuario] Mic[Captura de Micrófono] AudioPlayer[Reproductor de Audio] SSE_Rec[Receptor de Eventos SSE] end subgraph Backend ["Proxy Central (Node.js / Express) Port: 3000"] Orchestrator[Orquestador de Diálogo] ToolManager[Gestor de Herramientas] Persistence[Persistencia de Perfiles] TTS_Buffer[Gestor de Fragmentos TTS] end subgraph Service_STT ["Servicio STT (Python / FastAPI) Port: 5001"] FasterWhisper[Faster-Whisper] FFmpeg[Procesado de Audio] end subgraph Service_LLM ["LM Studio (Inferencia) Port: 1234"] Gemma4[Gemma 4 26b A4B] end subgraph Service_TTS ["Piper TTS (HTTP Server) Port: 7860"] Piper[Sintetizador de Voz] end subgraph External_APIs ["Herramientas Externas"] Brave[Brave Search API] Weather[OpenWeather API] Jina[Readability / Jina.ai] FileSystem[Sandbox File System] end %% Flujo 1: Voz a Texto User -- "Habla" --> Mic Mic -- "Audio (WebSocket)" --> Service_STT FasterWhisper -- "Texto Parcial/Final" --> UI %% Flujo 2: Petición al Orquestador UI -- "Prompt de Texto" --> Orchestrator %% Flujo 3: Inteligencia y Herramientas Orchestrator -- "Contexto + Historial" --> Service_LLM Gemma4 -- "Razonamiento / Tool Call" --> Orchestrator Orchestrator -- "Ejecutar" --> ToolManager ToolManager -.-> External_APIs External_APIs -.-> ToolManager ToolManager -- "Resultados" --> Orchestrator %% Flujo 4: Respuesta Streaming y Voz Gemma4 -- "Tokens (Stream)" --> Orchestrator Orchestrator -- "Texto (SSE)" --> SSE_Rec SSE_Rec -- "Renderizado" --> UI Orchestrator -- "Oraciones completas" --> TTS_Buffer TTS_Buffer -- "Texto Limpio" --> Piper Piper -- "Audio Bytes" --> TTS_Buffer TTS_Buffer -- "Audio Snippets (SSE)" --> SSE_Rec SSE_Rec -- "Reproducción" --> AudioPlayer AudioPlayer -- "Voz" --> User %% Estilos style Backend fill:#f9f,stroke:#333,stroke-width:2px style Frontend fill:#bbf,stroke:#333,stroke-width:2px style Service_LLM fill:#bfb,stroke:#333,stroke-width:2px style Service_TTS fill:#fbb,stroke:#333,stroke-width:2px style Service_STT fill:#fdb,stroke:#333,stroke-width:2px

Componentes y su función