description: complete guide about project structure
globs:
alwaysApply: false
Go WhatsApp Web Multidevice API
This is a Go implementation of a WhatsApp Web Multidevice API that allows you to interact with WhatsApp through HTTP APIs.
Project Structure
Root Directory
- readme.md - Project documentation and usage instructions
- docker-compose.yml - Docker configuration for running the application
- LICENCE.txt - License information
Source Code (src/)
The main source code is organized in the src directory with the following structure:
#### Command Line Interface
- src/cmd/root.go - Root command using Cobra for CLI commands, handles configuration loading
- src/cmd/rest.go - REST server command implementation
- src/cmd/mcp.go - Model Context Protocol server command implementation
#### Configuration
- src/config/ - Application configuration settings and constants
#### Domain Models
The application is organized using domain-driven design principles:
- src/domains/app/ - Core application domain models
- src/domains/chat/ - Chat-related domain models and interfaces
- src/domains/group/ - Group-related domain models
- src/domains/message/ - Message-related domain models
- src/domains/newsletter/ - Newsletter-related domain models
- src/domains/send/ - Message sending domain models
- src/domains/user/ - User-related domain models
#### Infrastructure
- src/infrastructure/chatstorage/ - Chat storage repository and WhatsApp integration
- src/infrastructure/whatsapp/ - WhatsApp client implementation and related infrastructure
#### User Interface
- src/ui/rest/ - REST API implementation
- src/ui/rest/helpers/ - Helper functions for REST handlers
- src/ui/rest/middleware/ - Middleware components for request processing
- src/ui/websocket/ - WebSocket implementation for real-time communication
- src/ui/mcp/ - Model Context Protocol server to communication with AI Agent
#### Utilities and Shared Components
- src/pkg/error/ - Error handling utilities
- src/pkg/utils/ - General utility functions
#### Use Cases
- src/usecase/ - Application services that implement business logic
#### Static Resources
- src/statics/ - Static resources like media files
- src/statics/media/ - Media files
- src/statics/qrcode/ - QR code images for WhatsApp authentication
- src/statics/senditems/ - Items to be sent via WhatsApp
#### Validation
- src/validations/ - Request validation logic
#### Views
- src/views/ - Templates and UI components
- src/views/assets/ - Frontend assets (CSS, JS, etc.)
- src/views/components/ - Reusable UI components
- src/views/components/generic/ - Generic UI components
Documentation
- docs/ - Project documentation
- docs/openapi.yaml - OpenAPI specification for the REST API
- docs/sdk/ - SDK documentation
Docker
- docker/ - Docker-related files and configurations
- docker/golang.Dockerfile - Dockerfile for building the Go application
Key Application Features
- WhatsApp login via QR code or pairing code
- Send/receive messages, media, contacts, locations
- Group management features
- Newsletter management
- WebSocket real-time updates
- Webhooks for message events
- Auto-reply functionality
- Model Context Protocol (MCP) server for AI agent communication
Application Flow
REST Server Mode
- The application starts from src/cmd/root.go
- REST server command is executed via src/cmd/rest.go
- Configuration is loaded from environment variables or command line flags
- The REST server is initialized using Fiber framework
- WhatsApp client is initialized and services are created
- REST routes are registered for different domains
- WebSocket hub is started for real-time communication
- Background tasks are started (auto-reconnect, chat storage flushing)
- The server listens for requests on the configured port
MCP Server Mode
- The application starts from src/cmd/root.go
- MCP server command is executed via src/cmd/mcp.go
- Model Context Protocol server is initialized for AI agent communication
- WhatsApp client services are made available through MCP protocol
- The MCP server listens for AI agent requests