Architecture

After installing hoodie, npm start will run cli/index.js which reads out the configuration from all the different places using the rc package, then passes it as options to server/index.js, the Hoodie core hapi plugin.

In server/index.js, the passed options are merged with defaults and parsed into configuration for the Hapi server. It passes the configuration on to hoodie-server, which combines the core server modules. It also bundles the Hoodie client on first request to /hoodie/client.js and passes in the configuration for the client. It also makes the app’s public folder accessible at the / root path, and Hoodie’s Core UIs at /hoodie/admin, /hoodie/account and /hoodie/store.

Hoodie uses CouchDB for data persistence. If options.dbUrl is not set, it falls back to PouchDB.

Once all configuration is taken care of, the internal plugins are initialised (see server/plugins/index.js). We define simple Hapi plugins for logging and for serving the app’s public assets and the Hoodie client.

Once everything is setup, the server is then started at the end of cli/start.js and the URL where hoodie is running is logged to the terminal.

Modules

Hoodie is a server built on top of hapi with frontend APIs for account and store related tasks. It is split up in many small modules with the goal to lower the barrier to new code contributors and to share maintenance responsibilities.

  1. server server repository server build status server coverage status server dependency status

    Hoodie’s core server logic as hapi plugin. It integrates Hoodie’s server core modules: account-server, store-server

    1. account-server account-server repository account-server build status account-server coverage status account-server dependency status

      Hapi plugin that implements the Account JSON API routes and exposes a corresponding API at server.plugins.account.api.*.

    2. store-server store-server repository store-server build status store-server coverage status store-server dependency status

      Hapi plugin that implements CouchDB’s Document API. Compatible with CouchDB and PouchDB for persistence.

  2. client client repository client build status client coverage status client dependency status

    Hoodie’s front-end client for the browser. It integrates Hoodie’s client core modules: account-client, store-client, connection-status and log

    1. account-client account-client repository account-client build status account-client coverage status account-client dependency status

      Client for the Account JSON API. It persists session information on the client and provides front-end friendly APIs for things like creating a user account, confirming, resetting a password, changing profile information, or closing the account.

    2. store-client store-client repository store-client build status store-client coverage status store-client dependency status

      Store client for data persistence and offline sync. It combines pouchdb-hoodie-api and pouchdb-hoodie-sync.

      1. pouchdb-hoodie-api pouchdb-hoodie-api repository pouchdb-hoodie-api build status pouchdb-hoodie-api coverage status pouchdb-hoodie-api dependency status

        PouchDB plugin that provides simple methods to add, find, update and remove data.

      2. pouchdb-hoodie-sync pouchdb-hoodie-sync repository pouchdb-hoodie-sync build status pouchdb-hoodie-sync coverage status pouchdb-hoodie-sync dependency status

        PouchDB plugin that provides simple methods to keep two databases in sync.

    3. connection-status connection-status repository connection-status build status connection-status coverage status connection-status dependency status

      Browser library to monitor a connection status. It emits disconnect & reconnect events if the request status changes and persists its status on the client.

    4. log log repository log build status log coverage status log dependency status

      JavaScript library for logging to the browser console. If available, it takes advantage of CSS-based styling of console log outputs.

  1. admin admin repository admin build status admin dependency status

    Hoodie’s built-in Admin Dashboard, built with Ember.js

    1. admin-client admin-client repository admin-client build status admin-client coverage status admin-client dependency status

      Hoodie’s front-end admin client for the browser. Used in the Admin Dashboard, but can also be used standalone for custom admin dashboard.