How kenichiro-kimura/line-notify-messenger works
Main Components
• Entrypoints & Execution Environments:
• AWS Lambda (src/lambdahandler.ts, AWS CDK stacks in bin and lib directories)
• Azure Functions (functions directory with HttpTrigger.ts, host.json)
• Cloudflare Workers (src/cloudflareworkers.ts)
• Business Logic:
• Core application logic resides in src/core/LineNotifyMessengerApp.ts (handles LINE event processing and request routing)
• Services:
• Messaging and response generation are implemented in services (lineService.ts, messageService.ts, httpResponseService.ts, groupService.ts)
• Request Handlers:
• There are specific implementations per environment (lambdaHttpRequestHandler.ts, functionsHttpRequestHandler.ts, cloudflareHttpRequestHandler.ts) that adapt the common IHTTPRequestHandler interface to each platform.
• Data Repositories & Image Storage:
• For image uploads: AWS S3 (s3ImageStorage.ts), Azure Blob Storage (note: file references might be adjusted in the readme), Cloudflare R2 (r2ImageStorage.ts)
• For group ID management: AWS DynamoDB (dynamoGroupRepository.ts), Azure Table Storage (tableStorageGroupRepository.ts), Cloudflare KV (kvGroupRepository.ts)
• Strategies:
• The send mode logic is encapsulated in the sendModeStrategy.ts, allowing DI to select or extend messaging behavior.
• Image Processing:
• Image conversion handled via Jimp (in src/utils/jimpImageConverter.ts)
• Infrastructure as Code (IaC):
• AWS: CDK configuration (bin and lib directories, cdk.json)
• Azure: Bicep files (bicep folder)
• Cloudflare: Terraform files (terraform folder) and wrangler.toml.template.
Out the Relationships and Interactions
• Separation between the entry points and the common core application (LineNotifyMessengerApp) that processes messages.
• That the messaging service interacts with the LINE Messaging API (external service) for sending messages.
• That the image processing components use Jimp to modify images before storage.
• Dependency injection flows where the strategy (send mode) is provided to the core business logic.
• A separate block that represents the IaC aspect, mapping CDK, Bicep, and Terraform to their respective deployment targets.
Architectural Patterns and Design Principles
• Modularity: The design clearly separates concerns between core application logic, request handling (platform-specific), messaging services, data persistence, and image processing.
• Interface-based Design: Interfaces (found under src/interfaces) drive implementations across different platforms (e.g., IImageStorage, IGroupRepository, IHttpRequestHandler) for easier substitution.
• Multi-Environment Deployment: The use of specific folders for AWS, Azure, and Cloudflare indicates an architecture that abstracts environment-specific logic behind common interfaces.
• Infrastructure as Code: The inclusion of CDK, Bicep, and Terraform demonstrates that deployment automation and reproducibility are essential parts of the architecture.
Final Recommendations
• Multiple layers: deployment/environments, abstraction via interfaces, core business logic, and integrations.