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.
This service provides a complete email delivery solution with:
- 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
- Frontend: React + TypeScript + Tailwind CSS
- Backend: Supabase Edge Functions (Deno)
- Database: PostgreSQL with Row Level Security
- Deployment: Vercel/Netlify compatible
git clone https://github.com/Pranjul1650/Email.git
cd Emailnpm installCreate a .env file with your Supabase credentials:
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_keyThe database schema is automatically managed through Supabase migrations in the supabase/migrations/ directory.
npm run dev- Stores email data and delivery status
- Tracks retry attempts and timestamps
- Row Level Security enabled
- Detailed attempt history for each email
- Links to email_messages via foreign key
- Tracks provider performance
- Circuit breaker state management
- Failure count tracking
- Automatic recovery timing
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 /functions/v1/get-email-status?messageId=uuid
Authorization: Bearer YOUR_SUPABASE_ANON_KEYGET /functions/v1/get-provider-health
Authorization: Bearer YOUR_SUPABASE_ANON_KEY- Multiple provider fallback
- Exponential backoff retry logic
- Circuit breaker pattern implementation
- Automatic failure recovery
- Provider health dashboard
- Email delivery statistics
- Circuit breaker state tracking
- Attempt history visualization
- Row Level Security (RLS)
- Input validation and sanitization
- Comprehensive error handling
- Structured logging
- TypeScript for type safety
- Comprehensive API documentation
- Unit tests included
- Clean architecture with SOLID principles
npm i -g vercel
vercel --prodnpm run build
netlify deploy --prod --dir=distSet these in your deployment platform:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEY
Run the test suite:
npm testTests cover:
- Email sending functionality
- Retry logic and exponential backoff
- Circuit breaker behavior
- Rate limiting enforcement
- Provider fallback mechanisms
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
- Row Level Security (RLS) on all database tables
- API key authentication required
- Input validation and sanitization
- User-based data isolation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Supabase for backend infrastructure
- UI components styled with Tailwind CSS
- Icons provided by Lucide React
For support, email pranjul1650@example.com or create an issue in this repository.