How jaredwray/airhorn works
Main Components
• Core API & Notification Functions: Represented by the main file (airhorn.ts) that exposes key functions like send(), sendSMTP(), sendSMS(), sendWebhook(), and sendMobilePush().
• Provider Service & Strategy Layer: Modules in src (such as provider-service.ts and provider-type.ts) coordinate the selection and execution of the correct notification provider.
• Provider Implementations: The src/providers subdirectory contains individual modules for each cloud service (aws-ses, aws-sms, aws-sns, firebase-messaging, twilio-sendgrid, twilio-sms, webhook). These can be shown as individual “provider” components.
• Template Management:
– Template Service (src/template-service.ts and template-sync.ts): Handles template loading, rendering, and possibly synchronization between file system and a database.
– Template Provider Abstraction: Noted by template-providers (with an in-memory version in memory.ts, and a MongoDB-based one in mongo.ts) to abstract how templates are fetched.
Relationships and Interactions
• Optionally, include a “Template Provider” abstraction that can use either the in-memory or database-backed (MongoDB/Postgres) implementation as configured via Airhorn options.
Architectural Patterns & Design Principles
• Use of the Strategy Pattern for selecting among different provider implementations.
• Loose coupling between the core API and provider implementations (achieved through abstraction over provider types and template providers).
• The modularized design in “src” (with dedicated directories for providers and template providers) emphasizes separation of concerns.
• The file system-based templating (as outlined in the README) is a key design aspect, so emphasize the structure (templates folder structure in test/templates can serve as an example).
Relevant Technologies and Frameworks
• Node.js (ESM with TypeScript): The project is built as an ESM module with the latest Node.js features.
• Cloud Services: AWS (SES, SMS, SNS), Twilio (Sendgrid, SMS), Firebase (Messaging) are critical external integrations.
• Template Engines: While not explicitly shown in code, the README mentions support for EJS, Handlebars, etc.
• CI/CD Integration: GitHub Actions, Docker (docker-compose.yml) are used to streamline testing and deployment.
Final Assembly
• Every component is labeled and its role clearly described—don’t skip over details such as error-handling flows or fallback mechanisms if applicable (active/passive fail over mentioned in the README for multiple providers).