12 KiB
AGENTS.md
This file provides guidance to AI coding agents (Codex, GitHub Copilot, etc.) when working with code in this repository.
Project Overview
Bytedesk is an AI-powered omnichannel customer service platform with team cooperation capabilities, providing enterprise instant messaging, customer service, knowledge base, ticket management, and AI agent functionality.
This repository is backend-only: a Java 21 + Spring Boot 4.1.0 multi-module Maven monorepo. Frontend applications live in separate repositories (see frontend/readme.md):
- Web (visitor widget + admin): https://github.com/Bytedesk/bytedesk-web
- Desktop (Electron): https://github.com/Bytedesk/bytedesk-desktop
- Mobile: https://github.com/Bytedesk/bytedesk-mobile
Architecture
Backend Architecture (Java 21 + Spring Boot 4.1.0)
- Entry Point:
starter/src/main/java/com/bytedesk/starter/StarterApplication.java - Core Stack: Spring Boot 4.1.0, Spring Data JPA, Spring Security (OAuth2/OIDC + LDAP), WebFlux alongside Spring MVC; Jetty servlet container (Tomcat excluded)
- Concurrency: Java 21 virtual threads enabled (
spring.threads.virtual.enabled=true) - Messaging: Netty-based WebSocket/MQTT/STOMP stack in
modules/core/src/main/java/com/bytedesk/core/socket/(HTTP port9003, WebSocket port9885); broker selected viabytedesk.mq.type(defaultartemis;rabbitmq/kafka/rocketmqalso supported) - Database: MySQL (primary), Redis (caching + message queuing), H2 (testing); PostgreSQL/Oracle/KingBase also supported, selected via
bytedesk.datasource.active - Migrations: Liquibase, master change log at
starter/src/main/resources/db/changelog/master.xml - Workflow Engines: Flowable 8.0.0 (ticket workflows), COLA state machine 5.0.0 (core workflows; Spring StateMachine 4.0.0 also on the classpath during migration to COLA)
- AI: Spring AI 2.0.0 based integration with 20+ providers, MCP client/server, and Agent Skills (see AI Integration below)
- Multi-module Maven structure; root aggregator modules:
channels,modules,plugins,starter
Module Structure
Root Maven modules (pom.xml): channels, modules, plugins, starter
channels/- Aggregator only; all channel modules (wechat, whatsapp, email, dingtalk, ...) are currently commented out inchannels/pom.xmlplugins/- Optional plugins; onlykanbanis active (appoint,backup,calendar,elearning,note,pdf,socialhub,formare commented out)starter/- Spring Boot application aggregating the active modules
Backend Modules (modules/):
core/- Core functionality and utilities (protobuf/gRPC codegen, WebSocket/MQTT/STOMP stack, COLA state machine, RBAC, quartz, push, workflow)team/- Team IM and organizational structureservice/- Customer service and routingkbase/- Knowledge base managementai/- AI integration (Spring AI 2.0.0): 20+ LLM providers (anthropic, azure, baidu, bedrock, custom, dashscope, deepseek, dmr, gitee, google, groq, huggingface, minimax, mistralai, moonshot, nvidia, ollama, openai, openrouter, perplexity, siliconflow, tencent, volcengine, zhipuai), robot/robot_thread, MCP client & server, agent skills, tool/tool_call/tool_audit, RAGticket/- Ticket management, SLA, Flowable 8 workflowscall/- Call center functionality (FreeSWITCH)meet/- Meeting/conferencingwebrtc/- WebRTC video supportvoc/- Voice of customer feedbackforum/- Forum functionalitysocial/- Social featuresbi/- Business intelligence (built, but currently NOT aggregated into starter)crm/- CRM functionalitydisk/- File storagemall/- Mall/e-commercemarketing/- Marketing toolsopinion/- Opinion/feedbackremote/- Remote supporttraining/- Training managementcli/- Command line interface
Note: modules/shop/ contains only stale build output (target/) and is NOT a module in modules/pom.xml; do not use it.
Plugins (plugins/):
kanban/- Kanban board functionality (built, but NOT aggregated into starter)
Development Commands
Backend (Maven)
Prefer the repository wrapper (./starter/mvnw) instead of assuming a global Maven; JDK 21 is required.
# Build entire project
./starter/mvnw -f pom.xml clean install -DskipTests
# Build a specific module (with its dependencies)
./starter/mvnw -f pom.xml -pl modules/core -am -DskipTests install
# Run application (default profile: noai; JASYPT_ENCRYPTOR_PASSWORD optional, see Environment Pitfalls)
./starter/mvnw -f starter/pom.xml spring-boot:run
# Generate Javadoc
./starter/mvnw javadoc:javadoc
Docker Deployment
cd deploy/docker
# Usage: ./start.sh <db> <mq> <scenario> <target> [observability]
# db: mysql | postgresql | oracle | kingbase9 (aliases: pg, kingbase)
# mq: artemis | rabbitmq
# scenario: standard | noai | call | webrtc | call-webrtc
# target: all | middleware
# observability (5th arg): obs | observability | true
# Start without AI (default active profile of the app is also noai)
./start.sh mysql artemis noai all
# Standard scenario
./start.sh mysql artemis standard all
# Only middleware (DB/MQ/etc.), no app container
./start.sh mysql artemis standard middleware
# With observability stack (Prometheus/Grafana)
./start.sh mysql artemis standard all obs
Notes:
callandcall-webrtcscenarios only supportmysql/postgresqlbackends- Compose assets:
compose-base.yaml,compose-db-*.yaml,compose-mq-{artemis,rabbitmq}.yaml,compose-scenario-{standard,noai,call,webrtc}.yaml,compose-app-*.yaml,compose-observability.yaml deploy/docker/one/contains all-in-one compose files for quick single-node deploymentstop.shfor teardown,watchdog.shfor monitoring
Key Technologies and Patterns
Backend Patterns
- JPA Entities: Domain models with Spring Data JPA repositories
- REST Controllers: Spring MVC controllers with OpenAPI/Swagger (springdoc) documentation
- WebSocket Controllers: Real-time messaging via Netty
- Service Layer: Business logic in service classes
- Security: Spring Security with OAuth2/OIDC + LDAP support; optional Jasypt property encryption for
ENC(...)values - Workflows: Flowable 8 (ticket processes), COLA state machine (core workflows)
- Caching: Redis + Caffeine (local cache)
- Message Queue:
bytedesk.mq.typeselects the broker (defaultartemis;rabbitmq/kafka/rocketmqsupported); ActiveMQ Artemis / RabbitMQ available via Docker compose; embedded Artemis server dependency included - Templates: FreeMarker is primary; Thymeleaf restricted to
error/*,excel/*,file/*views
Plugin Patterns
- Plugins: Optional capabilities layered on
modules/; onlykanbancurrently active and it is NOT aggregated into starter - Channels: All channel modules are disabled (commented out in
channels/pom.xml); re-enable by un-commenting the desired module
Important Notes
Database Support
The database is selected via bytedesk.datasource.active (default mysql):
- MySQL (primary production)
- PostgreSQL
- H2 (development/testing)
- Oracle
- KingBase
Datasource files: starter/src/main/resources/properties/<profile>/datasource/50-datasource-*.properties (common + per-DB).
Default login: admin@email.com / admin
AI Integration
Built on Spring AI 2.0.0 with 20+ providers under modules/ai/.../providers/: Ollama (local), ZhipuAI (default provider of the open profile), DeepSeek, DashScope, OpenAI, Anthropic, Azure, Google, Bedrock, Moonshot, Minimax, SiliconFlow, Volcengine, Tencent, Baidu, Gitee, Groq, Mistral AI, NVIDIA, Perplexity, OpenRouter, HuggingFace, DMR, plus a custom provider.
- The
openprofile sets ZhipuAI as default for chat/embedding/vision/audio/rerank/multimodal models (properties/open/70-ai-batch-liquibase.properties) - Elasticsearch vector store (custom
VectorStoreConfig); Spring AI JDBC ChatMemory tables managed by Liquibase (spring.ai.chat.memory.repository.jdbc.initialize-schema=never) - MCP (
properties/<profile>/75-mcp.properties): MCP client and server are disabled by default (spring.ai.mcp.client.enabled=false,spring.ai.mcp.server.enabled=false); when enabled, bearer-token auth applies and only read-only tools are exposed by default - Agent Skills (
properties/<profile>/76-skills.properties): shell / filesystem / web-fetch skill tools; disabled in thenoaiprofile, enabled inopen; skill definitions live understarter/src/main/resources/skills/
Module Dependencies
- All modules depend on
modules/core - Starter aggregates:
core,team,service,kbase,ai,crm,marketing,ticket,call,meet,webrtc,voc,forum,social,remote,training,cli - Not currently aggregated into starter:
bi(commented out instarter/pom.xml),disk,mall,opinion, and thekanbanplugin - All channel modules are disabled (commented out in
channels/pom.xml)
Configuration Files
- Main:
starter/src/main/resources/application.properties— setsspring.profiles.active=noaiby default - Profiles:
noai(default, AI disabled) andopen(AI enabled, ZhipuAI default).application-noai.properties/application-open.propertiesimport modular configs fromstarter/src/main/resources/properties/{noai,open}/ - Modular configs are numbered for ordering:
30-core-business,31-call-freeswitch,32-webrtc,33-cache-redis,40-oauth-ldap,41-logging,51-jpa-web-actuator,60-mq-mail-quartz,70-ai-batch-liquibase,75-mcp,76-skills,80-flowable,90-thirdparty-cloud,99-docker-compose, plusdatasource/50-* - Docker:
deploy/docker/compose-*.yaml
Environment Pitfalls
- Default local HTTP port is
9003, WebSocket port is9885; check port conflicts before concluding startup failure - Local dev commonly requires MySQL + Redis (Docker compose in
deploy/docker/is the usual path); Spring Boot docker-compose lifecycle is disabled (spring.docker.compose.enabled=false) — usedeploy/docker/start.sh/stop.shinstead JASYPT_ENCRYPTOR_PASSWORDis only required if you actually useENC(...)encrypted properties; shipped configs contain only commented examples, so startup works without itbytedesk.licenseKeymay need a trial license for some features (see comments inapplication-noai.properties)modules/coreincludes protobuf/gRPC generation (CI installs protoc 23.x); if related classes are missing, rebuild core with-pl modules/core -am- Liquibase migrations live under
starter/src/main/resources/db/changelog/; do not introduce Flyway - Prefer minimal scoped changes; do not refactor unrelated modules in the same task
Testing
Backend Tests
# Run all tests
./starter/mvnw -f pom.xml test
# Run tests for specific module
./starter/mvnw -f pom.xml -pl modules/core test
# Run single test class
./starter/mvnw test -Dtest=YourTestClass
# Run single test method
./starter/mvnw test -Dtest=YourTestClass#testMethod
Build Artifacts
- Main JAR:
starter/target/bytedesk-starter.jar(finalName fixed instarter/pom.xml) - Generated Javadocs:
starter/src/main/resources/static/javadocs/ - Swagger/OpenAPI: Available at
/swagger-ui.htmlwhen running - Docker image: built from
starter/Dockerfile(eclipse-temurin:21-jdk base), published tojackning/bytedeskon Docker Hub
CI/CD
.github/workflows/bytedesk.yml: triggered onv*tag pushes; JDK 21 (temurin) + protoc 23.x, Maven build, creates GitHub release.github/modernize/: modernization workflow assets
Development Workflow
- Backend Development: Work in specific modules under
modules/, test via starter app - Plugins: Add optional capabilities in
plugins/(onlykanbanactive) - Channels: Currently disabled; re-enable by un-commenting modules in
channels/pom.xml - Full Stack Testing: Run backend on port 9003; frontends (separate repos) connect via REST/WebSocket (9885)
- Docker Testing: Use
deploy/docker/start.shfor full environment testing
License
Business Source License 1.1 - Can be used for commercial purposes but prohibits resale, SaaS hosting, or deployment for illegal businesses without permission.