Project Architecture

This section describes the architecture of the project.

Directory Structure

bin
Useful scripts for routine work. Examples include setting up Git commit hooks and releasing a new version.
config
Configuration code for webpack and other things.
docs
This documentation.
public
Files that will be deployed verbatim to the server, except for index.html, where the boot script will be inlined. These include skin files.
spec
Contains the unit tests. Its directory structure resembles the src directory.
src
Contains the production code. Code is split into modules for different parts of the application.
tasks
Gulp tasks to run test server, build, test the application.

Important Modules

These modules live in the src directory. There may be an arbitrary number of modules. Therefore, this section only lists the significant modules.

boot

This module is the entry point to Bemuse. It reads the ?mode= parameter and determines the name of the main module to load. It then displays a loading indicator and loads the main module asynchronously. After the main module is downloaded, finally, it is executed. Main modules include app, the game, and test, the unit tests. Upon building, the boot script will be inlined into index.html.

Rationale: No one likes blank white page. We want the user to see the application starting up as soon as possible, even though it is simply a loading indicator. To make this blazingly fast, we keep the compiled size of the boot very small, and inline that compiled code directly into the HTML file. So, no round-trip HTML requests! If they can load the HTML, they will see the loading bar.

app
This is the main module of the game’s application flow. Executing this module will present the game’s main menu.
test
This is the main module for unit tests. Executing this module will setup the environment for testing, load the unit tests in spec directory, and then execute them. After the test is run, the results and coverage data (if available) will be sent back to the server for further processing.
game
This module contains the actual game part. For example, the logic for judging notes, calculating score, and rendering the scene.