How chickenai/multizlogin works
Project type and purpose
• MultiZlogin is a full-stack, monolithic Node.js application built on Express.
• It provides both a web UI (EJS templates) for human operators and a RESTful API for integration with other systems (e.g., n8n).
• Core purpose: manage multiple Zalo accounts (login via QR), support proxy usage per account, configure per-account webhooks, track connection status, and expose an API for external automation.
File structure
• src/server.js & src/app.js: application entrypoints (HTTP server, middleware setup).
• src/routes/*: routing layer, separates UI routes (EJS views) from API routes (/api/*).
• src/services/*: business-logic layer (authService, proxyService, webhookService).
• src/api/zalo/zalo.js: Zalo integration module using zca-js library.
• src/config/webhookConfig.json + .env: global & per-account configuration.
• data/ and zalo_data/: persistent JSON storage for cookies, proxies, webhook configs (no external DB).
• Dockerfile, docker-compose.yaml & scripts/: containerization, volume setup, build/publish automation.
Main components
a. Client Layer
• Browser UI (EJS pages served over HTTPS)
• External API Consumer (e.g., n8n workflows calling /api/* endpoints)
b. Web/Application Server
• Express.js HTTP server
• Routing Layer: UI routes vs API routes
• Controllers: lightweight handlers in routes/*.js
• Service Layer: encapsulates interactions with Zalo, proxies, webhook logic
c. Persistence Layer
• File-based JSON storage (mounted volume via Docker) for:
• cookies/users.json
• proxies.json
• webhook-config.json
d. External Services
• Zalo Web API (third-party service)
• n8n (or other webhook target)
e. Deployment/Infrastructure
• Docker Container (multizlogin_zalo-server)
• Docker Compose orchestration (bind mounts for zalo_data)
• Helper scripts for build, publish, migration
Relationships and interactions
• Browser ⇄ Express (UI GET/POST)
• Express routes ⇄ Service layer (business methods)
• Service layer ⇄ JSON storage (read/write)
• authService/webhookService ⇄ Zalo API (login, fetch events)
• webhookService ⇄ External webhook targets (n8n)
• API consumers ⇄ Express API routes (X-API-Key auth)
Architectural patterns & design principles
• MVC-like separation: Views (EJS) ↔ Controllers (routes) ↔ Services
• Single process monolith for simplicity, layered internally
• Environment-driven config (12-factor) via .env and webhookConfig.json
• Container-first design: all state in external volume, stateless app container
Final recommendations
• Every logical component (routes vs services vs storage) rather than lumping everything under “server.”
• Docker volume mapping for zalo_data as the persistent layer.
• Security/auth (API key in header, session cookie management) near the boundary.