BookBrainz website, written in node.js.
Clone or download
MonkeyDo Merge pull request #183 from akhilesh26/bug/query_search
Fix(Query on initial Search): Initial search Query is not showing in result Page in input query box.
Latest commit 095168f Sep 20, 2018
Failed to load latest commit information.
.github Add PR template for use on github Apr 23, 2016
config feat: extend default session lifetime to 30 days Aug 26, 2018
data style: fix lint errors in data/test-data.js Dec 10, 2017
docker chore(docker): Lower privileges for running server Dec 17, 2017
flow-typed chore: add Flow type information to entity.js routes file Aug 23, 2018
scripts Merge pull request #179 from kartikohri1712/master Sep 8, 2018
src Fix(Query on initial Search): Initial search Query is not showing in … Sep 20, 2018
static Merge branch 'master' of into n… Sep 11, 2016
test fix(display): make renderRelationship throw with invalid inputs, and … Sep 8, 2018
.babelrc chore: ignore less requires in client JS when building with babel Sep 14, 2018
.dockerignore chore(docker): Copy over package-lock.json for consistent build Dec 17, 2017
.doclets.yml Switch to documenting src folder, since doclets cannot (yet) run npm … Jan 16, 2017
.editorconfig Bring .editorconfig in line with what's in files now Apr 24, 2016
.eslintignore refactor(core): Setting up hot module reload on the server including … Aug 21, 2018
.eslintrc.js style: remove silly multiline-comment-style rule May 20, 2018
.flowconfig chore: initialize flow config and dependencies, add flow preset to babel Jun 13, 2017
.gitignore refactor(core) Hot module export entity-editor controller and ignore … Aug 27, 2018
.gitmodules Switched to HTTPS for Lobes submodule, in an attempt to fix tests. Jun 27, 2015
.jsinspectrc chore(package.json): Add dupreport script Dec 29, 2017
.travis.yml test(core): Added postgres version in travis config Aug 26, 2018 docs: update contributing guide Apr 29, 2018
Dockerfile chore(docker): Copy over package-lock.json for consistent build Dec 17, 2017
LICENSE Added LICENSE and included factor-bundle in dev deps. Jan 20, 2015 Added instructions to set up test database Sep 20, 2018
package-lock.json chore: swap jade/pug templates to ES6 string templates Sep 4, 2018
package.json chore: ignore less requires in client JS when building with babel Sep 14, 2018
webpack.client.js refactor(core) Hot module export entity-editor controller and ignore … Aug 27, 2018

BookBrainz Site

Build Status Dependency Status devDependency Status Code Climate

This repository contains the code for the BookBrainz web site. The directories are arranged as follows:

  • config - the config to be used when running the site; copy the example files and edit, dropping the .example suffix.
  • scripts - scripts used during the development and deployment of BookBrainz.
  • src - node.js source files defining the site logic and user interface.
  • static - static files which are served by node as part of the site.
  • templates - Jade templates defining how the site looks - we're slowly replacing these with React.
  • test - unit tests and functional tests for the site.

Additionally, after building the client JavaScript (see below), the following directories will exist:

  • static/stylesheets - the CSS generated from compiling the project LESS files (src/client/stylesheets).
  • static/js - minified JavaScript files which are referred to by the site pages.


Auto-generated developer documentation can be found at our corresponding doclets site. Our contributing guide can be found here.

Setting up a local BookBrainz server

Installing Dependencies

BookBrainz depends on having PostgreSQL, Redis and Elasticsearch and NodeJS set up and running.

To get PostgreSQL, use one of the following commands:

Debian-based OS

sudo apt-get install postgresql

Red Hat-based OS

sudo yum install postgresql-server

To install Redis, run similar commands to get the dependency from your package manager:

Debian-based OS

sudo apt-get install redis-server

Red Hat-based OS

sudo yum install redis

To install Elasticsearch, follow the instructions at

And finally, for NodeJS, choose the correct installation file, or view the instructions for package managers at

Setting up Dependencies

No setup is required for Redis or Elasticsearch. However, it is necessary to perform some initialization for PostgreSQL and import the latest BookBrainz database dump.

Firstly, begin downloading the latest BookBrainz dump from

Then, uncompress the latest.tar.bz2 file, using the bzip2 command:

bzip2 -d latest.tar.bz2

This will give you a file that you can restore into PostgreSQL, which will set up data identical to the data we have on the website. To do this, run:

sudo -u postgres pg_restore -e -C -O latest.tar -d postgres

At this point, the database is set up, and the following command should give you a list of usernames of BookBrainz editors (after entering the password from earlier):

sudo -u postgres psql bookbrainz -c "SELECT name FROM bookbrainz.editor"


Since this project makes use of git submodules, you need to use git clone --recursive to clone it. Alternatively you can follow the directions in the documentation linked here to manually initialize submodules.

Currently used submodules:

To clone the repository and point the local HEAD to the latest commit in the stable branch, something like the following command should work:

git clone --recursive

Installing Packages

The site depends on a number of node packages which can be installed using npm:

cd bookbrainz-site/
npm install

This command will also compile the site LESS and JavaScript source files.


Create a copy of config.json.example and rename it to config.json. Then, edit the values so that they are correct for your environment. If the prior instructions have been followed, it should only be necessary to change the PostgreSQL username and password.

Building and running

A number of subcommands exist to manage the installation and run the server. These are described here; any commands not listed should not be called directly:

  • start - start the server in production mode, with code built once
  • debug - start the server in debug mode, with code watched for changes
  • lint - check the code for syntax and style issues
  • test - perform linting and attempt to compile the code
  • jsdoc - build the documentation for JSDoc annotated functions within the code


The test suite is built using Mocha and Chai. Before running the tests, you will need to set up a bookbrainz_test database in postgres. Here are the instructions to do so:

  1. Clone the bookbrainz-sql repository. We will refer below to the directory simply as bookbrainz-sql/
  2. Run the following postgres commands to create and set up the bookbrainz_test database:
  • psql -c 'CREATE DATABASE bookbrainz_test;' -U postgres
  • psql -c 'CREATE EXTENSION "uuid-ossp"; CREATE SCHEMA musicbrainz; CREATE SCHEMA bookbrainz;' -d bookbrainz_test -U postgres
  • psql -f bookbrainz-sql/schemas/musicbrainz.sql -d bookbrainz_test -U postgres
  • psql -f bookbrainz-sql/schemas/bookbrainz.sql -d bookbrainz_test -U postgres
  • psql -f bookbrainz-sql/scripts/create_triggers.sql -d bookbrainz_test -U postgres
  1. Profit.