# yaswanthkillampalli/mail-ops architecture

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

- Interactive diagram: https://gitdiagram.com/yaswanthkillampalli/mail-ops
- Repository: https://github.com/yaswanthkillampalli/mail-ops

## Overview

MailOps ingests support email through a Resend webhook, persists it, and runs Groq triage alongside Cerebras deep analysis. Supervisors then review live email and analysis data, reply or create tickets, manage assignments and ticket status, and monitor operational/model metrics. The graph preserves the documented product areas; some API routes and UI components are unsampled, so their internal connections are included only where the README or excerpts establish them.

Main entry points: [`app/api`](https://github.com/yaswanthkillampalli/mail-ops/tree/main/app/api) (Dashboard APIs), [`lib/realtime.ts`](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/realtime.ts) (Realtime refresh), [`lib/supabase.ts`](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/supabase.ts) (Supabase database), [`app/dashboard/emails/page.tsx`](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/emails/page.tsx) (Email workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Email ingestion"]
  node_webhook["Inbound webhook<br/>[route.ts]"]
  node_email_save["Email persistence<br/>[emails.ts]"]
end

subgraph group_analysis["AI analysis"]
  node_email_analysis["Analysis orchestrator<br/>[email_analysis.ts]"]
  node_groq["Groq triage<br/>[classify.ts]"]
  node_cerebras["Cerebras analysis<br/>[analyze.ts]"]
  node_staff_suggestion["Staff suggestion<br/>[suggestStaff.ts]"]
end

subgraph group_operations["Supervisor operations"]
  node_dashboard["Operations overview<br/>[page.tsx]"]
  node_email_page["Email workspace<br/>[page.tsx]"]
  node_email_list["Email list<br/>[EmailList.tsx]"]
  node_email_detail["Email detail<br/>[EmailDetail.tsx]"]
  node_tickets_page["Ticket kanban<br/>[page.tsx]"]
  node_kanban["Kanban board<br/>[KanbanBoard.tsx]"]
  node_replies_page["Replies log<br/>[page.tsx]"]
  node_replies_list["Replies list<br/>[RepliesList.tsx]"]
  node_reply_detail["Reply detail<br/>[ReplyDetail.tsx]"]
  node_monitoring_page["AI monitoring<br/>[page.tsx]"]
  node_monitoring_charts["Monitoring charts"]
  node_stats_cards["Monitoring stats<br/>[StatCards.tsx]"]
end

subgraph group_persistence["Data and integrations"]
  node_api_routes["Dashboard APIs"]
  node_queries["Domain queries<br/>[queries.ts]"]
  node_supabase[("Supabase database<br/>[supabase.ts]")]
  node_realtime["Realtime refresh<br/>[realtime.ts]"]
end

node_sender(("Support sender"))
node_resend_inbound{{"Resend inbound"}}
node_resend{{"Resend mail API"}}

node_sender -->|"sends email"| node_resend_inbound
node_resend_inbound -->|"posts webhook"| node_webhook
node_webhook -->|"saves email"| node_email_save
node_email_save -.->|"stores email"| node_supabase
node_email_save -.->|"starts analysis"| node_email_analysis
node_email_analysis -->|"runs triage"| node_groq
node_email_analysis -->|"runs analysis"| node_cerebras
node_groq -->|"writes triage"| node_supabase
node_cerebras -->|"writes results"| node_supabase
node_dashboard -->|"fetches overview"| node_api_routes
node_dashboard -->|"refreshes on changes"| node_realtime
node_email_page -->|"fetches emails"| node_api_routes
node_email_page -->|"refreshes on changes"| node_realtime
node_email_page -->|"renders list"| node_email_list
node_email_page -->|"renders detail"| node_email_detail
node_email_detail -->|"updates and acts"| node_api_routes
node_api_routes -->|"calls domain queries"| node_queries
node_api_routes -->|"updates email"| node_supabase
node_api_routes -->|"sends reply"| node_resend
node_queries -->|"reads and writes"| node_supabase
node_tickets_page -->|"fetches tickets"| node_api_routes
node_tickets_page -->|"refreshes on changes"| node_realtime
node_tickets_page -->|"renders board"| node_kanban
node_replies_page -->|"refreshes on changes"| node_realtime
node_replies_page -->|"renders history"| node_replies_list
node_replies_page -->|"renders detail"| node_reply_detail
node_monitoring_page -->|"fetches metrics"| node_api_routes
node_monitoring_page -->|"refreshes on changes"| node_realtime
node_monitoring_page -->|"renders charts"| node_monitoring_charts
node_monitoring_page -->|"renders metrics"| node_stats_cards
node_api_routes -->|"requests suggestion"| node_staff_suggestion
node_staff_suggestion -->|"uses staff roster"| node_queries
node_realtime -.->|"subscribes to changes"| node_supabase

click node_webhook "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/api/webhook/route.ts"
click node_email_save "https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/emails.ts"
click node_email_analysis "https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/email_analysis.ts"
click node_groq "https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/groq/classify.ts"
click node_cerebras "https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/cerebras/analyze.ts"
click node_staff_suggestion "https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/groq/suggestStaff.ts"
click node_dashboard "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/page.tsx"
click node_email_page "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/emails/page.tsx"
click node_email_list "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/EmailList.tsx"
click node_email_detail "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/EmailDetail.tsx"
click node_tickets_page "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/tickets/page.tsx"
click node_kanban "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/KanbanBoard.tsx"
click node_replies_page "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/replies/page.tsx"
click node_replies_list "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/RepliesList.tsx"
click node_reply_detail "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/ReplyDetail.tsx"
click node_monitoring_page "https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/monitoring/page.tsx"
click node_monitoring_charts "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/PriorityDistributionChart.tsx"
click node_stats_cards "https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/StatCards.tsx"
click node_api_routes "https://github.com/yaswanthkillampalli/mail-ops/tree/main/app/api"
click node_queries "https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/queries.ts"
click node_supabase "https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/supabase.ts"
click node_realtime "https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/realtime.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_webhook,node_email_save toneBlue
class node_email_analysis,node_groq,node_cerebras,node_staff_suggestion toneAmber
class node_dashboard,node_email_page,node_email_list,node_email_detail,node_tickets_page,node_kanban,node_replies_page,node_replies_list,node_reply_detail,node_monitoring_page,node_monitoring_charts,node_stats_cards,node_resend toneMint
class node_api_routes,node_queries,node_supabase,node_realtime toneRose
class node_sender,node_resend_inbound toneIndigo
```

## Components

### Email ingestion

- [Inbound webhook](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/api/webhook/route.ts): `app/api/webhook/route.ts`
- [Email persistence](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/emails.ts): `lib/emails.ts`

### AI analysis

- [Analysis orchestrator](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/email_analysis.ts): `lib/email_analysis.ts`
- [Groq triage](https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/groq/classify.ts): `llm-components/groq/classify.ts`
- [Cerebras analysis](https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/cerebras/analyze.ts): `llm-components/cerebras/analyze.ts`
- [Staff suggestion](https://github.com/yaswanthkillampalli/mail-ops/blob/main/llm-components/groq/suggestStaff.ts): `llm-components/groq/suggestStaff.ts`

### Supervisor operations

- [Operations overview](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Email workspace](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/emails/page.tsx): `app/dashboard/emails/page.tsx`
- [Email list](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/EmailList.tsx): `components/EmailList.tsx`
- [Email detail](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/EmailDetail.tsx): `components/EmailDetail.tsx`
- [Ticket kanban](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/tickets/page.tsx): `app/dashboard/tickets/page.tsx`
- [Kanban board](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/KanbanBoard.tsx): `components/KanbanBoard.tsx`
- [Replies log](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/replies/page.tsx): `app/dashboard/replies/page.tsx`
- [Replies list](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/RepliesList.tsx): `components/RepliesList.tsx`
- [Reply detail](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/ReplyDetail.tsx): `components/ReplyDetail.tsx`
- [AI monitoring](https://github.com/yaswanthkillampalli/mail-ops/blob/main/app/dashboard/monitoring/page.tsx): `app/dashboard/monitoring/page.tsx`
- [Monitoring charts](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/PriorityDistributionChart.tsx): `components/PriorityDistributionChart.tsx`
- [Monitoring stats](https://github.com/yaswanthkillampalli/mail-ops/blob/main/components/StatCards.tsx): `components/StatCards.tsx`

### Data and integrations

- [Dashboard APIs](https://github.com/yaswanthkillampalli/mail-ops/tree/main/app/api): `app/api`
- [Domain queries](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/queries.ts): `lib/queries.ts`
- [Supabase database](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/supabase.ts): `lib/supabase.ts`
- [Realtime refresh](https://github.com/yaswanthkillampalli/mail-ops/blob/main/lib/realtime.ts): `lib/realtime.ts`

### Other components

- **Support sender**
- **Resend inbound**
- **Resend mail API**

## Connections

- Support sender → Resend inbound: sends email
- Resend inbound → Inbound webhook: posts webhook
- Inbound webhook → Email persistence: saves email (evidence: `app/api/webhook/route.ts`)
- Email persistence → Supabase database: stores email
- Email persistence → Analysis orchestrator: starts analysis
- Analysis orchestrator → Groq triage: runs triage (evidence: `lib/email_analysis.ts`)
- Analysis orchestrator → Cerebras analysis: runs analysis (evidence: `lib/email_analysis.ts`)
- Groq triage → Supabase database: writes triage
- Cerebras analysis → Supabase database: writes results
- Operations overview → Dashboard APIs: fetches overview (evidence: `app/dashboard/page.tsx`)
- Operations overview → Realtime refresh: refreshes on changes (evidence: `app/dashboard/page.tsx`)
- Email workspace → Dashboard APIs: fetches emails (evidence: `app/dashboard/emails/page.tsx`)
- Email workspace → Realtime refresh: refreshes on changes (evidence: `app/dashboard/emails/page.tsx`)
- Email workspace → Email list: renders list (evidence: `app/dashboard/emails/page.tsx`)
- Email workspace → Email detail: renders detail (evidence: `app/dashboard/emails/page.tsx`)
- Email detail → Dashboard APIs: updates and acts (evidence: `components/EmailDetail.tsx`)
- Dashboard APIs → Domain queries: calls domain queries (evidence: `app/api/tickets/route.ts`)
- Dashboard APIs → Supabase database: updates email (evidence: `app/api/emails/[id]/route.ts`)
- Dashboard APIs → Resend mail API: sends reply (evidence: `app/api/emails/[id]/reply/route.ts`)
- Domain queries → Supabase database: reads and writes (evidence: `lib/queries.ts`)
- Ticket kanban → Dashboard APIs: fetches tickets (evidence: `app/dashboard/tickets/page.tsx`)
- Ticket kanban → Realtime refresh: refreshes on changes (evidence: `app/dashboard/tickets/page.tsx`)
- Ticket kanban → Kanban board: renders board (evidence: `app/dashboard/tickets/page.tsx`)
- Replies log → Realtime refresh: refreshes on changes (evidence: `app/dashboard/replies/page.tsx`)
- Replies log → Replies list: renders history (evidence: `app/dashboard/replies/page.tsx`)
- Replies log → Reply detail: renders detail (evidence: `app/dashboard/replies/page.tsx`)
- AI monitoring → Dashboard APIs: fetches metrics (evidence: `app/dashboard/monitoring/page.tsx`)
- AI monitoring → Realtime refresh: refreshes on changes (evidence: `app/dashboard/monitoring/page.tsx`)
- AI monitoring → Monitoring charts: renders charts (evidence: `app/dashboard/monitoring/page.tsx`)
- AI monitoring → Monitoring stats: renders metrics (evidence: `app/dashboard/monitoring/page.tsx`)
- Dashboard APIs → Staff suggestion: requests suggestion (evidence: `app/api/ai/suggest-staff/route.ts`)
- Staff suggestion → Domain queries: uses staff roster
- Realtime refresh → Supabase database: subscribes to changes
