# kishorekola19/outbox-lab-assignment architecture

> Architecture diagram of the GitHub repository kishorekola19/outbox-lab-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kishorekola19/outbox-lab-assignment
- Repository: https://github.com/kishorekola19/outbox-lab-assignment

## Overview

ReachInbox is a full-stack email scheduling and lead-outreach platform. Users authenticate, prepare recipient lists, compose campaigns, and send immediately or schedule delivery; they can then review/search email status, connect Slack, and monitor queues. Scheduled campaigns persist in PostgreSQL and dispatch through BullMQ/Redis workers, with rate limiting, idempotency, Slack alerts, and Elasticsearch search. The README documents these capabilities; the sampled source confirms key controller, worker, auth, search, and integration behavior, but not every frontend/API or dispatch connection.

Main entry points: [`backend/src/workers/emailWorker.ts`](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/workers/emailWorker.ts) (Email worker), [`frontend/src/App.tsx`](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/App.tsx) (ReachInbox UI), [`backend/src/config/db.ts`](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/config/db.ts) (PostgreSQL), [`backend/src/server.ts`](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/server.ts) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["ReachInbox UI<br/>[App.tsx]"]
  node_compose["Compose campaigns<br/>[ComposePage.tsx]"]
  node_mailviews["Scheduled and sent<br/>[ScheduledPage.tsx]"]
  node_maildetail["Email details"]
  node_settings["Slack settings"]
  node_queueview["Queue dashboard<br/>[QueueAdminPage.tsx]"]
end

subgraph group_api["API and identity"]
  node_server["Express server<br/>[server.ts]"]
  node_authroutes["Auth routes<br/>[authRoutes.ts]"]
  node_authcontroller["Auth handlers<br/>[authController.ts]"]
  node_authservice["Identity service<br/>[authService.ts]"]
  node_emailroutes["Email routes<br/>[emailRoutes.ts]"]
  node_emailcontroller["Campaign handlers<br/>[emailController.ts]"]
  node_slackroutes["Slack routes<br/>[slackRoutes.ts]"]
  node_slackcontroller["Slack handlers<br/>[slackController.ts]"]
end

subgraph group_delivery["Campaign delivery"]
  node_postgres[("PostgreSQL<br/>[db.ts]")]
  node_queue["BullMQ queue<br/>[emailQueue.ts]"]
  node_redis[("Redis<br/>[redis.ts]")]
  node_worker["Email worker<br/>[emailWorker.ts]"]
  node_dispatch["Unified dispatch"]
end

subgraph group_integrations["Search and integrations"]
  node_gmail["Gmail OAuth and send<br/>[gmailService.ts]"]
  node_slackservice["Slack integration<br/>[slackService.ts]"]
  node_search[("Email search index<br/>[client.ts]")]
end

node_user(("Campaign user"))
node_gmailapi{{"Google Gmail API"}}
node_slack{{"Slack"}}

node_user -->|"uses"| node_webapp
node_webapp -->|"opens"| node_compose
node_webapp -->|"opens"| node_mailviews
node_webapp -->|"opens"| node_maildetail
node_webapp -->|"opens"| node_settings
node_webapp -->|"opens"| node_queueview
node_webapp -->|"REST requests"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_emailroutes
node_server -->|"mounts"| node_slackroutes
node_server -->|"starts"| node_worker
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"verifies identity"| node_authservice
node_authservice -->|"upserts users"| node_postgres
node_authcontroller -->|"reads connections"| node_postgres
node_emailroutes -->|"dispatches"| node_emailcontroller
node_emailcontroller -->|"stores campaigns"| node_postgres
node_emailcontroller -->|"enqueues jobs"| node_queue
node_emailcontroller -->|"dispatches now"| node_dispatch
node_emailcontroller -->|"indexes and searches"| node_search
node_queue -->|"delivers jobs"| node_worker
node_worker -->|"checks and updates"| node_postgres
node_worker -->|"checks rate limits"| node_redis
node_worker -->|"reschedules jobs"| node_queue
node_worker -->|"dispatches messages"| node_dispatch
node_worker -->|"alerts on limits"| node_slackservice
node_worker -->|"indexes sent mail"| node_search
node_dispatch -.->|"uses Gmail delivery"| node_gmail
node_gmail -->|"reads credentials"| node_postgres
node_gmail -->|"sends mail"| node_gmailapi
node_slackroutes -->|"dispatches"| node_slackcontroller
node_slackcontroller -->|"exchanges OAuth"| node_slackservice
node_slackcontroller -->|"reads and updates"| node_postgres
node_slackservice -->|"stores connection"| node_postgres
node_slackservice -->|"posts alerts"| node_slack
node_search -->|"fallback search"| node_postgres

click node_webapp "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/App.tsx"
click node_compose "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/ComposePage.tsx"
click node_mailviews "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/ScheduledPage.tsx"
click node_maildetail "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/EmailDetailPage.tsx"
click node_settings "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/SlackSettingsPage.tsx"
click node_queueview "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/QueueAdminPage.tsx"
click node_server "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/server.ts"
click node_authroutes "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/authRoutes.ts"
click node_authcontroller "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/authController.ts"
click node_authservice "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/auth/authService.ts"
click node_emailroutes "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/emailRoutes.ts"
click node_emailcontroller "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/emailController.ts"
click node_slackroutes "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/slackRoutes.ts"
click node_slackcontroller "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/slackController.ts"
click node_postgres "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/config/db.ts"
click node_queue "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/queues/emailQueue.ts"
click node_redis "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/config/redis.ts"
click node_worker "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/workers/emailWorker.ts"
click node_dispatch "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/services/unifiedEmailService.ts"
click node_gmail "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/services/gmailService.ts"
click node_slackservice "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/slack/slackService.ts"
click node_search "https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/elasticsearch/client.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_webapp,node_compose,node_mailviews,node_maildetail,node_settings,node_queueview,node_user toneBlue
class node_server,node_authroutes,node_authcontroller,node_authservice,node_emailroutes,node_emailcontroller,node_slackroutes,node_slackcontroller toneAmber
class node_postgres,node_queue,node_redis,node_worker,node_dispatch,node_gmailapi toneMint
class node_gmail,node_slackservice,node_search toneRose
class node_slack toneIndigo
```

## Components

### Web client

- [ReachInbox UI](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Compose campaigns](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/ComposePage.tsx): `frontend/src/pages/ComposePage.tsx`
- [Scheduled and sent](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/ScheduledPage.tsx): `frontend/src/pages/ScheduledPage.tsx`
- [Email details](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/EmailDetailPage.tsx): `frontend/src/pages/EmailDetailPage.tsx`
- [Slack settings](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/SlackSettingsPage.tsx): `frontend/src/pages/SlackSettingsPage.tsx`
- [Queue dashboard](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/frontend/src/pages/QueueAdminPage.tsx): `frontend/src/pages/QueueAdminPage.tsx`

### API and identity

- [Express server](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Auth routes](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/authRoutes.ts): `backend/src/routes/authRoutes.ts`
- [Auth handlers](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/authController.ts): `backend/src/controllers/authController.ts`
- [Identity service](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/auth/authService.ts): `backend/src/auth/authService.ts`
- [Email routes](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/emailRoutes.ts): `backend/src/routes/emailRoutes.ts`
- [Campaign handlers](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/emailController.ts): `backend/src/controllers/emailController.ts`
- [Slack routes](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/routes/slackRoutes.ts): `backend/src/routes/slackRoutes.ts`
- [Slack handlers](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/controllers/slackController.ts): `backend/src/controllers/slackController.ts`

### Campaign delivery

- [PostgreSQL](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/config/db.ts): `backend/src/config/db.ts`
- [BullMQ queue](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/queues/emailQueue.ts): `backend/src/queues/emailQueue.ts`
- [Redis](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/config/redis.ts): `backend/src/config/redis.ts`
- [Email worker](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/workers/emailWorker.ts): `backend/src/workers/emailWorker.ts`
- [Unified dispatch](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/services/unifiedEmailService.ts): `backend/src/services/unifiedEmailService.ts`

### Search and integrations

- [Gmail OAuth and send](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/services/gmailService.ts): `backend/src/services/gmailService.ts`
- [Slack integration](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/slack/slackService.ts): `backend/src/slack/slackService.ts`
- [Email search index](https://github.com/kishorekola19/outbox-lab-assignment/blob/main/backend/src/elasticsearch/client.ts): `backend/src/elasticsearch/client.ts`

### Other components

- **Campaign user**
- **Google Gmail API**
- **Slack**

## Connections

- Campaign user → ReachInbox UI: uses
- ReachInbox UI → Compose campaigns: opens
- ReachInbox UI → Scheduled and sent: opens
- ReachInbox UI → Email details: opens
- ReachInbox UI → Slack settings: opens
- ReachInbox UI → Queue dashboard: opens
- ReachInbox UI → Express server: REST requests
- Express server → Auth routes: mounts
- Express server → Email routes: mounts
- Express server → Slack routes: mounts
- Express server → Email worker: starts
- Auth routes → Auth handlers: dispatches
- Auth handlers → Identity service: verifies identity
- Identity service → PostgreSQL: upserts users
- Auth handlers → PostgreSQL: reads connections
- Email routes → Campaign handlers: dispatches
- Campaign handlers → PostgreSQL: stores campaigns
- Campaign handlers → BullMQ queue: enqueues jobs
- Campaign handlers → Unified dispatch: dispatches now
- Campaign handlers → Email search index: indexes and searches
- BullMQ queue → Email worker: delivers jobs
- Email worker → PostgreSQL: checks and updates
- Email worker → Redis: checks rate limits
- Email worker → BullMQ queue: reschedules jobs
- Email worker → Unified dispatch: dispatches messages
- Email worker → Slack integration: alerts on limits
- Email worker → Email search index: indexes sent mail
- Unified dispatch → Gmail OAuth and send: uses Gmail delivery
- Gmail OAuth and send → PostgreSQL: reads credentials
- Gmail OAuth and send → Google Gmail API: sends mail
- Slack routes → Slack handlers: dispatches
- Slack handlers → Slack integration: exchanges OAuth
- Slack handlers → PostgreSQL: reads and updates
- Slack integration → PostgreSQL: stores connection
- Slack integration → Slack: posts alerts
- Email search index → PostgreSQL: fallback search
