Skip to content

Pranjul1650/Email-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Resilient Email Service

A production-ready email sending service built with TypeScript, React, and Supabase that implements retry logic, fallback mechanisms, circuit breakers, and comprehensive monitoring to ensure reliable email delivery.

πŸš€ Live Demo

View Live Application

πŸ—οΈ Architecture

This service provides a complete email delivery solution with:

Core Features

  • Database-Powered: Uses Supabase PostgreSQL for persistent storage
  • API Endpoints: RESTful API with Supabase Edge Functions
  • Retry Logic: Exponential backoff with configurable attempts
  • Fallback Mechanism: Automatic provider switching on failure
  • Circuit Breaker Pattern: Prevents cascading failures
  • Real-time Monitoring: Live provider health and email status tracking

Tech Stack

  • Frontend: React + TypeScript + Tailwind CSS
  • Backend: Supabase Edge Functions (Deno)
  • Database: PostgreSQL with Row Level Security
  • Deployment: Vercel/Netlify compatible

πŸ“¦ Quick Start

1. Clone the Repository

git clone https://github.com/Pranjul1650/Email.git
cd Email

2. Install Dependencies

npm install

3. Environment Setup

Create a .env file with your Supabase credentials:

VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key

4. Database Setup

The database schema is automatically managed through Supabase migrations in the supabase/migrations/ directory.

5. Start Development Server

npm run dev

πŸ—„οΈ Database Schema

Tables

email_messages

  • Stores email data and delivery status
  • Tracks retry attempts and timestamps
  • Row Level Security enabled

email_attempts

  • Detailed attempt history for each email
  • Links to email_messages via foreign key
  • Tracks provider performance

provider_health

  • Circuit breaker state management
  • Failure count tracking
  • Automatic recovery timing

πŸ”§ API Endpoints

Send Email

POST /functions/v1/send-email
Content-Type: application/json
Authorization: Bearer YOUR_SUPABASE_ANON_KEY

{
  "to": "recipient@example.com",
  "subject": "Email Subject",
  "body": "Email content",
  "from": "sender@example.com"
}

Get Email Status

GET /functions/v1/get-email-status?messageId=uuid
Authorization: Bearer YOUR_SUPABASE_ANON_KEY

Get Provider Health

GET /functions/v1/get-provider-health
Authorization: Bearer YOUR_SUPABASE_ANON_KEY

🎯 Key Features

1. Resilient Email Delivery

  • Multiple provider fallback
  • Exponential backoff retry logic
  • Circuit breaker pattern implementation
  • Automatic failure recovery

2. Real-time Monitoring

  • Provider health dashboard
  • Email delivery statistics
  • Circuit breaker state tracking
  • Attempt history visualization

3. Production Ready

  • Row Level Security (RLS)
  • Input validation and sanitization
  • Comprehensive error handling
  • Structured logging

4. Developer Experience

  • TypeScript for type safety
  • Comprehensive API documentation
  • Unit tests included
  • Clean architecture with SOLID principles

πŸš€ Deployment

Vercel (Recommended)

npm i -g vercel
vercel --prod

Netlify

npm run build
netlify deploy --prod --dir=dist

Environment Variables for Production

Set these in your deployment platform:

  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY

πŸ§ͺ Testing

Run the test suite:

npm test

Tests cover:

  • Email sending functionality
  • Retry logic and exponential backoff
  • Circuit breaker behavior
  • Rate limiting enforcement
  • Provider fallback mechanisms

πŸ“Š Monitoring

The application provides built-in monitoring:

  • Email Statistics: Success/failure rates, delivery times
  • Provider Health: Circuit breaker states, failure counts
  • Real-time Updates: Live status updates every 5 seconds
  • Historical Data: Complete attempt history for each email

πŸ”’ Security

  • Row Level Security (RLS) on all database tables
  • API key authentication required
  • Input validation and sanitization
  • User-based data isolation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

For support, email pranjul1650@example.com or create an issue in this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published