EarthBrain technical overview

This project started out as a single repository: FoodBrain. This was later split up into 2 repositories: EarthBrain and ForestBrain. The reason for this is to separate common data types, such as user, taxonomy and location data, from the more specific data inside the project itself (which was FoodBrain at the time, but gradually morphed into ForestBrain). This way, EarthBrain can be used in other projects to, serving different goals with a unified data structure. The first of these sister projects was ReleafBrain.

What follows here is a brief overview of some of the components inside the EarthBrain ecosystem, and how they interact with other "brain halves".

Architecture

Most of the data lives inside MODX, in the custom earthbrain_* database tables. The database model is relational, meaning that tables are internally referencing each other (one-to-one, one-to-many, many-to-many). These relationships can be utilized in your code to join relevant data together and represent it from a single object / array.

Some kinds of data are connected to a MODX resource:

  • foodForest
  • foodForestComponent
  • foodForestInput

This means those objects are tied to a modResource object, which will contain generic data (such as name, description, alias).

MODX

MODX is the CMS that's currently used to manage and present data. It's a PHP/MySQL based framework primarily used for making websites. It has its own templating engine with a simple syntax, which lets you do all the templating yourself. This requires more work upfront than many other platforms, but it doesn't force you into a specific development workflow. You have 100% control over the output, which is exactly what I want.

In MODX, resources are used to represent data on a web page. The layout is controlled by the resource template and each resource has a content area for everything unique to that page. You can add anything you want there through the ContentBlocks page builder.

To speed up development of MODX projects, I created a platform called Romanesco, containing most common building blocks for an average website. Romanesco takes care of the basics and presentation, so we can focus on the FoodBrain data.

Sharing data across contexts

One of the main goals of ForestBrain is to share the available data between projects (or organizations). Inside MODX, they will be represented by a context. At the time of writing, the following contexts are in place:

  • ForestBrain - central repository with forest data
  • PFF - philippinefoodforest.org
  • SONATA - info about organization and database of mother trees
  • Baganihan - journal and permaculture design of my personal food forest project
  • Global - generic data that can be reused across contexts
  • Hub - for testing, references and documentation

Each context can use different templating, content elements and styling to represent the same ForestBrain data. This makes things a lot more efficient, as you only need to maintain 1 MODX installation.

Users

EarthBrain users are connected to MODX users. This makes it a bit more complicated to access this data from outside MODX, but the benefit is that we can use the advanced and flexible permission system of MODX.

For more info, see earthbrain-user-management.

Managing data

The MODX manager comes with a frontend written in ExtJS, which takes care of most GUI elements. Some extras (such as ContentBlocks) have their own UI, but the overall user experience is pretty consistent with how ExtJS works. One handy feature that's widely available is the right-click context menu, so I encourage you to explore that. Keyboard commands (like Ctrl + S for saving) also work in most views, as does drag & drop.

Development

For managing the custom EarthBrain data, an extra called MIGX is used. This extra allows me to develop CRUD functionality in ExtJS, using only JSON configuration files. It's also possible to work directly in ExtJS, but that is quite a complex undertaking. Be warned ;)

External use

In the future, I'm planning to expose the data through an API (probably with Directus). Help appreciated!