https://github.com/rohitramteke1/pearlthoughts-email-service-challenge
A resilient email delivery backend system built as part of the PearlThoughts internship challenge.
https://github.com/rohitramteke1/pearlthoughts-email-service-challenge
api-gateway aws-lambda aws-sam backend circuit-breaker email-service express idempotency internship-challenge nodejs queue-system rate-limiter retry-mechanism serverless
Last synced: 4 days ago
JSON representation
A resilient email delivery backend system built as part of the PearlThoughts internship challenge.
- Host: GitHub
- URL: https://github.com/rohitramteke1/pearlthoughts-email-service-challenge
- Owner: rohitramteke1
- License: other
- Created: 2025-06-08T04:01:52.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-06-08T04:06:13.000Z (4 months ago)
- Last Synced: 2025-08-16T16:48:25.490Z (about 2 months ago)
- Topics: api-gateway, aws-lambda, aws-sam, backend, circuit-breaker, email-service, express, idempotency, internship-challenge, nodejs, queue-system, rate-limiter, retry-mechanism, serverless
- Language: JavaScript
- Homepage: https://zkmvf4vzs8.execute-api.ap-south-1.amazonaws.com/Prod/api/email
- Size: 69.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Resilient Email Sending Service (Node.js + Express)
A fault-tolerant, scalable, and testable email sending service built with JavaScript. Designed for reliability using:
* Retry logic
* Provider fallback
* Circuit breakers
* Rate limiting
* Queue processing
* Idempotency
* Full unit test coverage## ✨ Features
- Retry mechanism with exponential backoff
- Fallback between multiple email providers
- Idempotency to prevent duplicate sends
- Rate limiting middleware
- Status tracking of email attempts
- Circuit breaker for both providers
- In-memory job queue with:* FIFO processing
* Pause/Resume capability
* Failed job retry
* Queue size limit
Logging via Winston
Unit tests with Jest & Supertest## Folder Structure
```
src/
├── app.js
├── controllers/
│ └── email.controller.js
├── services/
│ └── email.service.js
├── providers/
│ ├── providerA.js
│ └── providerB.js
├── utils/
│ ├── circuitBreaker.js
│ ├── emailQueue.js
│ ├── idempotency.js
│ ├── logger.js
│ ├── rateLimiter.js
│ └── statusTracker.js
tests/
├── email.test.js
└── queue.test.js
```## Getting Started
### 1️⃣ Clone & Install
```bash
git clone https://github.com/rohitramteke1/pearlthoughts-email-service-challenge
cd pearlthoughts-email-service-challenge
npm install
```### 2️⃣ Run the Server
```bash
npm start
```### 3️⃣ Run Tests
```bash
npm test
```## API Endpoint
### POST `/api/email`
**Body:**
```json
{
"to": "recipient@example.com",
"subject": "Hello",
"body": "This is a test email",
"idempotencyKey": "unique-key-123"
}
```**Responses:**
* `200 OK` — Email job added to queue
* `400 Bad Request` — Missing fields
* `500 Internal Server Error` — Server failure## 🥪 Testing
* `email.test.js`: Validates API behaviors
* `queue.test.js`: Validates queue retry, pause, and failure handling## 🛠 Design Principles
* Clean code using SOLID principles
* Zero external email APIs — mock-based providers
* Minimal dependencies
* Fully ESM-compatible using Jest## Author
Built with as part of the PearlThoughts Backend Developer Trainee challenge.
## License
MIT
## Live API URL
Use the following live URL to send emails (via POST):
```
https://zkmvf4vzs8.execute-api.ap-south-1.amazonaws.com/Prod/api/email
```