# santmun/agente-marco architecture

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

- Interactive diagram: https://gitdiagram.com/santmun/agente-marco
- Repository: https://github.com/santmun/agente-marco

## Overview

Marco is a dental-clinic voice agent plus an owner-facing control panel. The main call flow is patient → phone/voice agent → Worker tools → availability and booking → calendar, with call records synchronized for panel review. The panel also covers calls, patients, pending follow-ups, agent settings and knowledge, costs, and integrations. Evidence comes from the README and the shown excerpts/SOURCE INDEX; some panel routes and integrations are documented but their implementations were not sampled, so those links are cited to the README.

Main entry points: [`src/worker/hoja.ts`](https://github.com/santmun/agente-marco/blob/main/src/worker/hoja.ts) (Sheet access), [`src/app/App.tsx`](https://github.com/santmun/agente-marco/blob/main/src/app/App.tsx) (Panel shell), [`src/worker/herramientas.ts`](https://github.com/santmun/agente-marco/blob/main/src/worker/herramientas.ts) (Call tools), [`src/worker/api.ts`](https://github.com/santmun/agente-marco/blob/main/src/worker/api.ts) (Panel API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_voice["Voice agent"]
  node_agent_prompt["Agent prompt<br/>[prompt.md]"]
  node_agent_config["Agent settings<br/>[configuracion.json]"]
  node_agent_tools["Tool definitions<br/>[herramientas.json]"]
end

subgraph group_worker["Worker runtime"]
  node_worker_entry["Worker routing<br/>[index.ts]"]
  node_tool_handlers["Call tools<br/>[herramientas.ts]"]
  node_booking["Availability &amp; booking<br/>[agenda.ts]"]
  node_call_sync["Call synchronization<br/>[sincronizar.ts]"]
  node_installer["Google setup<br/>[instalar.ts]"]
  node_api["Panel API<br/>[api.ts]"]
end

subgraph group_data["Clinic data"]
  node_clinic_state[("Locks &amp; index<br/>[estado.ts]")]
  node_sheet_access["Sheet access<br/>[hoja.ts]"]
  node_clinic_catalog["Clinic catalog<br/>[catalogo.ts]"]
  node_demo_data["Preview data<br/>[demo.ts]"]
end

subgraph group_integrations["External services"]
  node_telephony["Phone / SIP"]
  node_sheets[("Sheets store")]
  node_composio["Composio bridge<br/>[composio.ts]"]
  node_calendar[("Google Calendar")]
  node_whatsapp["WhatsApp"]
  node_eleven_api["ElevenLabs API<br/>[elevenlabs.ts]"]
end

subgraph group_control["Control panel"]
  node_app["Panel shell<br/>[App.tsx]"]
  node_dashboard["Summary &amp; costs"]
  node_call_views["Calls &amp; follow-ups"]
  node_clinic_views["Agenda &amp; patients"]
  node_agent_views["Agent &amp; knowledge<br/>[Marco.tsx]"]
  node_connections_view["Connections setup<br/>[Conexiones.tsx]"]
  node_ui_kit["UI components<br/>[kit.tsx]"]
  node_charts["Charts<br/>[graficas.tsx]"]
end

node_patient(("Patient"))

node_patient -->|"calls through"| node_telephony
node_telephony -->|"reaches agent"| node_agent_prompt
node_agent_prompt -->|"uses settings"| node_agent_config
node_agent_prompt -->|"uses tools"| node_agent_tools
node_agent_tools -->|"calls tools"| node_worker_entry
node_worker_entry -->|"routes tools"| node_tool_handlers
node_tool_handlers -->|"calls booking"| node_booking
node_booking -->|"locks slots"| node_clinic_state
node_booking -->|"reads / writes"| node_sheet_access
node_booking -->|"runs calendar actions"| node_composio
node_composio -->|"accesses calendars"| node_calendar
node_tool_handlers -->|"records tools"| node_sheet_access
node_sheet_access -->|"executes sheet actions"| node_composio
node_sheet_access -->|"reads / writes"| node_sheets
node_tool_handlers -.->|"sends confirmations"| node_whatsapp
node_call_sync -->|"fetches calls"| node_eleven_api
node_call_sync -->|"stores calls"| node_sheet_access
node_call_sync -->|"creates urgent follow-ups"| node_tool_handlers
node_worker_entry -->|"schedules sync"| node_call_sync
node_installer -->|"sets up Google"| node_composio
node_installer -->|"creates sheet"| node_sheet_access
node_sheet_access -->|"uses preview rows"| node_demo_data
node_demo_data -->|"uses clinic data"| node_clinic_catalog
node_worker_entry -->|"routes API"| node_api
node_app -->|"requests panel data"| node_api
node_app -->|"shows sections"| node_dashboard
node_app -->|"shows sections"| node_call_views
node_app -->|"shows sections"| node_clinic_views
node_app -->|"shows settings"| node_agent_views
node_app -->|"shows setup"| node_connections_view
node_app -->|"uses components"| node_ui_kit
node_dashboard -->|"renders charts"| node_charts
node_api -->|"reads clinic records"| node_sheet_access
node_api -->|"loads call audio"| node_eleven_api
node_connections_view -->|"manages connections"| node_api

click node_agent_prompt "https://github.com/santmun/agente-marco/blob/main/agent/prompt.md"
click node_agent_config "https://github.com/santmun/agente-marco/blob/main/agent/configuracion.json"
click node_agent_tools "https://github.com/santmun/agente-marco/blob/main/agent/herramientas.json"
click node_worker_entry "https://github.com/santmun/agente-marco/blob/main/src/worker/index.ts"
click node_tool_handlers "https://github.com/santmun/agente-marco/blob/main/src/worker/herramientas.ts"
click node_booking "https://github.com/santmun/agente-marco/blob/main/src/worker/agenda.ts"
click node_clinic_state "https://github.com/santmun/agente-marco/blob/main/src/worker/estado.ts"
click node_sheet_access "https://github.com/santmun/agente-marco/blob/main/src/worker/hoja.ts"
click node_composio "https://github.com/santmun/agente-marco/blob/main/src/worker/composio.ts"
click node_call_sync "https://github.com/santmun/agente-marco/blob/main/src/worker/sincronizar.ts"
click node_eleven_api "https://github.com/santmun/agente-marco/blob/main/src/worker/elevenlabs.ts"
click node_installer "https://github.com/santmun/agente-marco/blob/main/src/worker/instalar.ts"
click node_clinic_catalog "https://github.com/santmun/agente-marco/blob/main/src/worker/catalogo.ts"
click node_demo_data "https://github.com/santmun/agente-marco/blob/main/src/worker/demo.ts"
click node_api "https://github.com/santmun/agente-marco/blob/main/src/worker/api.ts"
click node_app "https://github.com/santmun/agente-marco/blob/main/src/app/App.tsx"
click node_dashboard "https://github.com/santmun/agente-marco/tree/main/src/app/pages"
click node_call_views "https://github.com/santmun/agente-marco/tree/main/src/app/pages"
click node_clinic_views "https://github.com/santmun/agente-marco/tree/main/src/app/pages"
click node_agent_views "https://github.com/santmun/agente-marco/blob/main/src/app/pages/Marco.tsx"
click node_connections_view "https://github.com/santmun/agente-marco/blob/main/src/app/pages/Conexiones.tsx"
click node_ui_kit "https://github.com/santmun/agente-marco/blob/main/src/app/ui/kit.tsx"
click node_charts "https://github.com/santmun/agente-marco/blob/main/src/app/ui/graficas.tsx"

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_agent_prompt,node_agent_config,node_agent_tools toneBlue
class node_worker_entry,node_tool_handlers,node_booking,node_call_sync,node_installer,node_api toneAmber
class node_clinic_state,node_sheet_access,node_clinic_catalog,node_demo_data toneMint
class node_telephony,node_sheets,node_composio,node_calendar,node_whatsapp,node_eleven_api toneRose
class node_app,node_dashboard,node_call_views,node_clinic_views,node_agent_views,node_connections_view,node_ui_kit,node_charts,node_patient toneIndigo
```

## Components

### Voice agent

- [Agent prompt](https://github.com/santmun/agente-marco/blob/main/agent/prompt.md): `agent/prompt.md`
- [Agent settings](https://github.com/santmun/agente-marco/blob/main/agent/configuracion.json): `agent/configuracion.json`
- [Tool definitions](https://github.com/santmun/agente-marco/blob/main/agent/herramientas.json): `agent/herramientas.json`

### Worker runtime

- [Worker routing](https://github.com/santmun/agente-marco/blob/main/src/worker/index.ts): `src/worker/index.ts`
- [Call tools](https://github.com/santmun/agente-marco/blob/main/src/worker/herramientas.ts): `src/worker/herramientas.ts`
- [Availability & booking](https://github.com/santmun/agente-marco/blob/main/src/worker/agenda.ts): `src/worker/agenda.ts`
- [Call synchronization](https://github.com/santmun/agente-marco/blob/main/src/worker/sincronizar.ts): `src/worker/sincronizar.ts`
- [Google setup](https://github.com/santmun/agente-marco/blob/main/src/worker/instalar.ts): `src/worker/instalar.ts`
- [Panel API](https://github.com/santmun/agente-marco/blob/main/src/worker/api.ts): `src/worker/api.ts`

### Clinic data

- [Locks & index](https://github.com/santmun/agente-marco/blob/main/src/worker/estado.ts): `src/worker/estado.ts`
- [Sheet access](https://github.com/santmun/agente-marco/blob/main/src/worker/hoja.ts): `src/worker/hoja.ts`
- [Clinic catalog](https://github.com/santmun/agente-marco/blob/main/src/worker/catalogo.ts): `src/worker/catalogo.ts`
- [Preview data](https://github.com/santmun/agente-marco/blob/main/src/worker/demo.ts): `src/worker/demo.ts`

### External services

- **Phone / SIP**
- **Sheets store**
- [Composio bridge](https://github.com/santmun/agente-marco/blob/main/src/worker/composio.ts): `src/worker/composio.ts`
- **Google Calendar**
- **WhatsApp**
- [ElevenLabs API](https://github.com/santmun/agente-marco/blob/main/src/worker/elevenlabs.ts): `src/worker/elevenlabs.ts`

### Control panel

- [Panel shell](https://github.com/santmun/agente-marco/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Summary & costs](https://github.com/santmun/agente-marco/tree/main/src/app/pages): `src/app/pages`
- [Calls & follow-ups](https://github.com/santmun/agente-marco/tree/main/src/app/pages): `src/app/pages`
- [Agenda & patients](https://github.com/santmun/agente-marco/tree/main/src/app/pages): `src/app/pages`
- [Agent & knowledge](https://github.com/santmun/agente-marco/blob/main/src/app/pages/Marco.tsx): `src/app/pages/Marco.tsx`
- [Connections setup](https://github.com/santmun/agente-marco/blob/main/src/app/pages/Conexiones.tsx): `src/app/pages/Conexiones.tsx`
- [UI components](https://github.com/santmun/agente-marco/blob/main/src/app/ui/kit.tsx): `src/app/ui/kit.tsx`
- [Charts](https://github.com/santmun/agente-marco/blob/main/src/app/ui/graficas.tsx): `src/app/ui/graficas.tsx`

### Other components

- **Patient**

## Connections

- Patient → Phone / SIP: calls through (evidence: `README.md`)
- Phone / SIP → Agent prompt: reaches agent (evidence: `README.md`)
- Agent prompt → Agent settings: uses settings (evidence: `README.md`)
- Agent prompt → Tool definitions: uses tools (evidence: `README.md`)
- Tool definitions → Worker routing: calls tools (evidence: `README.md`)
- Worker routing → Call tools: routes tools (evidence: `src/worker/index.ts`)
- Call tools → Availability & booking: calls booking (evidence: `src/worker/herramientas.ts`)
- Availability & booking → Locks & index: locks slots (evidence: `src/worker/agenda.ts`)
- Availability & booking → Sheet access: reads / writes (evidence: `src/worker/agenda.ts`)
- Availability & booking → Composio bridge: runs calendar actions (evidence: `src/worker/agenda.ts`)
- Composio bridge → Google Calendar: accesses calendars (evidence: `README.md`)
- Call tools → Sheet access: records tools (evidence: `src/worker/herramientas.ts`)
- Sheet access → Composio bridge: executes sheet actions (evidence: `src/worker/hoja.ts`)
- Sheet access → Sheets store: reads / writes (evidence: `README.md`)
- Call tools → WhatsApp: sends confirmations (evidence: `README.md`)
- Call synchronization → ElevenLabs API: fetches calls (evidence: `src/worker/sincronizar.ts`)
- Call synchronization → Sheet access: stores calls (evidence: `src/worker/sincronizar.ts`)
- Call synchronization → Call tools: creates urgent follow-ups (evidence: `src/worker/sincronizar.ts`)
- Worker routing → Call synchronization: schedules sync (evidence: `src/worker/index.ts`)
- Google setup → Composio bridge: sets up Google (evidence: `README.md`)
- Google setup → Sheet access: creates sheet (evidence: `src/worker/instalar.ts`)
- Sheet access → Preview data: uses preview rows (evidence: `src/worker/hoja.ts`)
- Preview data → Clinic catalog: uses clinic data (evidence: `src/worker/demo.ts`)
- Worker routing → Panel API: routes API (evidence: `src/worker/index.ts`)
- Panel shell → Panel API: requests panel data (evidence: `README.md`)
- Panel shell → Summary & costs: shows sections (evidence: `src/app/App.tsx`)
- Panel shell → Calls & follow-ups: shows sections (evidence: `src/app/App.tsx`)
- Panel shell → Agenda & patients: shows sections (evidence: `src/app/App.tsx`)
- Panel shell → Agent & knowledge: shows settings (evidence: `src/app/App.tsx`)
- Panel shell → Connections setup: shows setup (evidence: `src/app/App.tsx`)
- Panel shell → UI components: uses components (evidence: `src/app/App.tsx`)
- Summary & costs → Charts: renders charts (evidence: `src/app/pages/Resumen.tsx`)
- Panel API → Sheet access: reads clinic records (evidence: `src/worker/api.ts`)
- Panel API → ElevenLabs API: loads call audio (evidence: `src/worker/api.ts`)
- Connections setup → Panel API: manages connections (evidence: `README.md`)
