How does the component database get created?


I’m doing some investigating into how the component categories in the blocks editor get populated, and I’m a bit stuck.

My current understanding is that the Java annotations somehow get parsed, and they are used to create the component database. That database is then used by drawer.js to populate the categories.

My questions are:

  1. Where is the source code for turning the annotations into something usable?
  2. How does the relate to component_database.js?

But any other info/corrections are super appreciated!

Thank you for your time,

1 Like

Hi @BeksOmega,

That work is done as part of the annotation processors. The one you want to look at is This produces a file in the components build tree called simple_components.json, which is pulled into the appengine module.

The ComponentDatabase is the Java view over the simple_components.json file union any components.json provided by extensions. It is used by the designer.

component_database.js serves two purposes. First, it is a JavaScript version of the type database from the Java side. Second, it manages the JavaScript view of the instances of all the components for use in the blocks editor.

I have a vision to reconcile these two at some point so there is a single item, but it's been on the back burner for a while now.


1 Like

Is there any specific reason why String Builder is used to manually craft the JSON? Because maybe it could be easier (or cleaner) to build an object with the org.json library, or any other?
The current procedure works, but it feels rudimentary to manually write a JSON rather than using objects which generate the JSON in a string that can be written into a file.


Historical reasons mostly. I thought I had an issue to rewrite that to use the org.json API instead of using StringBuilder.

Edit: My memory is correct:


Thank you for the information! That was exactly what I needed :smiley: