Skip to content

Backend Development ​

This page covers the local development environment setup, module structure, and extension development of the FastBee open-source backend.

Page Guide ​

Use CasesDevelopers who need to read or modify backend source code, add endpoints or protocols, or do custom development.
PrerequisitesJDK 8, Maven, MySQL 5.7+, and Redis are installed locally; component installation is covered in System Deployment.
Operation PathClone the source → Import into IDEA → Initialize the database → Edit the configuration → Start and verify.
Acceptance CriteriaThe service starts without errors, API 8080 and MQTT 1883/8083 ports are listening, and /swagger-ui.html opens the API documentation.

Environment Setup ​

Before you start, confirm that JDK 8, Maven, MySQL 5.7+, and Redis are installed locally; see System Deployment for component installation.

1. Clone the Source Code ​

bash
git clone https://gitee.com/beecue/fastbee.git

2. Import into IDEA ​

Open the springboot directory with IntelliJ IDEA and wait for the Maven dependencies to finish downloading.

3. Initialize the Database ​

bash
mysql -uroot -p -e "CREATE DATABASE fastbee DEFAULT CHARSET utf8 COLLATE utf8_unicode_ci;"
mysql -uroot -p fastbee < sql/fastbee.sql

4. Edit the Configuration ​

Edit springboot/fastbee-admin/src/main/resources/application-dev.yml; both the datasource and Redis configuration live in this file.

yaml
spring:
  datasource:
    dynamic:
      datasource:
        master:
          url: jdbc:mysql://localhost:3306/fastbee?...
          username: root
          password: your_password
  redis:
    host: localhost
    port: 6379
    password: your_password

5. Start ​

Run the FastBeeApplication.main() method.

6. Verify the Startup ​

After a successful start, confirm:

  • No exceptions in the console output
  • The backend API port 8080, MQTT TCP port 1883, and MQTT WebSocket port 8083 are all listening
  • Visiting http://localhost:8080/swagger-ui.html in a browser opens the Swagger API documentation

Module Overview ​

ModuleRole
fastbee-adminStartup entry point, configuration files
fastbee-commonUtilities, constants, exceptions, entity base classes
fastbee-frameworkSpring Security integration, JWT authentication, RuoYi framework
fastbee-open-api37 REST Controllers
fastbee-serviceIoT and system business Service layer
fastbee-serverNetty MQTT Broker + SIP Server
fastbee-protocolProtocol encoding/decoding
fastbee-plugsExtension plugins

API Controller Layer ​

The fastbee-open-api module contains the following API controllers:

CategoryControllerDescription
IoTProductControllerProduct management
IoTDeviceControllerDevice management
IoTThingsModelControllerThing model
IoTSceneControllerScene linkage
IoTScriptControllerRule scripts
IoTGroupControllerDevice grouping
VideoSipDeviceControllerSIP devices
VideoPlayerControllerVideo playback
VideoPtzControllerPTZ control
SystemDashBoardControllerDashboard
SystemDataCenterControllerData center

Extension Development ​

Add a New Endpoint ​

  1. Create a Controller in fastbee-open-api
  2. Create the Service and Mapper in fastbee-service
  3. Add the corresponding SQL and database tables

Add a New Protocol ​

  1. Implement the protocol codec in fastbee-protocol
  2. Register the protocol handler in fastbee-server

FAQ ​

Database connection failure on startup? ​

Check that the url, username, and password in application-dev.yml are correct, and confirm that sql/fastbee.sql has been executed to initialize the database.

Redis connection failure on startup? ​

Check the host, port, and password under redis in application-dev.yml and the Redis service status; if Redis has a password set, it must be filled in the configuration.

Startup fails because a port is in use? ​

Confirm that ports 8080, 1883, and 8083 are not occupied by other processes; if there is a conflict, change the corresponding configuration and restart.