Skip to content

Commit 5f338b9

Browse files
authored
blog post: qchat redesign (#62)
Translation of geotribu/website#1329
2 parents d3109fa + acc1109 commit 5f338b9

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: QChat as it never was
3+
subtitle: Choose your channel, comrade
4+
authors:
5+
- gounux
6+
categories:
7+
- Article
8+
comments: true
9+
date: 2025-09-08
10+
description: Reasons and technical explanations for the redesign of QChat, the system for chatting with peers in QGIS.
11+
icon: material/chat
12+
license: beerware
13+
links:
14+
- QChat introduction: posts/2024-10-18_introducing-QChat-chat-rooms-in-QGIS.md
15+
- QChat news: posts/2024-12-03_QChat_news.md
16+
pin: false
17+
tags:
18+
- community
19+
- QChat
20+
- QGIS
21+
---
22+
23+
# El rediseño de QChat
24+
25+
![icône globe speech GIS Chat - Credits: Global Market by DARAYANI from Noun Project (CC BY 3.0)](https://cdn.geotribu.fr/img/logos-icones/divers/globe_speech_GISChat.svg){: .img-thumbnail-left }
26+
27+
After [a somewhat shaky first version](./2024-10-18_introducing-QChat-chat-rooms-in-QGIS.md), Geotribu is pleased to announce some fairly significant and impactful changes to QChat, the chat system integrated into QGIS.
28+
29+
The new version of QChat is a bit like when [Com Truise](https://www.youtube.com/watch?v=L4ENAdECytk) gets on a motorbike: it really gets the blood pumping!
30+
31+
![A bicycle disguised as a motorbike with cardboard](https://cdn.geotribu.fr/img/articles-blog-rdp/articles/2025/qchat_revolution/velo_deguise_en_moto.png){: .img-center loading=lazy }
32+
33+
<!-- more -->
34+
35+
_A photo shamelessly stolen from Mastodon... If you know the author, please contact us!_
36+
37+
## Q...what !? QChat !
38+
39+
[_QChat_](https://plugins.qgis.org/plugins/qchat/) is a chat that integrates into QGIS as a panel, allowing you to share text messages, images, screenshots, lightweight vector data, etc., with other connected users.
40+
41+
![QChat panel in QGIS](https://cdn.geotribu.fr/img/articles-blog-rdp/articles/2025/qchat_revolution/screen_qchat_qgis.webp){: .img-center loading=lazy }
42+
43+
## Why?
44+
45+
The first version of QChat was quite rudimentary and not very scalable. In practical terms, due to its rather limited initial design, the API could only run on a single [uvicorn worker](https://fastapi.tiangolo.com/deployment/server-workers/), i.e. a single system process. This could lead to a limit on the number of people connected simultaneously.
46+
47+
We realised this [during the last QGIS-fr Users Meetings in Avignon](https://video.osgeo.org/w/cabBYiLUoRAZZbLp2CTRj7), and during [the quizz](https://slides.geotribu.net/2025-06-11_qchat_qgisfr2025.html#/0/24) in particular :cold_sweat:
48+
49+
_Patatra_...
50+
51+
With more than 100 people connected, things started to get a bit hectic... :boom::dash:
52+
53+
In order to be able to accommodate more people, we needed to review the design and implementation of the API.
54+
55+
Note that the new version brings some additional features, but the redesign is mainly _under the hood_.
56+
57+
## API redesign: `gischat`
58+
59+
The problem with the initial design is that, on the server side, users and their websocket connections are stored in Python lists and dictionaries. This has the advantage of keeping things simple — which was kind of the initial idea behind QChat :kissing_heart:.
60+
61+
But when you start working with multiple parallel workers, it becomes a problem, because workers are separate processes, each with their own Python lists and dictionaries. For example, it is impossible to insert an element from one worker and retrieve it from another.
62+
63+
It therefore becomes inevitable to use a "database" system or equivalent in order to store common information and enable communication between the different workers. It's difficult to do without it.
64+
65+
With a view to keeping things [K.I.S.S.](https://en.wikipedia.org/wiki/KISS_principle) :kiss:, we turned to [redis](https://redis.io/), which can run on our server and offers a very lightweight ‘database’: lists, dictionaries, etc. Exactly what we need to keep QChat from becoming overly complex.
66+
67+
In addition, Redis offers a [publish](https://redis.io/docs/latest/commands/publish/) & [subscribe](https://redis.io/docs/latest/commands/subscribe/) mechanism, which will allow our various parallel workers to communicate with each other in order to notify a QChat channel.
68+
69+
Here is a diagram explaining how the new QChat server works, which remains the same regardless of the number of parallel workers:
70+
71+
```mermaid
72+
graph TD
73+
subgraph QChat Clients
74+
QGIS1[👩 Alice]
75+
QGIS2[👨 Bob]
76+
end
77+
subgraph gischat server
78+
Worker1[🤖 Worker 1]
79+
Worker2[🤖 Worker 2]
80+
Redis[💾 Redis]
81+
end
82+
83+
QGIS1 --> |1👋 Opens a connection| Worker1
84+
Worker1 --> |2✅ Registers Alice| Redis
85+
Worker1 --> |3👋 Broadcast arrival of Alice| Redis
86+
87+
Redis --> |4👋 Broadcast arrival of Alice| Worker2
88+
Worker2 --> |5👋 Broadcast arrival of Alice| QGIS2
89+
90+
QGIS2 --> |6📦 Sends a message| Worker2
91+
Worker2 --> |7📦 Broadcasts the message| Redis
92+
Redis --> |8📦 Broadcasts the message| Worker1
93+
Worker1 --> |9📦 Broadcasts the message| QGIS1
94+
```
95+
96+
!!! info
97+
The "default" Geotribu server is located at `qchat.geotribu.net`, and offers one channel per language/country: `QGIS-fr`, `QGIS-es`, `QGIS-de`, `QGIS-it`... It is also possible to set up your own server [by following the instructions on the `gischat` repository](https://github.com/geotribu/gischat#deploy-a-self-hosted-instance).
98+
99+
## Creation of the official QGIS plugin: `QChat`
100+
101+
The initial version of QChat in QGIS was part of a hidden feature of the [QTribu](https://plugins.qgis.org/plugins/qtribu/) plugin. It wasn't very easy to find or discover.
102+
103+
So here is a new dedicated plugin available on the official repository: [QChat](https://plugins.qgis.org/plugins/qchat/).
104+
105+
To generate it, [the QGIS plugin templater](https://oslandia.gitlab.io/qgis/template-qgis-plugin/) was used. Unlike the [~~Plugin Builder~~](https://plugins.qgis.org/plugins/pluginbuilder/), this templater has the advantage of creating a solid and modern QGIS plugin structure:
106+
107+
- a clean file tree.
108+
- customizable settings for the plugin, directly in the general QGIS settings.
109+
- a documentation skeleton that is easy to develop.
110+
- a [CICD](https://en.wikipedia.org/wiki/CI/CD) that allows you to publish your plugin automatically and according to your preferred Git platform (GitHub or GitLab are available).
111+
112+
We ran the templater, and 24 prompts later we ended up with a solid QGIS plugin structure!
113+
114+
Here is the output of the plugin generation operation. What's more, it lets you know if you need to see an ophthalmologist at the start of the new school year...
115+
116+
![Launching the QGIS plugin templater to generate the QChat structure](https://cdn.geotribu.fr/img/articles-blog-rdp/articles/2025/qchat_revolution/qchat_plugin_templater_run.webp){: .img-center loading=lazy }
117+
118+
!!! warning
119+
If you want to create a new QGIS plugin in the future, forget the Plugin Builder. It's way more fancy to start with the templater.
120+
121+
## Bonus: a QField plugin for QChat
122+
123+
Alongside the development of the API and the QChat plugin, there is now also [a QField plugin](https://github.com/geotribu/qchat-qfield-plugin) compatible with QChat, for which we would like to thank [Mathieu Pellerin](https://github.com/nirvn), who initiated the project and got us started.
124+
125+
![Screen of the QField plugin compatible with QChat](https://cdn.geotribu.fr/img/articles-blog-rdp/articles/2024/qchat/prez/ecran_qchat_qfield_plugin.webp){: .img-center loading=lazy }
126+
127+
Currently, to use it, you need to add this URL in the "Plugins" settings of QField: <https://github.com/geotribu/qchat-qfield-plugin/releases/latest/download/qfield-plugin-qchat.zip>
128+
129+
In the future, we will do our best to make it available on the QField plugin repository once it is up and running :wink:
130+
131+
## What's next?
132+
133+
There are always new ideas and features to develop in QChat. Here are some of the ones we're thinking about:
134+
135+
- Adding a small form for sending emojis :joy_cat:
136+
- Sharing graphic models between multiple clients connected to QChat.
137+
- Sharing and executing pyqgis code. Yes. Just to please your IT Security Manager :smirk:
138+
- Adding a new panel and API feature to communicate with [matrix](https://matrix.org/) servers, a decentralized communication standard.
139+
140+
And a lot more! If you have any ideas, please share them with us!

0 commit comments

Comments
 (0)