How mhd-afrij/whatsapp_crm works
CRM-WhatsApp is a multi-service, WhatsApp-first team CRM. Users work through the Next.js dashboard to manage shared conversations, contacts, leads, deals, campaigns, tasks, reports, and workspace settings; the Laravel API provides CRM behavior, while the gateway owns WhatsApp connectivity and WhatsApp-origin message data. The gateway persists and processes messages, notifies the backend, and supports realtime events. Edges are limited to relationships shown in the README or supplied source evidence; unsampled capabilities are represented at subsystem level rather than by inferred call chains.
Main entry points: V1 CRM REST API · inbound-pipeline.ts Inbound message pipeline · (dashboard) CRM dashboard · ConversationController.php Conversation management
Components 25
User interface
- CRM dashboard
frontend/src/app/(dashboard) - API client and hooks
frontend/src/lib - Shared inbox UI
frontend/src/components/inbox
CRM and collaboration
- CRM REST API
backend/app/Http/Controllers/Api/V1 - Auth and permissions
backend/app/Http/Middleware - Conversation management
backend/app/Http/Controllers/Api/V1/ConversationController.php - Pipeline and deal stages
backend/app/Http/Controllers/Api/V1/PipelineController.php - Contact auto-linking
backend/app/Services/ContactAutoLinker.php - CRM domain records
backend/app/Models - Workspace and RBAC
backend/app/Models/Workspace.php - Campaigns and tasks
backend/app/Http/Controllers/Api/V1 - Reports and analytics
backend/app/Http/Controllers/Api/V1 - Settings and administration
backend/app/Http/Controllers/Api/V1
WhatsApp gateway
- Gateway API routes
whatsapp-gateway/src/routes/internal-whatsapp.routes.ts - Connection manager
whatsapp-gateway/src/whatsapp/connection-manager.ts - WhatsApp socket
whatsapp-gateway/src/whatsapp/baileys-socket.ts - Inbound message pipeline
whatsapp-gateway/src/whatsapp/inbound-pipeline.ts - Message repository
whatsapp-gateway/src/whatsapp/message-repository.ts - Backend notification client
whatsapp-gateway/src/lib/laravel-client.ts
Persistence and realtime
- Realtime event server
whatsapp-gateway/src/lib/socket-server.ts - Message media storage
whatsapp-gateway/src/lib/storage.ts - Gateway MySQL access
whatsapp-gateway/src/lib/mysql.ts - Redis
Other components
- Agent or admin
- WhatsApp service
Connections 25
- Agent or admin → CRM dashboard: uses
- CRM dashboard → API client and hooks: requests data
- CRM dashboard → Shared inbox UI: shows inbox
- API client and hooks → CRM REST API: calls REST API
- CRM REST API → Auth and permissions: protects routes
- CRM REST API → Conversation management: routes inbox requests
- CRM REST API → Pipeline and deal stages: routes pipeline requests
- CRM REST API → Campaigns and tasks: serves CRM features
- CRM REST API → Reports and analytics: serves reporting
- CRM REST API → Settings and administration: serves administration
- Conversation management → Contact auto-linking: links contacts
backend/app/Http/Controllers/Api/V1/ConversationController.php - Conversation management → CRM domain records: reads and writes
backend/app/Http/Controllers/Api/V1/ConversationController.php - Pipeline and deal stages → CRM domain records: creates stages
backend/app/Http/Controllers/Api/V1/PipelineController.php - Workspace and RBAC → CRM domain records: owns workspace data
backend/app/Models/Workspace.php - WhatsApp service → WhatsApp socket: connects through
- Gateway API routes → Connection manager: dispatches actions
whatsapp-gateway/src/routes/internal-whatsapp.routes.ts - Connection manager → WhatsApp socket: manages socket
- WhatsApp socket → Inbound message pipeline: delivers messages
whatsapp-gateway/src/whatsapp/inbound-pipeline.ts - Inbound message pipeline → Message repository: persists messages
whatsapp-gateway/src/whatsapp/inbound-pipeline.ts - Inbound message pipeline → Backend notification client: notifies backend
whatsapp-gateway/src/whatsapp/inbound-pipeline.ts - Inbound message pipeline → Realtime event server: emits message event
whatsapp-gateway/src/whatsapp/inbound-pipeline.ts - Message repository → Gateway MySQL access: queries and writes
whatsapp-gateway/src/whatsapp/message-repository.ts - Gateway API routes → Message media storage: reads media
whatsapp-gateway/src/routes/internal-whatsapp.routes.ts - Realtime event server → Redis: uses adapter
whatsapp-gateway/src/lib/socket-server.ts - Backend notification client → CRM REST API: notifies messages