# adxalex/retiro_mlops architecture

> Architecture diagram of the GitHub repository adxalex/retiro_mlops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adxalex/retiro_mlops
- Repository: https://github.com/adxalex/retiro_mlops

## Overview

El producto es un agente conversacional para el Parque de El Retiro, con respuestas basadas en RAG y planes de visita sujetos a aprobación humana. El flujo principal va desde CLI o Streamlit al grafo del agente, que enruta a herramientas, sintetiza la respuesta y puede pausar para aprobar o rechazar un plan. El RAG también tiene una ruta de preparación offline del corpus. Las relaciones se basan en el README y los excerpts/index; las integraciones externas sin evidencia directa de llamada se muestran como no verificadas.

Main entry points: [`src/pipeline.py`](https://github.com/adxalex/retiro_mlops/blob/main/src/pipeline.py) (Orquestación corpus), [`src/tools/__init__.py`](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/__init__.py) (Despacho allowlist), [`src/agent.py`](https://github.com/adxalex/retiro_mlops/blob/main/src/agent.py) (API del agente), [`src/ui_agente.py`](https://github.com/adxalex/retiro_mlops/blob/main/src/ui_agente.py) (Streamlit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Interfaces"]
  node_cli["CLI<br/>[main_agent.py]"]
  node_webui["Streamlit<br/>[ui_agente.py]"]
end

subgraph group_agent["Agente y herramientas"]
  node_agent_api["API del agente<br/>[agent.py]"]
  node_workflow["Grafo y HITL<br/>[graph.py]"]
  node_state["Estado conversacional<br/>[state.py]"]
  node_tool_dispatch["Despacho allowlist<br/>[__init__.py]"]
  node_rag_tool["Herramienta RAG<br/>[rag_tool.py]"]
  node_weather_tool["Herramienta AEMET<br/>[aemet_api.py]"]
  node_time_tool["Hora parque<br/>[hora_actual.py]"]
  node_image_tool["Descripción imagen<br/>[image_decrip.py]"]
end

subgraph group_rag["RAG online"]
  node_answer["Respuesta y citas<br/>[generate.py]"]
  node_retrieval["Recuperación<br/>[retrieve.py]"]
  node_vector_store[("Índice vectorial<br/>[index.py]")]
  node_embedding["Embeddings<br/>[embed.py]"]
  node_gemini_auth["Acceso Gemini<br/>[gemini_auth.py]"]
end

subgraph group_corpus["Preparación corpus"]
  node_corpus_pipeline["Orquestación corpus<br/>[pipeline.py]"]
  node_document_load["Carga documentos<br/>[load.py]"]
  node_chunking["Segmentación<br/>[chunk.py]"]
  node_embedding_cache[("Checkpoint embeddings<br/>[embedding_cache.py]")]
end

node_visitor(("Persona usuaria"))
node_aemet{{"Servicio AEMET"}}
node_gemini{{"API Gemini"}}

node_visitor -->|"pregunta o decisión"| node_cli
node_visitor -->|"pregunta o decisión"| node_webui
node_cli -->|"procesa turno"| node_agent_api
node_webui -->|"procesa turno"| node_agent_api
node_webui -->|"aprueba plan"| node_agent_api
node_agent_api -->|"invoca grafo"| node_workflow
node_workflow -->|"usa estado"| node_state
node_workflow -->|"ejecuta herramienta"| node_tool_dispatch
node_tool_dispatch -->|"despacha"| node_rag_tool
node_tool_dispatch -->|"despacha"| node_weather_tool
node_tool_dispatch -->|"despacha"| node_time_tool
node_tool_dispatch -->|"despacha"| node_image_tool
node_rag_tool -->|"solicita respuesta"| node_answer
node_answer -->|"recupera contexto"| node_retrieval
node_retrieval -->|"vectoriza consulta"| node_embedding
node_retrieval -->|"consulta índice"| node_vector_store
node_answer -->|"genera respuesta"| node_gemini_auth
node_embedding -->|"obtiene cliente"| node_gemini_auth
node_gemini_auth -.->|"accede API"| node_gemini
node_weather_tool -.->|"consulta datos"| node_aemet
node_corpus_pipeline -->|"carga corpus"| node_document_load
node_corpus_pipeline -->|"segmenta documentos"| node_chunking
node_corpus_pipeline -->|"genera vectores"| node_embedding
node_corpus_pipeline -->|"reanuda vectores"| node_embedding_cache
node_corpus_pipeline -->|"indexa chunks"| node_vector_store

click node_cli "https://github.com/adxalex/retiro_mlops/blob/main/main_agent.py"
click node_webui "https://github.com/adxalex/retiro_mlops/blob/main/src/ui_agente.py"
click node_agent_api "https://github.com/adxalex/retiro_mlops/blob/main/src/agent.py"
click node_workflow "https://github.com/adxalex/retiro_mlops/blob/main/src/graph.py"
click node_state "https://github.com/adxalex/retiro_mlops/blob/main/src/state.py"
click node_tool_dispatch "https://github.com/adxalex/retiro_mlops/blob/main/src/tools/__init__.py"
click node_rag_tool "https://github.com/adxalex/retiro_mlops/blob/main/src/tools/rag_tool.py"
click node_weather_tool "https://github.com/adxalex/retiro_mlops/blob/main/src/tools/aemet_api.py"
click node_time_tool "https://github.com/adxalex/retiro_mlops/blob/main/src/tools/hora_actual.py"
click node_image_tool "https://github.com/adxalex/retiro_mlops/blob/main/src/tools/image_decrip.py"
click node_answer "https://github.com/adxalex/retiro_mlops/blob/main/src/generate.py"
click node_retrieval "https://github.com/adxalex/retiro_mlops/blob/main/src/retrieve.py"
click node_vector_store "https://github.com/adxalex/retiro_mlops/blob/main/src/index.py"
click node_embedding "https://github.com/adxalex/retiro_mlops/blob/main/src/embed.py"
click node_gemini_auth "https://github.com/adxalex/retiro_mlops/blob/main/src/gemini_auth.py"
click node_corpus_pipeline "https://github.com/adxalex/retiro_mlops/blob/main/src/pipeline.py"
click node_document_load "https://github.com/adxalex/retiro_mlops/blob/main/src/load.py"
click node_chunking "https://github.com/adxalex/retiro_mlops/blob/main/src/chunk.py"
click node_embedding_cache "https://github.com/adxalex/retiro_mlops/blob/main/src/embedding_cache.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_webui toneBlue
class node_agent_api,node_workflow,node_state,node_tool_dispatch,node_rag_tool,node_weather_tool,node_time_tool,node_image_tool toneAmber
class node_answer,node_retrieval,node_vector_store,node_embedding,node_gemini_auth,node_gemini toneMint
class node_corpus_pipeline,node_document_load,node_chunking,node_embedding_cache toneRose
class node_visitor,node_aemet toneIndigo
```

## Components

### Interfaces

- [CLI](https://github.com/adxalex/retiro_mlops/blob/main/main_agent.py): `main_agent.py`
- [Streamlit](https://github.com/adxalex/retiro_mlops/blob/main/src/ui_agente.py): `src/ui_agente.py`

### Agente y herramientas

- [API del agente](https://github.com/adxalex/retiro_mlops/blob/main/src/agent.py): `src/agent.py`
- [Grafo y HITL](https://github.com/adxalex/retiro_mlops/blob/main/src/graph.py): `src/graph.py`
- [Estado conversacional](https://github.com/adxalex/retiro_mlops/blob/main/src/state.py): `src/state.py`
- [Despacho allowlist](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/__init__.py): `src/tools/__init__.py`
- [Herramienta RAG](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/rag_tool.py): `src/tools/rag_tool.py`
- [Herramienta AEMET](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/aemet_api.py): `src/tools/aemet_api.py`
- [Hora parque](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/hora_actual.py): `src/tools/hora_actual.py`
- [Descripción imagen](https://github.com/adxalex/retiro_mlops/blob/main/src/tools/image_decrip.py): `src/tools/image_decrip.py`

### RAG online

- [Respuesta y citas](https://github.com/adxalex/retiro_mlops/blob/main/src/generate.py): `src/generate.py`
- [Recuperación](https://github.com/adxalex/retiro_mlops/blob/main/src/retrieve.py): `src/retrieve.py`
- [Índice vectorial](https://github.com/adxalex/retiro_mlops/blob/main/src/index.py): `src/index.py`
- [Embeddings](https://github.com/adxalex/retiro_mlops/blob/main/src/embed.py): `src/embed.py`
- [Acceso Gemini](https://github.com/adxalex/retiro_mlops/blob/main/src/gemini_auth.py): `src/gemini_auth.py`

### Preparación corpus

- [Orquestación corpus](https://github.com/adxalex/retiro_mlops/blob/main/src/pipeline.py): `src/pipeline.py`
- [Carga documentos](https://github.com/adxalex/retiro_mlops/blob/main/src/load.py): `src/load.py`
- [Segmentación](https://github.com/adxalex/retiro_mlops/blob/main/src/chunk.py): `src/chunk.py`
- [Checkpoint embeddings](https://github.com/adxalex/retiro_mlops/blob/main/src/embedding_cache.py): `src/embedding_cache.py`

### Other components

- **Persona usuaria**
- **Servicio AEMET**
- **API Gemini**

## Connections

- Persona usuaria → CLI: pregunta o decisión (evidence: `README.md`)
- Persona usuaria → Streamlit: pregunta o decisión (evidence: `README.md`)
- CLI → API del agente: procesa turno (evidence: `README.md`)
- Streamlit → API del agente: procesa turno (evidence: `README.md`)
- Streamlit → API del agente: aprueba plan (evidence: `README.md`)
- API del agente → Grafo y HITL: invoca grafo (evidence: `src/agent.py`)
- Grafo y HITL → Estado conversacional: usa estado (evidence: `src/graph.py`)
- Grafo y HITL → Despacho allowlist: ejecuta herramienta (evidence: `src/graph.py`)
- Despacho allowlist → Herramienta RAG: despacha (evidence: `src/tools/__init__.py`)
- Despacho allowlist → Herramienta AEMET: despacha (evidence: `src/tools/__init__.py`)
- Despacho allowlist → Hora parque: despacha (evidence: `src/tools/__init__.py`)
- Despacho allowlist → Descripción imagen: despacha (evidence: `src/tools/__init__.py`)
- Herramienta RAG → Respuesta y citas: solicita respuesta (evidence: `src/tools/rag_tool.py`)
- Respuesta y citas → Recuperación: recupera contexto (evidence: `src/generate.py`)
- Recuperación → Embeddings: vectoriza consulta (evidence: `src/retrieve.py`)
- Recuperación → Índice vectorial: consulta índice (evidence: `src/retrieve.py`)
- Respuesta y citas → Acceso Gemini: genera respuesta (evidence: `src/generate.py`)
- Embeddings → Acceso Gemini: obtiene cliente (evidence: `src/embed.py`)
- Acceso Gemini → API Gemini: accede API
- Herramienta AEMET → Servicio AEMET: consulta datos
- Orquestación corpus → Carga documentos: carga corpus (evidence: `src/pipeline.py`)
- Orquestación corpus → Segmentación: segmenta documentos (evidence: `src/pipeline.py`)
- Orquestación corpus → Embeddings: genera vectores (evidence: `src/pipeline.py`)
- Orquestación corpus → Checkpoint embeddings: reanuda vectores (evidence: `src/pipeline.py`)
- Orquestación corpus → Índice vectorial: indexa chunks (evidence: `src/pipeline.py`)
