$ show evolution-foundation/evolution-api
Evolution API is a production-grade, multi-tenant WhatsApp API gateway built with Node.js, TypeScript, and Express. It manages independent WhatsApp instances via Baileys (WhatsApp Web), Meta Business API, and its own Evolution API channel, providing REST endpoints for messaging, chat management, groups, labels, and media. The system integrates deeply with chatbot platforms (Typebot, OpenAI, Dify, Flowise, N8N, EvoAI, EvolutionBot) and event systems (Webhook, WebSocket, RabbitMQ, SQS, NATS, Kafka, Pusher), and includes storage via S3/MinIO and CRM sync with Chatwoot. The architecture follows a modular controller-service pattern with Prisma ORM (supporting MySQL and PostgreSQL), Redis caching, and centralized configuration. It is actively maintained with frequent updates, extensive migrations, and CI/CD pipelines.
The LLM identified 5 files worth highlighting for reuse:
RouterBroker abstract class that standardizes route validation and dispatch across all API routers. It provides methods like dataValidate, groupValidate, inviteCodeValidate that accept a request, JSON schema, DTO class, and execution callback. This reduces boilerplate and ensures consistent error handling and instance extraction. It is self-contained and could be extracted as a reusable pattern for any Express-based API.
Abstract base service for all chatbot integrations (Typebot, OpenAI, Dify, etc.). It provides common logic for message processing, session management, sending WhatsApp messages with link previews, splitting long messages, handling media, and managing trigger rules. Concrete integrations extend this class, overriding only the specific API call. This pattern is reusable for adding new chatbot backends with minimal effort.
Unified cache service that abstracts over Redis and local NodeCache. Provides standard get/set/has/delete operations with TTL. Used throughout the codebase for session keys, instance data, and contact existence cache. The interface is clean and could be extracted as a standalone caching utility for any Node.js project.
Centralized event manager that routes WhatsApp events (messages, status updates, etc.) to all enabled event transports (webhook, WebSocket, RabbitMQ, SQS, NATS, Kafka, Pusher). It uses per-event toggles from configuration and handles delivery failures. This pattern decouples event producers from consumers and is reusable for any event-driven system.
Modular authentication state provider for Baileys WhatsApp sessions. It implements the standard Baileys auth state interface using file-based storage, with methods for reading/writing credentials, keys, and app state sync data. The pattern is cleanly separated and could be adapted for other storage backends (e.g., S3, database) by implementing the same interface.