Introduction
Communication Service is a microservice built using Node.js, Express.js, and MongoDB, designed to handle the communication needs of Legitify, a platform offering various modules like the Contract Management Tool, Notice Management Tool, Litigation, and Intellectual Property Rights (IPR). This service facilitates the sending of emails and SMS messages across different modules within the Legitify platform.
Features
Email Sending
Utilizes AWS SES (Simple Email Service) for sending emails.
Offers SMTP integration for clients, allowing them to configure their SMTP credentials for sending emails through Communication Service.
Supports HTML templates for email content.
SMS Sending
Integrates with Kaleyra, a third-party service, for sending SMS messages.
Provides flexibility in defining SMS templates.
Template Management
Communication Service includes a comprehensive template management system to streamline the process of composing and sending emails. Templates are organized into different categories corresponding to various modules within the Legitify platform. The templates are stored in specific directories within the project structure for easy access and management:
Authentication Templates (authTemplates)
Stored under the
./emailTemplate/authTemplates
directory.
Contracts Templates (contractsTemplates)
Stored under the
../emailTemplate/contractTemplates
directory.
IPR (Intellectual Property Rights) Templates (iprTemplates)
Stored under the
../emailTemplate/iprTemplates
directory.
Notice Templates (noticeTemplates)
Stored under the
../emailTemplate/noticeTemplates
directory.
Arbitration Templates (arbitrationTemplates)
Stored under the
../emailTemplate/arbitrationTemplates
directory.
LMT (Litigation Management Tool) Templates (lmtTemplates)
Stored under the
../emailTemplate/lmtTemplates
directory.
By categorizing templates based on their respective modules, Communication Service ensures efficient organization and retrieval of templates according to the specific communication requirements of each module. This structure facilitates easy maintenance and customization of templates, allowing for seamless communication across different functionalities within the Legitify platform.
Status Tracking
Logs the status of each email sent, including delivery success or failure, through a status tracking mechanism.
Model Schemas
Email Model:
projectName
: Name of the project associated with the email.senderId
: ID of the user sending the email.fromEmail
: Sender's email address.toRecipients
: Array of recipient email addresses.ccRecipients
: Array of CC recipient email addresses.content
: Content of the email.attachments
: Array of file attachments.templateName
: Name of the HTML template used for the email.
SMS Model:
projectName
: Name of the project associated with the SMS.senderId
: ID of the user sending the SMS.toMobile
: Recipient's mobile number.content
: Content of the SMS.templateId
: ID of the SMS template.smsSenderId
: Sender ID for SMS.templateName
: Name of the SMS template.
Status Log Schema:
eventType
: Type of event (e.g., email sent, SMS sent).response
: Response object containing details of the communication status.projectName
: Name of the project associated with the communication.templateName
: Name of the template used.parentId
: ID of the parent entity associated with the communication.parentType
: Type of the parent entity (e.g., cron job, email).additionalInformation
: Additional information related to the communication event.
Architecture
Built using Node.js and Express.js for the backend server.
Utilizes MongoDB as the database for storing communication-related data.
Implements a modular architecture to facilitate scalability and maintainability.
Integrates with AWS SES for email sending and Kaleyra for SMS sending.
SMTP Integration
In addition to utilizing AWS SES for email sending, Communication Service offers SMTP integration, allowing clients to configure their SMTP credentials for sending emails through the service. Below are the details required from clients for SMTP integration:
FROM_EMAIL: The email address to be used as the sender's address. For example,
[email protected]
.EMAIL_HOST: The SMTP server hostname or address. For example,
smtp.xxxxx.com
.PORT: The port number used for SMTP communication. Typically, this is
587
for TLS encryption or465
for SSL encryption.HOST_USER: The username or email address associated with the SMTP account. For example,
[email protected]
.HOST_PASSWORD: The password associated with the SMTP account. This information is sensitive and should be handled securely.
By providing these details, clients can seamlessly integrate their SMTP credentials with Communication Service, enabling the service to send emails on their behalf using the specified SMTP server. This integration offers flexibility and customization options for clients who prefer to use their own SMTP infrastructure for email communication within the Legitify platform.
Conclusion
Communication Service serves as a crucial component within the Legitify platform, enabling seamless communication between different modules and users. With features like email and SMS sending, template management, and status tracking, it provides a robust solution for managing communication needs effectively.