How tejasghatte/interact-mailer-microservice works
Project Type & Purpose
• It’s a standalone backend microservice:
• Exposes HTTP endpoints for authentication (OTP flows) and sending email notifications.
• Houses ~80+ HTML templates mapped to numeric “types” (per README) for different notification scenarios.
• Uses Nodemailer to dispatch messages via an external SMTP provider.
Top-Level Components
• “deployment” & Docker artifacts
• NGINX reverse-proxy (deployment/nginx)
• Dockerfile + docker-compose.yml for containerization and local orchestration
• Runtime service (“src”)
• HTTP server entrypoint (src/index.ts)
• Configuration (src/config)
• Middleware (src/middlewares)
• Controllers (src/controllers)
• Mailer module (src/mailers)
• Error & helper utilities (src/helpers, src/utils)
• Email templates (src/templates)
External Dependencies
• SMTP server (e.g. SendGrid, SES, corporate mail)
• GitHub Actions (deployment via .github/workflows/deployment.yml)
Core Request Flow & Interactions
1) API Client or upstream service calls HTTP endpoint →
2) NGINX (reverse proxy/load balancer) →
3) Express server (src/index.ts)
• CORS (src/config/cors.ts)
• JWT validation (src/middlewares/protect.ts)
• Route dispatch (src/routes/mailer.ts, auth routes)
• Controller logic (src/controllers/mailer.ts, auth.ts)
• Template lookup (src/templates/<type>.html)
• Nodemailer sendMail (src/mailers/nodemailer.ts)
4) External SMTP provider
5) Response back to client
Architectural Patterns & Principles
• Layered (Config → Middleware → Controllers → Services → External)
• Centralized error handling (src/controllers/error.ts + src/helpers/app_error.ts)
• Async error wrapper (src/helpers/catch_async.ts)
• Type safety (TypeScript declarations in src/types)
• Dockerized deployment + CI/CD via GitHub Actions