# erasable-mak/minipulse architecture

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

- Interactive diagram: https://gitdiagram.com/erasable-mak/minipulse
- Repository: https://github.com/erasable-mak/minipulse

## Overview

MiniPulse receives Slack mentions, verifies webhook signatures, acknowledges events, and processes accepted queries asynchronously. The adapter forwards each query to the AI service, which maintains per-thread memory and runs a Groq tool-calling loop; registered CRM tools query HubSpot, and the answer is posted back to the originating Slack thread. The graph preserves the documented contact and deal-query capabilities. Some wiring is based on README statements and the SOURCE INDEX; unsampled implementations are represented at their exact source paths.

Main entry points: [`services/ai-service/app/orchestrator.py`](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/orchestrator.py) (LLM Orchestrator), [`services/slack-adapter/app/handlers/events.py`](https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/handlers/events.py) (Mention Handler), [`services/slack-adapter/app/main.py`](https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/main.py) (Webhook API), [`services/ai-service/app/main.py`](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/main.py) (Query API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_slack["Slack Adapter"]
  node_adapter["Webhook API<br/>[main.py]"]
  node_signature["Signature Verification<br/>[signature.py]"]
  node_event_handler["Mention Handler<br/>[events.py]"]
end

subgraph group_intelligence["AI Orchestration"]
  node_ai_api["Query API<br/>[main.py]"]
  node_orchestrator["LLM Orchestrator<br/>[orchestrator.py]"]
  node_memory[("Thread Memory<br/>[memory.py]")]
end

subgraph group_crm["CRM Tools"]
  node_tool_registry["Tool Registry<br/>[registry.py]"]
  node_deal_tools["Deal Queries<br/>[deals.py]"]
  node_contact_tools["Contact Lookup<br/>[contacts.py]"]
  node_hubspot_client["HubSpot Client<br/>[hubspot.py]"]
end

subgraph group_integrations["External Services"]
  node_slack_platform["Slack Events/API"]
  node_groq["Groq LLM"]
  node_hubspot[("HubSpot CRM")]
end

node_user(("Slack User"))

node_user -->|"asks via"| node_slack_platform
node_slack_platform -->|"sends webhook"| node_adapter
node_adapter -->|"verifies request"| node_signature
node_adapter -->|"dispatches mention"| node_event_handler
node_event_handler -->|"posts query"| node_ai_api
node_ai_api -->|"processes query"| node_orchestrator
node_orchestrator -->|"reads and appends"| node_memory
node_orchestrator -->|"requests completions"| node_groq
node_orchestrator -->|"dispatches tools"| node_tool_registry
node_tool_registry -->|"registers"| node_deal_tools
node_tool_registry -->|"registers"| node_contact_tools
node_deal_tools -->|"searches deals"| node_hubspot_client
node_contact_tools -.->|"queries contacts"| node_hubspot_client
node_hubspot_client -->|"calls CRM API"| node_hubspot
node_ai_api -->|"returns answer"| node_event_handler
node_event_handler -->|"posts reply"| node_slack_platform
node_slack_platform -->|"delivers reply"| node_user

click node_adapter "https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/main.py"
click node_signature "https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/middleware/signature.py"
click node_event_handler "https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/handlers/events.py"
click node_ai_api "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/main.py"
click node_orchestrator "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/orchestrator.py"
click node_memory "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/memory.py"
click node_tool_registry "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/registry.py"
click node_deal_tools "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/deals.py"
click node_contact_tools "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/contacts.py"
click node_hubspot_client "https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/clients/hubspot.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_adapter,node_signature,node_event_handler,node_user toneBlue
class node_ai_api,node_orchestrator,node_memory toneAmber
class node_tool_registry,node_deal_tools,node_contact_tools,node_hubspot_client toneMint
class node_slack_platform,node_groq,node_hubspot toneRose
```

## Components

### Slack Adapter

- [Webhook API](https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/main.py): `services/slack-adapter/app/main.py`
- [Signature Verification](https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/middleware/signature.py): `services/slack-adapter/app/middleware/signature.py`
- [Mention Handler](https://github.com/erasable-mak/minipulse/blob/main/services/slack-adapter/app/handlers/events.py): `services/slack-adapter/app/handlers/events.py`

### AI Orchestration

- [Query API](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/main.py): `services/ai-service/app/main.py`
- [LLM Orchestrator](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/orchestrator.py): `services/ai-service/app/orchestrator.py`
- [Thread Memory](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/memory.py): `services/ai-service/app/memory.py`

### CRM Tools

- [Tool Registry](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/registry.py): `services/ai-service/app/tools/registry.py`
- [Deal Queries](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/deals.py): `services/ai-service/app/tools/deals.py`
- [Contact Lookup](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/tools/contacts.py): `services/ai-service/app/tools/contacts.py`
- [HubSpot Client](https://github.com/erasable-mak/minipulse/blob/main/services/ai-service/app/clients/hubspot.py): `services/ai-service/app/clients/hubspot.py`

### External Services

- **Slack Events/API**
- **Groq LLM**
- **HubSpot CRM**

### Other components

- **Slack User**

## Connections

- Slack User → Slack Events/API: asks via (evidence: `README.md`)
- Slack Events/API → Webhook API: sends webhook (evidence: `README.md`)
- Webhook API → Signature Verification: verifies request (evidence: `services/slack-adapter/app/main.py`)
- Webhook API → Mention Handler: dispatches mention (evidence: `services/slack-adapter/app/main.py`)
- Mention Handler → Query API: posts query (evidence: `services/slack-adapter/app/handlers/events.py`)
- Query API → LLM Orchestrator: processes query (evidence: `services/ai-service/app/main.py`)
- LLM Orchestrator → Thread Memory: reads and appends (evidence: `services/ai-service/app/orchestrator.py`)
- LLM Orchestrator → Groq LLM: requests completions (evidence: `README.md`)
- LLM Orchestrator → Tool Registry: dispatches tools (evidence: `services/ai-service/app/orchestrator.py`)
- Tool Registry → Deal Queries: registers (evidence: `services/ai-service/app/tools/registry.py`)
- Tool Registry → Contact Lookup: registers (evidence: `services/ai-service/app/tools/registry.py`)
- Deal Queries → HubSpot Client: searches deals (evidence: `services/ai-service/app/tools/deals.py`)
- Contact Lookup → HubSpot Client: queries contacts (evidence: `README.md`)
- HubSpot Client → HubSpot CRM: calls CRM API (evidence: `services/ai-service/app/clients/hubspot.py`)
- Query API → Mention Handler: returns answer (evidence: `README.md`)
- Mention Handler → Slack Events/API: posts reply (evidence: `services/slack-adapter/app/handlers/events.py`)
- Slack Events/API → Slack User: delivers reply (evidence: `README.md`)
