# pedrosarni/hackfood-2026 architecture

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

- Interactive diagram: https://gitdiagram.com/pedrosarni/hackfood-2026
- Repository: https://github.com/pedrosarni/hackfood-2026

## Overview

Hackathon repository implementing a WhatsApp grocery-ordering bot integrated with iFood, plus an operational analytics dashboard. The main workflow receives a WhatsApp message, buffers it, and runs the conversation flow: interpretation and order handling lead to iFood actions and replies; background paths support follow-ups and order tracking. A separate panel records conversation and integration events and provides dashboard analytics and AI-generated insights. Some dashboard-to-backend wiring and unsampled subsystem behavior are not shown, so those links are omitted.

Main entry points: [`src/bot/contexto.py`](https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/contexto.py) (Bot context), [`Frontend/Rascunho_Dash/app.jsx`](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/app.jsx) (Dashboard app), [`src/app.py`](https://github.com/pedrosarni/hackfood-2026/blob/main/src/app.py) (Webhook and jobs), [`src/bot/fluxo.py`](https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/fluxo.py) (Order conversation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation runtime"]
  node_app["Webhook and jobs<br/>[app.py]"]
  node_buffer["Message buffer<br/>[buffer.py]"]
  node_context["Bot context<br/>[contexto.py]"]
  node_flow["Order conversation<br/>[fluxo.py]"]
  node_interpret["Message interpretation<br/>[interpretar.py]"]
  node_order_features["Order features"]
  node_agent_router["Agent routing<br/>[__init__.py]"]
end

subgraph group_integrations["External services"]
  node_whatsapp["WhatsApp API<br/>[whatsapp.py]"]
  node_ifood["iFood MCP and OAuth<br/>[ifood_mcp.py]"]
  node_llm["LLM services<br/>[llm.py]"]
  node_meta["Meta Cloud API"]
  node_ifood_service["iFood services"]
  node_model_service["Gemini and fallback"]
end

subgraph group_operations["Operations and insights"]
  node_panel_server["Panel server<br/>[servidor.py]"]
  node_diary["Event diary and spies<br/>[painel.py]"]
  node_analyst["Page insights<br/>[analista.py]"]
  node_analyst_agent["Analyst agent profile<br/>[analista.py]"]
end

subgraph group_dashboard["Analytics dashboard"]
  node_dashboard["Dashboard app<br/>[app.jsx]"]
  node_dashboard_data["Dashboard metrics<br/>[data.js]"]
  node_dashboard_sections["Team and agent views<br/>[equipe.jsx]"]
  node_dashboard_insights["Insights view<br/>[insights.jsx]"]
  node_dashboard_reports["PDF reporting<br/>[pdf-report.js]"]
end

node_customer(("WhatsApp customer"))
node_dashboard_user(("Dashboard operator"))

node_customer -->|"sends message"| node_meta
node_meta -->|"posts webhook"| node_app
node_app -->|"queues messages"| node_buffer
node_app -->|"runs conversation"| node_flow
node_flow -.->|"uses services"| node_context
node_flow -->|"interprets input"| node_interpret
node_flow -->|"dispatches actions"| node_order_features
node_context -->|"routes model calls"| node_agent_router
node_context -->|"calls tools"| node_ifood
node_context -->|"generates JSON"| node_llm
node_context -->|"sends and fetches"| node_whatsapp
node_whatsapp -->|"calls Graph API"| node_meta
node_ifood -->|"calls MCP"| node_ifood_service
node_llm -->|"requests generation"| node_model_service
node_app -->|"records activity"| node_diary
node_panel_server -->|"reads panel data"| node_diary
node_panel_server -->|"requests insights"| node_analyst
node_analyst -->|"uses profile"| node_analyst_agent
node_dashboard_user -.->|"views analytics"| node_dashboard
node_dashboard -->|"uses metrics"| node_dashboard_data
node_dashboard -->|"renders sections"| node_dashboard_sections
node_dashboard -->|"renders insights"| node_dashboard_insights
node_dashboard -->|"downloads report"| node_dashboard_reports

click node_app "https://github.com/pedrosarni/hackfood-2026/blob/main/src/app.py"
click node_buffer "https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/buffer.py"
click node_context "https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/contexto.py"
click node_flow "https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/fluxo.py"
click node_interpret "https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/interpretar.py"
click node_order_features "https://github.com/pedrosarni/hackfood-2026/tree/main/src/bot"
click node_agent_router "https://github.com/pedrosarni/hackfood-2026/blob/main/src/agentes/__init__.py"
click node_whatsapp "https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/whatsapp.py"
click node_ifood "https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/ifood_mcp.py"
click node_llm "https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/llm.py"
click node_panel_server "https://github.com/pedrosarni/hackfood-2026/blob/main/src/painel/servidor.py"
click node_diary "https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/painel.py"
click node_analyst "https://github.com/pedrosarni/hackfood-2026/blob/main/src/painel/analista.py"
click node_analyst_agent "https://github.com/pedrosarni/hackfood-2026/blob/main/src/agentes/analista.py"
click node_dashboard "https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/app.jsx"
click node_dashboard_data "https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/data.js"
click node_dashboard_sections "https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/equipe.jsx"
click node_dashboard_insights "https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/insights.jsx"
click node_dashboard_reports "https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/pdf-report.js"

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_app,node_buffer,node_context,node_flow,node_interpret,node_order_features,node_agent_router toneBlue
class node_whatsapp,node_ifood,node_llm,node_meta,node_ifood_service,node_model_service toneAmber
class node_panel_server,node_diary,node_analyst,node_analyst_agent toneMint
class node_dashboard,node_dashboard_data,node_dashboard_sections,node_dashboard_insights,node_dashboard_reports toneRose
class node_customer,node_dashboard_user toneIndigo
```

## Components

### Conversation runtime

- [Webhook and jobs](https://github.com/pedrosarni/hackfood-2026/blob/main/src/app.py): `src/app.py`
- [Message buffer](https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/buffer.py): `src/shared/buffer.py`
- [Bot context](https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/contexto.py): `src/bot/contexto.py`
- [Order conversation](https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/fluxo.py): `src/bot/fluxo.py`
- [Message interpretation](https://github.com/pedrosarni/hackfood-2026/blob/main/src/bot/interpretar.py): `src/bot/interpretar.py`
- [Order features](https://github.com/pedrosarni/hackfood-2026/tree/main/src/bot): `src/bot`
- [Agent routing](https://github.com/pedrosarni/hackfood-2026/blob/main/src/agentes/__init__.py): `src/agentes/__init__.py`

### External services

- [WhatsApp API](https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/whatsapp.py): `src/shared/whatsapp.py`
- [iFood MCP and OAuth](https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/ifood_mcp.py): `src/shared/ifood_mcp.py`
- [LLM services](https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/llm.py): `src/shared/llm.py`
- **Meta Cloud API**
- **iFood services**
- **Gemini and fallback**

### Operations and insights

- [Panel server](https://github.com/pedrosarni/hackfood-2026/blob/main/src/painel/servidor.py): `src/painel/servidor.py`
- [Event diary and spies](https://github.com/pedrosarni/hackfood-2026/blob/main/src/shared/painel.py): `src/shared/painel.py`
- [Page insights](https://github.com/pedrosarni/hackfood-2026/blob/main/src/painel/analista.py): `src/painel/analista.py`
- [Analyst agent profile](https://github.com/pedrosarni/hackfood-2026/blob/main/src/agentes/analista.py): `src/agentes/analista.py`

### Analytics dashboard

- [Dashboard app](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/app.jsx): `Frontend/Rascunho_Dash/app.jsx`
- [Dashboard metrics](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/data.js): `Frontend/Rascunho_Dash/data.js`
- [Team and agent views](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/equipe.jsx): `Frontend/Rascunho_Dash/equipe.jsx`
- [Insights view](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/insights.jsx): `Frontend/Rascunho_Dash/insights.jsx`
- [PDF reporting](https://github.com/pedrosarni/hackfood-2026/blob/main/Frontend/Rascunho_Dash/pdf-report.js): `Frontend/Rascunho_Dash/pdf-report.js`

### Other components

- **WhatsApp customer**
- **Dashboard operator**

## Connections

- WhatsApp customer → Meta Cloud API: sends message
- Meta Cloud API → Webhook and jobs: posts webhook
- Webhook and jobs → Message buffer: queues messages (evidence: `src/app.py`)
- Webhook and jobs → Order conversation: runs conversation (evidence: `src/app.py`)
- Order conversation → Bot context: uses services
- Order conversation → Message interpretation: interprets input (evidence: `src/bot/fluxo.py`)
- Order conversation → Order features: dispatches actions (evidence: `src/bot/fluxo.py`)
- Bot context → Agent routing: routes model calls (evidence: `src/bot/contexto.py`)
- Bot context → iFood MCP and OAuth: calls tools (evidence: `src/bot/contexto.py`)
- Bot context → LLM services: generates JSON (evidence: `src/bot/contexto.py`)
- Bot context → WhatsApp API: sends and fetches (evidence: `src/bot/contexto.py`)
- WhatsApp API → Meta Cloud API: calls Graph API (evidence: `src/shared/whatsapp.py`)
- iFood MCP and OAuth → iFood services: calls MCP (evidence: `src/shared/ifood_mcp.py`)
- LLM services → Gemini and fallback: requests generation (evidence: `src/shared/llm.py`)
- Webhook and jobs → Event diary and spies: records activity (evidence: `src/shared/painel.py`)
- Panel server → Event diary and spies: reads panel data (evidence: `src/painel/servidor.py`)
- Panel server → Page insights: requests insights (evidence: `src/painel/servidor.py`)
- Page insights → Analyst agent profile: uses profile (evidence: `src/painel/analista.py`)
- Dashboard operator → Dashboard app: views analytics
- Dashboard app → Dashboard metrics: uses metrics (evidence: `Frontend/Rascunho_Dash/app.jsx`)
- Dashboard app → Team and agent views: renders sections (evidence: `Frontend/Rascunho_Dash/app.jsx`)
- Dashboard app → Insights view: renders insights (evidence: `Frontend/Rascunho_Dash/app.jsx`)
- Dashboard app → PDF reporting: downloads report (evidence: `Frontend/Rascunho_Dash/app.jsx`)
