# yuvi-prog/tidio_converstation_mbtech architecture

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

- Interactive diagram: https://gitdiagram.com/yuvi-prog/tidio_converstation_mbtech
- Repository: https://github.com/yuvi-prog/tidio_converstation_mbtech

## Overview

This service collects chat messages, waits until a visitor’s conversation has been inactive, summarizes it, and emails a recap with a transcript link. The main flow begins at the chat-event endpoint and continues through polling, persistence, summarization, and delivery; a separate HTTP route serves stored transcripts. Gemini summarization and SendGrid delivery are visible in source, while the README is empty. The graph reflects the sampled files; the external chat client’s integration details are not shown.

Main entry points: [`poller.js`](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/poller.js) (Session poller), [`index.js`](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/index.js) (HTTP service), [`db.js`](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/db.js) (SQLite database), [`summarize.js`](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/summarize.js) (Summary builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Collection and entrypoints"]
  node_http_service["HTTP service<br/>[index.js]"]
  node_poll_scheduler["Poll scheduler<br/>[index.js]"]
end

subgraph group_processing["Session processing and delivery"]
  node_session_poller["Session poller<br/>[poller.js]"]
  node_summary_builder["Summary builder<br/>[summarize.js]"]
  node_email_sender["Email sender<br/>[email.js]"]
end

subgraph group_storage["Persistence and transcript access"]
  node_transcript_route["Transcript route<br/>[transcript.js]"]
  node_sqlite[("SQLite database<br/>[db.js]")]
end

node_chat_client(("Chat client"))
node_gemini{{"Gemini API"}}
node_sendgrid{{"SendGrid"}}

node_chat_client -.->|"posts events"| node_http_service
node_http_service -->|"writes events"| node_sqlite
node_http_service -->|"mounts route"| node_transcript_route
node_poll_scheduler -->|"runs poll"| node_session_poller
node_session_poller -->|"reads and writes"| node_sqlite
node_session_poller -->|"requests summary"| node_summary_builder
node_summary_builder -.->|"generates summary"| node_gemini
node_session_poller -->|"sends recap"| node_email_sender
node_email_sender -->|"dispatches email"| node_sendgrid
node_transcript_route -->|"loads transcript"| node_sqlite

click node_http_service "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/index.js"
click node_poll_scheduler "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/index.js"
click node_session_poller "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/poller.js"
click node_summary_builder "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/summarize.js"
click node_email_sender "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/email.js"
click node_transcript_route "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/transcript.js"
click node_sqlite "https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/db.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_http_service,node_poll_scheduler,node_chat_client toneBlue
class node_session_poller,node_summary_builder,node_email_sender toneAmber
class node_transcript_route,node_sqlite,node_gemini toneMint
class node_sendgrid toneIndigo
```

## Components

### Collection and entrypoints

- [HTTP service](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/index.js): `index.js`
- [Poll scheduler](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/index.js): `index.js`

### Session processing and delivery

- [Session poller](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/poller.js): `poller.js`
- [Summary builder](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/summarize.js): `summarize.js`
- [Email sender](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/email.js): `email.js`

### Persistence and transcript access

- [Transcript route](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/transcript.js): `transcript.js`
- [SQLite database](https://github.com/yuvi-prog/tidio_converstation_mbtech/blob/main/db.js): `db.js`

### Other components

- **Chat client**
- **Gemini API**
- **SendGrid**

## Connections

- Chat client → HTTP service: posts events
- HTTP service → SQLite database: writes events (evidence: `index.js`)
- HTTP service → Transcript route: mounts route (evidence: `index.js`)
- Poll scheduler → Session poller: runs poll (evidence: `index.js`)
- Session poller → SQLite database: reads and writes (evidence: `poller.js`)
- Session poller → Summary builder: requests summary (evidence: `poller.js`)
- Summary builder → Gemini API: generates summary (evidence: `summarize.js`)
- Session poller → Email sender: sends recap (evidence: `poller.js`)
- Email sender → SendGrid: dispatches email (evidence: `email.js`)
- Transcript route → SQLite database: loads transcript (evidence: `transcript.js`)
