# bikramprasad/email-consumer architecture

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

- Interactive diagram: https://gitdiagram.com/bikramprasad/email-consumer
- Repository: https://github.com/bikramprasad/email-consumer

## Overview

SwiftDrop’s Email Consumer handles SNS notifications: its Lambda parses each message and delegates processing, which checks file and email state in MongoDB, sends receiver emails from an EJS template, updates status, then sends the sender a confirmation. The README also documents SNS subscription and deployment, but those configuration files were not sampled, so deployment wiring is not mapped. The graph reflects sampled calls; SMTP and MongoDB are documented integrations.

Main entry points: [`utils/sendEmailWithTemplate.js`](https://github.com/bikramprasad/email-consumer/blob/master/utils/sendEmailWithTemplate.js) (Message processor), [`utils/emailService.js`](https://github.com/bikramprasad/email-consumer/blob/master/utils/emailService.js) (Template email sender), [`handler.js`](https://github.com/bikramprasad/email-consumer/blob/master/handler.js) (Email Lambda), [`utils/db.js`](https://github.com/bikramprasad/email-consumer/blob/master/utils/db.js) (MongoDB connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Event handling"]
  node_lambda["Email Lambda<br/>[handler.js]"]
end

subgraph group_processing["Email processing"]
  node_processor["Message processor"]
end

subgraph group_data["Persistence"]
  node_dbconn["MongoDB connection<br/>[db.js]"]
  node_dbops["Email and file queries<br/>[emailDbOps.js]"]
end

subgraph group_delivery["Email delivery"]
  node_email["Template email sender<br/>[emailService.js]"]
  node_templates["Receiver and sender templates"]
end

node_sns(("AWS SNS"))
node_mongodb[("MongoDB")]
node_smtp["SMTP service"]

node_sns -.->|"triggers"| node_lambda
node_lambda -->|"delegates to"| node_processor
node_processor -->|"connects to"| node_dbconn
node_processor -->|"queries and updates"| node_dbops
node_processor -->|"sends notifications"| node_email
node_dbconn -.->|"connects to"| node_mongodb
node_dbops -.->|"reads and writes"| node_mongodb
node_email -->|"renders"| node_templates
node_email -.->|"sends mail"| node_smtp

click node_lambda "https://github.com/bikramprasad/email-consumer/blob/master/handler.js"
click node_processor "https://github.com/bikramprasad/email-consumer/blob/master/utils/sendEmailWithTemplate.js"
click node_dbconn "https://github.com/bikramprasad/email-consumer/blob/master/utils/db.js"
click node_dbops "https://github.com/bikramprasad/email-consumer/blob/master/utils/emailDbOps.js"
click node_email "https://github.com/bikramprasad/email-consumer/blob/master/utils/emailService.js"
click node_templates "https://github.com/bikramprasad/email-consumer/tree/master/templates"

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_lambda toneBlue
class node_processor,node_mongodb toneAmber
class node_dbconn,node_dbops toneMint
class node_email,node_templates toneRose
class node_sns,node_smtp toneIndigo
```

## Components

### Event handling

- [Email Lambda](https://github.com/bikramprasad/email-consumer/blob/master/handler.js): `handler.js`

### Email processing

- [Message processor](https://github.com/bikramprasad/email-consumer/blob/master/utils/sendEmailWithTemplate.js): `utils/sendEmailWithTemplate.js`

### Persistence

- [MongoDB connection](https://github.com/bikramprasad/email-consumer/blob/master/utils/db.js): `utils/db.js`
- [Email and file queries](https://github.com/bikramprasad/email-consumer/blob/master/utils/emailDbOps.js): `utils/emailDbOps.js`

### Email delivery

- [Template email sender](https://github.com/bikramprasad/email-consumer/blob/master/utils/emailService.js): `utils/emailService.js`
- [Receiver and sender templates](https://github.com/bikramprasad/email-consumer/tree/master/templates): `templates`

### Other components

- **AWS SNS**
- **MongoDB**
- **SMTP service**

## Connections

- AWS SNS → Email Lambda: triggers (evidence: `README.md`)
- Email Lambda → Message processor: delegates to (evidence: `handler.js`)
- Message processor → MongoDB connection: connects to (evidence: `utils/sendEmailWithTemplate.js`)
- Message processor → Email and file queries: queries and updates (evidence: `utils/sendEmailWithTemplate.js`)
- Message processor → Template email sender: sends notifications (evidence: `utils/sendEmailWithTemplate.js`)
- MongoDB connection → MongoDB: connects to
- Email and file queries → MongoDB: reads and writes
- Template email sender → Receiver and sender templates: renders (evidence: `utils/emailService.js`)
- Template email sender → SMTP service: sends mail
