# shivamjuyal24/inflow architecture

> Architecture diagram of the GitHub repository shivamjuyal24/inflow, 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/shivamjuyal24/inflow
- Repository: https://github.com/shivamjuyal24/inflow

## Overview

Inflow is a Gmail triage application: users sign in, connect a Gmail mailbox, review classified messages and generated replies, then explicitly approve sending. The documented backend workflow fetches and parses mail, classifies it, persists categories and actions, and routes work to reply drafting or meeting analysis; separate draft and follow-up flows support review, sending, reconciliation, and later follow-ups. Edges use excerpts or README statements as evidence; unsampled implementations are represented only where documented.

Main entry points: [`backend/src/services/triage.service.ts`](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/triage.service.ts) (Triage coordinator), [`backend/src/config/supabase.ts`](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/supabase.ts) (Supabase data), [`frontend/src/App.tsx`](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/App.tsx) (Frontend routes), [`backend/src/graph/graph.ts`](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/graph.ts) (LangGraph workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Frontend routes<br/>[App.tsx]"]
  node_auth_ui["Sign-in state<br/>[AuthProvider.tsx]"]
  node_dashboard["Inbox dashboard<br/>[Dashboard.tsx]"]
  node_drafts_ui["Draft review<br/>[Drafts.tsx]"]
  node_draft_detail["Draft controls<br/>[DraftDetail.tsx]"]
  node_api["API client<br/>[apiClient.ts]"]
end

subgraph group_identity["Identity and mailbox"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_auth_controller["OAuth handling<br/>[auth.controller.ts]"]
  node_auth_middleware["Bearer auth<br/>[auth.middleware.ts]"]
  node_gmail["Gmail access<br/>[gmail.service.ts]"]
end

subgraph group_triage["Triage pipeline"]
  node_server["Server scheduler<br/>[server.ts]"]
  node_triage_service["Triage coordinator<br/>[triage.service.ts]"]
  node_sync["Mail ingestion"]
  node_parser["Email parsing<br/>[email.parser.ts]"]
  node_graph["LangGraph workflow<br/>[graph.ts]"]
  node_classify["Classification<br/>[jevClassifier.ts]"]
  node_actions["Action mapping<br/>[actionMapper.ts]"]
  node_email_routes["Email routes<br/>[email.routes.ts]"]
  node_email_controller["Inbox API"]
  node_triage_routes["Triage routes<br/>[triage.routes.ts]"]
end

subgraph group_review["Draft lifecycle"]
  node_draft_routes["Draft routes<br/>[draft.routes.ts]"]
  node_draft_controller["Draft lifecycle"]
  node_followup["Follow-up sweep"]
end

subgraph group_data["Persistence and providers"]
  node_db[("Supabase data<br/>[supabase.ts]")]
  node_groq["Groq models<br/>[groq.ts]"]
  node_jev["Jev classifier API<br/>[jevClassifier.ts]"]
  node_google["Google OAuth<br/>[google.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"provides state"| node_auth_ui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_drafts_ui
node_auth_ui -->|"authenticates"| node_db
node_dashboard -.->|"loads inbox"| node_api
node_drafts_ui -.->|"loads drafts"| node_api
node_drafts_ui -.->|"renders review"| node_draft_detail
node_user -->|"connects mailbox"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"guards"| node_auth_middleware
node_auth_controller -->|"uses OAuth"| node_google
node_auth_controller -->|"stores account"| node_db
node_server -->|"schedules"| node_triage_service
node_user -->|"triggers manually"| node_triage_routes
node_triage_routes -->|"dispatches"| node_triage_service
node_email_routes -->|"dispatches"| node_email_controller
node_email_controller -->|"runs triage"| node_triage_service
node_triage_service -->|"ingests mail"| node_sync
node_sync -->|"fetches messages"| node_gmail
node_sync -->|"parses messages"| node_parser
node_triage_service -->|"orchestrates"| node_graph
node_graph -->|"classifies"| node_classify
node_classify -->|"requests labels"| node_jev
node_graph -->|"derives actions"| node_actions
node_graph -->|"persists results"| node_db
node_draft_routes -->|"dispatches"| node_draft_controller
node_draft_routes -->|"guards"| node_auth_middleware
node_draft_controller -->|"reads and updates"| node_db
node_draft_controller -->|"sends approved reply"| node_gmail
node_draft_detail -.->|"approves or resolves"| node_draft_controller
node_server -->|"schedules sweep"| node_followup
node_followup -->|"checks and stores drafts"| node_db
node_followup -->|"generates follow-up"| node_groq

click node_app "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/App.tsx"
click node_auth_ui "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/auth/AuthProvider.tsx"
click node_dashboard "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/pages/Dashboard.tsx"
click node_drafts_ui "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/pages/Drafts.tsx"
click node_draft_detail "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/components/DraftDetail.tsx"
click node_api "https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/lib/apiClient.ts"
click node_auth_routes "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/auth.routes.ts"
click node_auth_controller "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/auth.controller.ts"
click node_auth_middleware "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/middleware/auth.middleware.ts"
click node_gmail "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/gmail.service.ts"
click node_server "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/server.ts"
click node_triage_service "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/triage.service.ts"
click node_sync "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/emailSync.service.ts"
click node_parser "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/email.parser.ts"
click node_graph "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/graph.ts"
click node_classify "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/jevClassifier.ts"
click node_actions "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/actionMapper.ts"
click node_email_routes "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/email.routes.ts"
click node_email_controller "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/email.controller.ts"
click node_triage_routes "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/triage.routes.ts"
click node_draft_routes "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/draft.routes.ts"
click node_draft_controller "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/draft.controller.ts"
click node_followup "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/followUp.service.ts"
click node_db "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/supabase.ts"
click node_groq "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/groq.ts"
click node_jev "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/jevClassifier.ts"
click node_google "https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/google.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_app,node_auth_ui,node_dashboard,node_drafts_ui,node_draft_detail,node_api,node_user toneBlue
class node_auth_routes,node_auth_controller,node_auth_middleware,node_gmail toneAmber
class node_server,node_triage_service,node_sync,node_parser,node_graph,node_classify,node_actions,node_email_routes,node_email_controller,node_triage_routes toneMint
class node_draft_routes,node_draft_controller,node_followup toneRose
class node_db,node_groq,node_jev,node_google toneIndigo
```

## Components

### Web application

- [Frontend routes](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sign-in state](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/auth/AuthProvider.tsx): `frontend/src/auth/AuthProvider.tsx`
- [Inbox dashboard](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Draft review](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/pages/Drafts.tsx): `frontend/src/pages/Drafts.tsx`
- [Draft controls](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/components/DraftDetail.tsx): `frontend/src/components/DraftDetail.tsx`
- [API client](https://github.com/shivamjuyal24/inflow/blob/main/frontend/src/lib/apiClient.ts): `frontend/src/lib/apiClient.ts`

### Identity and mailbox

- [Auth routes](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [OAuth handling](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/auth.controller.ts): `backend/src/controllers/auth.controller.ts`
- [Bearer auth](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/middleware/auth.middleware.ts): `backend/src/middleware/auth.middleware.ts`
- [Gmail access](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/gmail.service.ts): `backend/src/services/gmail.service.ts`

### Triage pipeline

- [Server scheduler](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Triage coordinator](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/triage.service.ts): `backend/src/services/triage.service.ts`
- [Mail ingestion](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/emailSync.service.ts): `backend/src/services/emailSync.service.ts`
- [Email parsing](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/email.parser.ts): `backend/src/services/email.parser.ts`
- [LangGraph workflow](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/graph.ts): `backend/src/graph/graph.ts`
- [Classification](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/jevClassifier.ts): `backend/src/graph/jevClassifier.ts`
- [Action mapping](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/actionMapper.ts): `backend/src/graph/actionMapper.ts`
- [Email routes](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/email.routes.ts): `backend/src/routes/email.routes.ts`
- [Inbox API](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/email.controller.ts): `backend/src/controllers/email.controller.ts`
- [Triage routes](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/triage.routes.ts): `backend/src/routes/triage.routes.ts`

### Draft lifecycle

- [Draft routes](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/routes/draft.routes.ts): `backend/src/routes/draft.routes.ts`
- [Draft lifecycle](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/controllers/draft.controller.ts): `backend/src/controllers/draft.controller.ts`
- [Follow-up sweep](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/services/followUp.service.ts): `backend/src/services/followUp.service.ts`

### Persistence and providers

- [Supabase data](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/supabase.ts): `backend/src/config/supabase.ts`
- [Groq models](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/groq.ts): `backend/src/config/groq.ts`
- [Jev classifier API](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/graph/jevClassifier.ts): `backend/src/graph/jevClassifier.ts`
- [Google OAuth](https://github.com/shivamjuyal24/inflow/blob/main/backend/src/config/google.ts): `backend/src/config/google.ts`

### Other components

- **User**

## Connections

- User → Frontend routes: uses (evidence: `frontend/src/App.tsx`)
- Frontend routes → Sign-in state: provides state (evidence: `frontend/src/App.tsx`)
- Frontend routes → Inbox dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Frontend routes → Draft review: routes to (evidence: `frontend/src/App.tsx`)
- Sign-in state → Supabase data: authenticates (evidence: `frontend/src/auth/AuthProvider.tsx`)
- Inbox dashboard → API client: loads inbox
- Draft review → API client: loads drafts
- Draft review → Draft controls: renders review
- User → Auth routes: connects mailbox (evidence: `README.md`)
- Auth routes → OAuth handling: dispatches (evidence: `backend/src/routes/auth.routes.ts`)
- Auth routes → Bearer auth: guards (evidence: `backend/src/routes/auth.routes.ts`)
- OAuth handling → Google OAuth: uses OAuth (evidence: `README.md`)
- OAuth handling → Supabase data: stores account (evidence: `README.md`)
- Server scheduler → Triage coordinator: schedules (evidence: `backend/src/server.ts`)
- User → Triage routes: triggers manually (evidence: `README.md`)
- Triage routes → Triage coordinator: dispatches (evidence: `README.md`)
- Email routes → Inbox API: dispatches
- Inbox API → Triage coordinator: runs triage (evidence: `backend/src/controllers/email.controller.ts`)
- Triage coordinator → Mail ingestion: ingests mail (evidence: `README.md`)
- Mail ingestion → Gmail access: fetches messages (evidence: `README.md`)
- Mail ingestion → Email parsing: parses messages (evidence: `README.md`)
- Triage coordinator → LangGraph workflow: orchestrates (evidence: `README.md`)
- LangGraph workflow → Classification: classifies (evidence: `README.md`)
- Classification → Jev classifier API: requests labels (evidence: `README.md`)
- LangGraph workflow → Action mapping: derives actions (evidence: `README.md`)
- LangGraph workflow → Supabase data: persists results (evidence: `README.md`)
- Draft routes → Draft lifecycle: dispatches (evidence: `backend/src/routes/draft.routes.ts`)
- Draft routes → Bearer auth: guards (evidence: `backend/src/routes/draft.routes.ts`)
- Draft lifecycle → Supabase data: reads and updates (evidence: `backend/src/controllers/draft.controller.ts`)
- Draft lifecycle → Gmail access: sends approved reply (evidence: `backend/src/controllers/draft.controller.ts`)
- Draft controls → Draft lifecycle: approves or resolves
- Server scheduler → Follow-up sweep: schedules sweep (evidence: `backend/src/server.ts`)
- Follow-up sweep → Supabase data: checks and stores drafts (evidence: `backend/src/services/followUp.service.ts`)
- Follow-up sweep → Groq models: generates follow-up (evidence: `backend/src/services/followUp.service.ts`)
