Skip to main content

Project Architecture

This section describes the architecture of the project.

Structure

The Bemuse project is a monorepo. This means every package that shapes the project lives inside the same repository, which allows for easier development process.

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.
packages
Contains projects closely-related to the core Bemuse project. These are published into separate npm packages.
public
Files that will be deployed verbatim to the server, except forindex.html, where the boot script will be inlined. These include skin files.
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.
website
The code that powers this documentation. We use Docusaurus to build our documentation as a static website.

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 intoindex.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.

Packages

We also maintain other closely-related packages. These used to live in their own repository, but we've merged them into the main Bemuse repo for easier development.

bms-js
This package is a BMS parser written in JavaScript.
bmson
This package contains various functions useful for working with bmson files.
bemuse-tools
This package contains the command-line tools to convert a BMS package into a Bemuse package. Traditional BMS packages are optimized for offline playing. They are distributed as a large .zip file with .wav, .mpg, and .bms files.