Skip to content

Commit

Permalink
feat: docker compose add and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanrongman committed Feb 11, 2025
1 parent 8a7bf55 commit 6fc04d6
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 6 deletions.
79 changes: 79 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: '2.1'
services:
redis:
image: redis:6.2.17
container_name: IntelliConnect-ce-redis
sysctls:
- net.core.somaxconn=1024
ports:
- "6379:6379"
volumes:
- "redis-volume:/data"
# default password: 1234
command: redis-server --requirepass 1234 --appendonly yes
environment:
- TZ=Asia/Shanghai
mysql:
image: mysql:5.7.44
container_name: IntelliConnect-ce-mysql
ports:
- "3306:3306"
volumes:
- "mysql-volume:/etc/mysql/conf.d"
- "mysql-volume:/var/lib/mysql"
- "mysql-volume:/logs"
environment:
# user: root,password:XzHvhX4CDaN696oQAXdmlcsrqgWbkxRl
- MYSQL_ROOT_PASSWORD=XzHvhX4CDaN696oQAXdmlcsrqgWbkxRl
- MYSQL_DATABASE=cwliot1.8
- TZ=Asia/Shanghai
command: ["--default-authentication-plugin=mysql_native_password"]
influxdb:
image: influxdb:1.6.4
container_name: IntelliConnect-ce-influxdb
volumes:
- "influxdb-volume:/etc/influxdb"
- "influxdb-volume:/var/lib/influxdb/data"
- "influxdb-volume:/var/lib/influxdb/meta"
- "influxdb-volume:/var/lib/influxdb/wal"
ports:
- 8086:8086
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: cwl
DOCKER_INFLUXDB_INIT_PASSWORD: 1234
DOCKER_INFLUXDB_INIT_ORG: my-org
DOCKER_INFLUXDB_INIT_BUCKET: buketname
# DOCKER_INFLUXDB_INIT_RETENTION: 720
emqx:
image: emqx:5.8.4
container_name: IntelliConnect-ce-emqx
restart: always
environment:
- TZ=Asia/Shanghai
healthcheck:
test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"]
interval: 5s
timeout: 25s
retries: 5
networks:
emqx-bridge:
aliases:
- node1.emqx.io
ports:
- 1883:1883
- 8083:8083
- 8084:8084
- 8883:8883
- 18083:18083
volumes:
- "emqx-volume:/opt/emqx/log"
- "emqx-volume:/opt/emqx/data"
volumes:
mysql-volume:
redis-volume:
influxdb-volume:
emqx-volume:
networks:
emqx-bridge:
driver: bridge
10 changes: 7 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IntelliConnect

> 一个智慧的物联网平台内核
> 一个由创万联社区开发的智慧物联网平台内核(首个专为AI智能体设计的物联网平台内核)
> 本项目正在快速开发中,文档正不断更新,欢迎提issue或email提醒作者。
Expand All @@ -15,12 +15,16 @@
* 支持时序数据库influxdb

## 安装运行
> 推荐使用docker安装,docker-compose.yaml文件在docker目录下,执行 docker-compose up 可初始化
mysql,redis,emqx和influxdb环境。
* 安装mysql和redis数据库,高性能运行推荐安装时序数据库influxdb
* 安装EMQX集群,并配置好exhook,本项目使用exhook作为mqtt消息的处理器
* 安装java17环境
* 修改配置文件application.yaml
* 修改配置文件application.yaml(设置ddl-auto为update模式)
* java -jar IntelliConnect-1.8-SNAPSHOT.jar

具体安装细节请看快速开始章节。

## 项目特色
* 极简主义,层次分明,符合mvc分层结构
* 完善的物模型抽象,使得iot开发者可以专注于业务本身
Expand All @@ -43,7 +47,7 @@
欢迎加入群聊一起交流讨论有关Aiot相关的话题,链接过期了可以issue或email提醒一下作者。

<div style="width: 250px;margin: 0 auto;">
<img src="./images/547c30be46816d92a5667d4d783e157.jpg" width="250px"/>
<img src="./images/fd0ac036093fa0c241a58774bc0d78c.jpg" width="250px"/>
</div>


Expand Down
Binary file added docs/get_started/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/get_started/img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/get_started/img_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/get_started/img_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/get_started/img_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 130 additions & 1 deletion docs/get_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,140 @@ Agent智能体可以自我学习。智能体是一种通用问题解决器。从
目前已经有很多的智能体框架,如langchain,promptulate和agently。但给智能体编写工具并不是一件非常容易的
事情,需要掌握良好的提示工程技术和抽象能力,因此本物联网内核提供了Agent智能体的抽象,并直接提供了可用的工具
集合,做到真正的开箱即用。
![img_1.png](img_1.png)

## 什么是物模型
物模型是物联网平台内核的基础模块,它定义了物联网设备的功能和属性,例如开关、亮度、温度、湿度等。
本物联网平台内核提供了物模型管理模块,用户可以轻松管理物联网设备的功能和属性。

## 安装部署流程

### 一、容器化环境初始化
1. 进入项目docker目录执行以下命令:
```bash
cd docker && docker-compose up -d
```
* 该操作将自动创建并启动以下服务容器:
- MySQL 数据库服务
- Redis 缓存服务
- EMQX MQTT消息中间件(https://www.emqx.com/zh)
- InfluxDB 时序数据库

2. 验证容器状态(可选):
```bash
docker-compose ps
```

### 二、应用配置指引
1. 修改`application.yaml`配置文件,配置数据库连接:
```yaml
spring:
influx:
user: cwl
# 你的数据库url
url: http://[容器IP]:8086
password: [数据库密码]
mapper-location: top.rslly.iot.dao
dataBaseName: data
retention: autogen #保存策略
datasource:
url: jdbc:mysql://[容器IP]:3306/[数据库名]?useSSL=false&characterEncoding=UTF-8
username: [数据库用户名]
password: [数据库密码]
redis:
host: [容器IP]
port: 6379
password: [redis密码]
```
2. 配置持久层参数(建议生产环境使用update模式):
```yaml
jpa:
hibernate:
ddl-auto: update # 自动更新表结构,保留数据
show-sql: false # 生产环境建议关闭SQL日志
```
### 三、首次启动注意事项
1. 容器IP建议替换为实际Docker网络地址(可通过`docker network inspect bridge`查询)
2. 首次启动建议设置`ddl-auto: create`初始化数据库结构,后续改为update
3. 刚启动时候数据库没有用户数据,因而无法登录,请手动添加管理员用户数据进行初始化,role为admin,password格式为 `{bcrypt}XXXX`
XXX为bcrypt加密后的密文,具体请看SpringSecurity的加密规则。
![img_4.png](img_4.png)
> user表的结构
4. 各中间件默认端口如被占用,需同步调整docker-compose.yaml中的端口映射配置
5. 生产环境建议配置独立的数据库账号并设置访问白名单
6. 内网环境需要使用穿透技术,如frp软件。

### 四、配置exhook
> 多语言的 钩子扩展 由 emqx-exhook 插件进行支持。它允许用户使用其它编程(例如:Python、Java 等)直接向 EMQX 挂载钩子,
以接收并处理 EMQX 系统的事件,达到扩展和定制 EMQX 的目的。
![img.png](img.png)
1. 登录emqx dashboard ,点击菜单:插件扩展 -> Exhook -> 添加
![img_2.png](img_2.png)
> 特别注意:由于本机使用docker安装EMQX服务器,因此上面的地址不能填写locahost(127.0.0.1),
具体ip请根据实际情况进行填写。
2. 开启exhook插件
![img_3.png](img_3.png)

### 五、微信小程序和微信服务号接入
1. 在application.yaml中配置微信小程序和微信服务号的appid和appsecret,以及微信的ToUserName,ToUserName是小程序的微信号。
可以通过截获微信服务器的请求获取。
```yaml
wx:
debug: true (生产模式下请设置为false,否则无法获取access_token)
appid: XXXXXX (服务号appid)
appsecret: XXXXXX (服务号appsecret)
micro: (小程序)
appid: XXXXXX
appsecret: XXXXXX
ToUserName: XXXXXX
appid2: XXXXXX
ToUserName2: XXXXXX
appsecret2: XXXXXX
msg:
token: XXXXXX
```
2. 将项目的api添加到微信开放平台,并配置好回调地址,然后就可以通过微信小程序或者微信服务号进行愉快的玩耍了。
详情请参考微信开放平台文档。(https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html)

### 六、联网搜索selenium安装
>如果你不需要使用AI联网搜索,那么至此处恭喜你,你已经拥有一个属于自己的物联网平台了,祝你愉快。
但如果需要使用AI联网搜索,那么你需要安装selenium,selenium是一个开源的浏览器自动化测试工具,
它可以自动模拟浏览器行为,如点击、输入、提交表单等,从而实现自动化测试和模拟用户操作。

1. 安装服务器无头谷歌浏览器。
```bash
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
```
查看当前浏览器版本
```bash
google-chrome --version
```
2. 配置运行的chrome驱动
先下载对应版本的chromedriver(http://npm.taobao.org/mirrors/chromedriver/)
解压到自己方便寻找的目录
```bash
unzip chromedriver_linux64.zip
```
3.配置application.yaml文件
```yaml
ai:
chromeDrive-path: [chromedriver路径]
chrome-path: [chrome可执行文件路径]
audio-tmp-path: [临时音频文件存放路径]
audio-temp-url: [项目运行的域名]
glm-key:
deepSeek-key:
dashscope-key:
robot-name: [机器人名称]
team-name: 创万联
```
通过以上步骤即可完成基础环境的搭建与配置,建议通过健康检查接口验证各服务连接状态。如果你需要
控制家里的电气,你可以选择安装homeAssistant与本平台集成,它将帮助你管理家庭的电器,并提供流畅的体验。

## 如何使用该平台内核
安装部署后,启动后访问呢http://localhost:8080/swagger-ui/index.html
即可获得完整的接口文档,使用这些接口既可以快速开发物联网应用,也可以作为基础模块来搭建物联网应用。
Expand All @@ -29,7 +158,7 @@ Agent智能体可以自我学习。智能体是一种通用问题解决器。从
<source src="../video/demo.mp4" type="video/mp4">
</video>

## Agent语音交互效果
## Agent语音交互效果(接入Esp32)

<video controls="controls" width="500" height="200">
<source src="../video/demo2.mp4" type="video/mp4">
Expand Down
Binary file removed docs/images/547c30be46816d92a5667d4d783e157.jpg
Binary file not shown.
Binary file added docs/images/fd0ac036093fa0c241a58774bc0d78c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
* 支持时序数据库influxdb

## 安装运行
> 推荐使用docker安装,docker-compose.yaml文件在docker目录下,执行 docker-compose up 可初始化
mysql,redis,emqx和influxdb环境,安装详情请看官方文档。
* 安装mysql和redis数据库,高性能运行推荐安装时序数据库influxdb
* 安装EMQX集群,并配置好exhook,本项目使用exhook作为mqtt消息的处理器
* 安装java17环境
* 修改配置文件application.yaml
* 修改配置文件application.yaml(设置ddl-auto为update模式)
* java -jar IntelliConnect-1.8-SNAPSHOT.jar

## 项目特色
Expand All @@ -46,6 +48,7 @@
* 技术博客地址https://wordpress.rslly.top
* 社区地址https://github.com/cwliot
* 创万联社区公众号:微信直接搜索创万联

## 相关项目和社区
* 创万联(cwl): 专注于物联网和人工智能技术的开源社区。
* Promptulate https://github.com/Undertone0809/promptulate [A LLM application and Agent development framework.]
Expand All @@ -55,7 +58,7 @@
欢迎加入群聊一起交流讨论有关Aiot相关的话题,链接过期了可以issue或email提醒一下作者。

<div style="width: 250px;margin: 0 auto;">
<img src="./docs/images/547c30be46816d92a5667d4d783e157.jpg" width="250px"/>
<img src="./docs/images/fd0ac036093fa0c241a58774bc0d78c.jpg" width="250px"/>
</div>


Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ spring:
matching-strategy: ant_path_matcher
jpa:
show-sql: false
hibernate:
#更新或者创建数据库表结构(第一次启动请设置为update)
ddl-auto: none
influx:
user: cwl
# 你的数据库url
Expand Down

0 comments on commit 6fc04d6

Please sign in to comment.