A story about creating a forum service in the age of AI

I've been quietly working on this for the past two weeks or so, and I've been gathering a lot of knowledge, so I've decided to leave it as an output of that. Concept The concept of the service is a forum service for developers. It manages multiple communities with a single service. Anyone can create a new community, and within that, they can become an administrator, or conversely, they can participate as a member in other communities. The ideal form would be a service like Discord that is open (anyone can view). Why a forum? Currently, Slack and Discord are often used to manage online communities. In fact, the author also uses Slack and Discord in their community. However, I feel that there are some problems. Knowledge becomes closed Since chat is not searchable on the web, knowledge tends to become closed. Although there is a high level of psychological safety, it makes it difficult for beginners to gain knowledge online, as the same questions are regularly repeated. In addition, because of the atmosphere of high psychological safety, there are cases where people write words that they would not usually use, and then have screenshots taken of them. You don't know if you can continue to use it for free Since Salesforce acquired Slack, it has undergone several functional revisions. The history of past revisions is also deleted after a certain period of time. Accumulating knowledge is difficult, and in that sense, it is not suitable for communities. I personally like Discord, but the UX is a little unusual, and it is often perceived as problematic for beginners. Discord itself is free to use (individuals can pay for it), but it is unclear whether it will be maintained in the future. Account management is complicated This is the case with Slack, but I personally don't like the fact that each URL has its own separate account. As the number of accounts increases, the more complicated password management becomes, and some people end up reusing passwords. There is the advantage of being able to change the character for each URL, but I feel that the advantage of being able to manage everything with a single account is greater. The settings are also independent, and setting them up each time is also a hassle. Advantages of Forums I think the following are the advantages of forums. Openness Forums can be searched on the web, and knowledge becomes open. Communication in an open forum encourages appropriate behaviour. Freedom for users If you just want to browse a forum, you don't need to register as a user, and you don't need to be prepared to jump off a cliff like in a chat room. Issues with existing forums I don't think many forum services have many Japanese developers. 5channel The advantages and disadvantages of anonymity Reddit There is a Japanese subreddit, but it is basically for English speakers Slashdot Sa-shu... Stack Overflow Specialised in QA. There are tags, but it is not a community in the traditional sense. Teratail Specialised in QA. There are tags, but it is not a community in the traditional sense. There is also open-source forum software, but it is basically one community, one forum. In other words, you need to set up your own server as your own community. This means that you need to register an account for each community, and managing the server for the community can be troublesome. Multiple Community? NodeBB Community Multiple communities on discourse? - Support - Discourse Meta Starting to create a forum So, I started to create a forum. It's hard to develop from scratch, and there's a lot of reinventing the wheel, so I investigated the following open-source forums. Discourse NodeBB Flarum phpBB As a result, I found that a plugin for NodeBB would allow me to do a certain number of things. If it's open source, you can be reassured (?). How NodeBB plugins work NodeBB plugins are made up of the following three files. plugin.json Basic plugin information package.json Plugin dependencies and installation as a package library.js Plugin code (file name is arbitrary) Creating a plugin plugin.json describes the basic information for the plugin. { "id": "nodebb-plugin-caiz", "name": "NodeBB Plugin for Caiz", "description": "NodeBB Plugin for Caiz", "version": "1.0.0", "library": "./library.js", "staticDirs": { "language": "locales" }, "hooks": [ { "hook": "static:app.load", "method": "init" }, { "hook": "filter:categories.build", "method": "customizeCategoriesLink" }, { "hook": "filter:topic.build", "method": "customizeTopicRender" }, { "hook": "filter:category.get", "method": "customizeCategoryLink" } ] } Basically, you write the event that the plugin calls and the name of the JavaScript function under hooks. Hooks - NodeBB Documen

Apr 5, 2025 - 07:16
 0
A story about creating a forum service in the age of AI

I've been quietly working on this for the past two weeks or so, and I've been gathering a lot of knowledge, so I've decided to leave it as an output of that.

Concept

The concept of the service is a forum service for developers. It manages multiple communities with a single service. Anyone can create a new community, and within that, they can become an administrator, or conversely, they can participate as a member in other communities.

The ideal form would be a service like Discord that is open (anyone can view).

Why a forum?

Currently, Slack and Discord are often used to manage online communities. In fact, the author also uses Slack and Discord in their community. However, I feel that there are some problems.

Knowledge becomes closed

Since chat is not searchable on the web, knowledge tends to become closed. Although there is a high level of psychological safety, it makes it difficult for beginners to gain knowledge online, as the same questions are regularly repeated.

In addition, because of the atmosphere of high psychological safety, there are cases where people write words that they would not usually use, and then have screenshots taken of them.

You don't know if you can continue to use it for free

Since Salesforce acquired Slack, it has undergone several functional revisions. The history of past revisions is also deleted after a certain period of time. Accumulating knowledge is difficult, and in that sense, it is not suitable for communities.

I personally like Discord, but the UX is a little unusual, and it is often perceived as problematic for beginners. Discord itself is free to use (individuals can pay for it), but it is unclear whether it will be maintained in the future.

Account management is complicated

This is the case with Slack, but I personally don't like the fact that each URL has its own separate account. As the number of accounts increases, the more complicated password management becomes, and some people end up reusing passwords. There is the advantage of being able to change the character for each URL, but I feel that the advantage of being able to manage everything with a single account is greater. The settings are also independent, and setting them up each time is also a hassle.

Advantages of Forums

I think the following are the advantages of forums.

Openness

Forums can be searched on the web, and knowledge becomes open. Communication in an open forum encourages appropriate behaviour.

Freedom for users

If you just want to browse a forum, you don't need to register as a user, and you don't need to be prepared to jump off a cliff like in a chat room.

Issues with existing forums

I don't think many forum services have many Japanese developers.

  • 5channel The advantages and disadvantages of anonymity
  • Reddit There is a Japanese subreddit, but it is basically for English speakers
  • Slashdot Sa-shu...
  • Stack Overflow Specialised in QA. There are tags, but it is not a community in the traditional sense.
  • Teratail Specialised in QA. There are tags, but it is not a community in the traditional sense.

There is also open-source forum software, but it is basically one community, one forum. In other words, you need to set up your own server as your own community. This means that you need to register an account for each community, and managing the server for the community can be troublesome.

Starting to create a forum

So, I started to create a forum. It's hard to develop from scratch, and there's a lot of reinventing the wheel, so I investigated the following open-source forums.

  • Discourse
  • NodeBB
  • Flarum
  • phpBB

As a result, I found that a plugin for NodeBB would allow me to do a certain number of things. If it's open source, you can be reassured (?).

How NodeBB plugins work

NodeBB plugins are made up of the following three files.

  • plugin.json Basic plugin information
  • package.json Plugin dependencies and installation as a package
  • library.js Plugin code (file name is arbitrary)

Creating a plugin

plugin.json describes the basic information for the plugin.

{
  "id": "nodebb-plugin-caiz",
  "name": "NodeBB Plugin for Caiz",
  "description": "NodeBB Plugin for Caiz",
  "version": "1.0.0",
  "library": "./library.js",
  "staticDirs": {
    "language": "locales"
  },
  "hooks": [
    {
      "hook": "static:app.load",
      "method": "init"
    },
    {
      "hook": "filter:categories.build",
      "method": "customizeCategoriesLink"
    },
    {
      "hook": "filter:topic.build",
      "method": "customizeTopicRender"
    },
    {
      "hook": "filter:category.get",
      "method": "customizeCategoryLink"
    }
  ]
}

Basically, you write the event that the plugin calls and the name of the JavaScript function under hooks.

Hooks - NodeBB Documentation

There are two types of hooks in use at the moment, and the list of server-side hooks is defined in Hooks · NodeBB/NodeBB Wiki. The other type is a build hook that is called when the template is rendered, and it is called in the format filter:(template name).build. However, the build hook is sometimes not called even when a file name is specified, and I don't fully understand how it works...

Creating plugin code

This is the basic form of a plugin. plugin.init is called because init is specified in static:app.load in hooks. This is a hook function that is called when the app starts up.

'use strict';
const winston = require.main.require('winston'); 
const plugin = {};
plugin.init = async function (params) {
  const { router, middleware, controllers } = params;
  winston.info('[plugin/caiz] Initializing Caiz plugin');

  router.get('/api/communities', controllers.categories.list);
  router.get('/api/:handle', Community.Index);
};
module.exports = plugin;

You can also output logs using console.log, but using winston, you can change the log format and the output destination.

The router for routing is Express, so you can add routing using router.get, etc.

controllers are NodeBB controllers mapped to src/controllers, so they are easy to understand.

Customising the template

The default template for NodeBB is NodeBB/nodebb-theme-harmony. You can clone this, specify it as the theme, and customise it.

It uses Bootstrap for display and benchpressjs for the template engine. When customising the display content, use the build hook to modify templateData.

static async customizeIndexLink(data) {
  const { categories } = data.templateData;
  categories.forEach(category => {
    category.link = `/${category.handle}`;
    if (!category.children) return;
    category.children.forEach(child => {
      child.link = `/${category.handle}/${child.cid}-${child.handle}`;
    });
  });
  return data;
}

If you write code like this, you can display it in the template with { ./link }. The template is a *.tpl file in the templates directory. Note that there is no display support for Benchpress in VS Code, etc., so it seems better to highlight it as an HTML file.

Reflecting themes and plugins

Themes and plugins are installed using the npm command.

npm install nodebb-theme-caiz

This will install nodebb-theme-caiz. After installation, activate it.

./nodebb activate nodebb-theme-caiz

This will activate the theme and plugin.

If you make modifications

If you modify the plugin, restart NodeBB. You can do this either via command or from the admin screen.

./nodebb restart

If you modify the theme, you will also need to build it. You can do this from the command line or from the administration screen.

./nodebb build
./nodebb restart

If you are developing with Docker Compose, restarting will not work, so it seems better to operate from the administration screen.

Current situation

At the moment, we are still just starting to understand the mechanisms of plugins and themes, and many functions are lacking.

  • Creating, editing and deleting communities
  • Registering and deleting members
  • Registering, editing and deleting member permissions
  • Functions using AI

I think the functions, such as posting, can use the standard NodeBB functions. While I'm making it, I'll publish it if I have any knowledge. Or rather, there is little published information about NodeBB plugin development, so I'm groping in the dark. So I'll leave it as a memo for myself. Even on Qiita, there is no NodeBB tag, which is proof of that...

Furthermore, because there is not a lot of information, even when using the AI Coding Agent, there are many cases where it generates code that does not work. If we publish our knowledge this way, it may gradually become smarter...

Summary

There are so many different types of hooks in NodeBB that it seems like you could implement a wide range of functions using only plugins. There are also a lot of settings, so if you can get to grips with plugins, settings, and themes, I have a feeling you'll be able to meet most needs.

The code is available below.

goofmint/caiz