# vercel-labs/eve-data-analyst-template architecture

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

- Interactive diagram: https://gitdiagram.com/vercel-labs/eve-data-analyst-template
- Repository: https://github.com/vercel-labs/eve-data-analyst-template

## Overview

This repository is a Slack-based data analyst: a user asks a business question, the eve agent discovers schema and definitions, executes guarded read-only SQL against Postgres, and responds in the thread, optionally with a chart or table and a SQL record. The graph preserves documented safety, access, memory, and Slack reply capabilities. Source excerpts show the Slack channel setup, query logging, visualization posting, and memory scoping; several tool and analyst implementations are not excerpted, so their internal call links are omitted.

Main entry points: [`agent/agent.ts`](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/agent.ts) (Eve analyst agent), [`agent/lib/integrations/slack/visualizations/post.ts`](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/visualizations/post.ts) (Visualization delivery), [`agent/tools/run_sql.ts`](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/run_sql.ts) (SQL execution tool), [`agent/lib/integrations/slack/channel.ts`](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/channel.ts) (Slack channel adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation and agent"]
  node_slack_channel["Slack channel adapter<br/>[channel.ts]"]
  node_agent["Eve analyst agent<br/>[agent.ts]"]
  node_instructions["Time instructions<br/>[current-time.ts]"]
  node_web_tools["Web search and fetch<br/>[web_search.ts]"]
end

subgraph group_analysis["Analyst query runtime"]
  node_schema_tool["Schema lookup<br/>[describe_schema.ts]"]
  node_schema_describe["Schema descriptions<br/>[describe-schema.ts]"]
  node_sql_tool["SQL execution tool<br/>[run_sql.ts]"]
  node_sql_runtime["Read-only SQL runtime<br/>[postgres.ts]"]
  node_postgres[("Postgres")]
  node_approval["Cost approval policy<br/>[approval.ts]"]
  node_query_log["Query log<br/>[query-log.ts]"]
end

subgraph group_slack["Slack responses"]
  node_approval_card["Approval card<br/>[approval-card.ts]"]
  node_sql_attachment["SQL reply attachment<br/>[sql-attachment.ts]"]
  node_chart_tool["Chart tool"]
  node_table_tool["Table tool"]
  node_visualization_post["Visualization delivery<br/>[post.ts]"]
  node_slack_api["Slack API<br/>[api.ts]"]
  node_thread["Slack thread"]
  node_reply["Text replies<br/>[replies.ts]"]
  node_continuation["Reply continuation"]
end

subgraph group_memory["Scoped memory"]
  node_memory_user["User preferences"]
  node_memory_channel["Channel preferences"]
  node_memory_scope["Memory scopes<br/>[scope.ts]"]
end

node_user(("Slack user"))

node_user -->|"asks question"| node_slack_channel
node_slack_channel -.->|"routes turn"| node_agent
node_agent -->|"looks up schema"| node_schema_tool
node_schema_tool -.->|"describes schema"| node_schema_describe
node_agent -->|"invokes SQL"| node_sql_tool
node_sql_tool -.->|"runs query"| node_sql_runtime
node_sql_runtime -->|"reads data"| node_postgres
node_sql_tool -.->|"checks cost"| node_approval
node_approval -->|"requests approval"| node_approval_card
node_approval_card -->|"registers input"| node_slack_channel
node_sql_tool -.->|"records query"| node_query_log
node_chart_tool -->|"posts chart"| node_visualization_post
node_table_tool -->|"posts table"| node_visualization_post
node_visualization_post -->|"reads turn queries"| node_query_log
node_visualization_post -->|"formats SQL"| node_sql_attachment
node_visualization_post -->|"posts message"| node_slack_api
node_slack_api -.->|"delivers blocks"| node_thread
node_agent -.->|"forms answer"| node_reply
node_reply -.->|"replies in thread"| node_thread
node_agent -.->|"uses preferences"| node_memory_user
node_agent -.->|"uses preferences"| node_memory_channel
node_memory_user -->|"scopes by principal"| node_memory_scope
node_memory_channel -->|"scopes by channel"| node_memory_scope
node_continuation -.->|"transfers queries"| node_query_log
node_agent -.->|"uses time context"| node_instructions
node_agent -->|"network disabled"| node_web_tools

click node_slack_channel "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/channel.ts"
click node_agent "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/agent.ts"
click node_instructions "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/instructions/current-time.ts"
click node_schema_tool "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/describe_schema.ts"
click node_schema_describe "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/tools/describe-schema.ts"
click node_sql_tool "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/run_sql.ts"
click node_sql_runtime "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/postgres.ts"
click node_approval "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/approval.ts"
click node_approval_card "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/approval-card.ts"
click node_query_log "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/query-log.ts"
click node_sql_attachment "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/sql-attachment.ts"
click node_chart_tool "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/post_slack_chart.ts"
click node_table_tool "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/post_slack_table.ts"
click node_visualization_post "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/visualizations/post.ts"
click node_slack_api "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/api.ts"
click node_reply "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/replies.ts"
click node_continuation "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/reply-continuation.ts"
click node_memory_user "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/memory/user-preferences.ts"
click node_memory_channel "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/memory/channel-preferences.ts"
click node_memory_scope "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/memory/scope.ts"
click node_web_tools "https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/web_search.ts"

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_slack_channel,node_agent,node_instructions,node_web_tools,node_user toneBlue
class node_schema_tool,node_schema_describe,node_sql_tool,node_sql_runtime,node_postgres,node_approval,node_query_log toneAmber
class node_approval_card,node_sql_attachment,node_chart_tool,node_table_tool,node_visualization_post,node_slack_api,node_thread,node_reply,node_continuation toneMint
class node_memory_user,node_memory_channel,node_memory_scope toneRose
```

## Components

### Conversation and agent

- [Slack channel adapter](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/channel.ts): `agent/lib/integrations/slack/channel.ts`
- [Eve analyst agent](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/agent.ts): `agent/agent.ts`
- [Time instructions](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/instructions/current-time.ts): `agent/instructions/current-time.ts`
- [Web search and fetch](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/web_search.ts): `agent/tools/web_search.ts`

### Analyst query runtime

- [Schema lookup](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/describe_schema.ts): `agent/tools/describe_schema.ts`
- [Schema descriptions](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/tools/describe-schema.ts): `agent/lib/tools/describe-schema.ts`
- [SQL execution tool](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/run_sql.ts): `agent/tools/run_sql.ts`
- [Read-only SQL runtime](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/postgres.ts): `agent/lib/analyst/postgres.ts`
- **Postgres**
- [Cost approval policy](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/approval.ts): `agent/lib/analyst/approval.ts`
- [Query log](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/query-log.ts): `agent/lib/analyst/query-log.ts`

### Slack responses

- [Approval card](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/approval-card.ts): `agent/lib/analyst/approval-card.ts`
- [SQL reply attachment](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/analyst/sql-attachment.ts): `agent/lib/analyst/sql-attachment.ts`
- [Chart tool](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/post_slack_chart.ts): `agent/tools/post_slack_chart.ts`
- [Table tool](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/tools/post_slack_table.ts): `agent/tools/post_slack_table.ts`
- [Visualization delivery](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/visualizations/post.ts): `agent/lib/integrations/slack/visualizations/post.ts`
- [Slack API](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/api.ts): `agent/lib/integrations/slack/api.ts`
- **Slack thread**
- [Text replies](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/replies.ts): `agent/lib/integrations/slack/replies.ts`
- [Reply continuation](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/integrations/slack/reply-continuation.ts): `agent/lib/integrations/slack/reply-continuation.ts`

### Scoped memory

- [User preferences](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/memory/user-preferences.ts): `agent/memory/user-preferences.ts`
- [Channel preferences](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/memory/channel-preferences.ts): `agent/memory/channel-preferences.ts`
- [Memory scopes](https://github.com/vercel-labs/eve-data-analyst-template/blob/main/agent/lib/memory/scope.ts): `agent/lib/memory/scope.ts`

### Other components

- **Slack user**

## Connections

- Slack user → Slack channel adapter: asks question
- Slack channel adapter → Eve analyst agent: routes turn
- Eve analyst agent → Schema lookup: looks up schema
- Schema lookup → Schema descriptions: describes schema
- Eve analyst agent → SQL execution tool: invokes SQL
- SQL execution tool → Read-only SQL runtime: runs query
- Read-only SQL runtime → Postgres: reads data
- SQL execution tool → Cost approval policy: checks cost
- Cost approval policy → Approval card: requests approval
- Approval card → Slack channel adapter: registers input (evidence: `agent/channels/slack.ts`)
- SQL execution tool → Query log: records query
- Chart tool → Visualization delivery: posts chart
- Table tool → Visualization delivery: posts table
- Visualization delivery → Query log: reads turn queries (evidence: `agent/lib/integrations/slack/visualizations/post.ts`)
- Visualization delivery → SQL reply attachment: formats SQL (evidence: `agent/lib/integrations/slack/visualizations/post.ts`)
- Visualization delivery → Slack API: posts message (evidence: `agent/lib/integrations/slack/visualizations/post.ts`)
- Slack API → Slack thread: delivers blocks
- Eve analyst agent → Text replies: forms answer
- Text replies → Slack thread: replies in thread
- Eve analyst agent → User preferences: uses preferences
- Eve analyst agent → Channel preferences: uses preferences
- User preferences → Memory scopes: scopes by principal (evidence: `agent/memory/user-preferences.ts`)
- Channel preferences → Memory scopes: scopes by channel (evidence: `agent/memory/channel-preferences.ts`)
- Reply continuation → Query log: transfers queries
- Eve analyst agent → Time instructions: uses time context
- Eve analyst agent → Web search and fetch: network disabled
