Skip to content

Latest commit

 

History

History
66 lines (41 loc) · 4.18 KB

File metadata and controls

66 lines (41 loc) · 4.18 KB

Lire cette page en français English, page shown

MicroCoaster WebApp, the web control application

The web application that drives MicroCoaster layouts. It discovers the connected ESP32 modules, shows their state in real time, and lets you build sequences that orchestrate a whole layout.

Live at app.microcoaster.com.

01 Architecture

The application talks to two worlds that do not have the same needs, so it uses two separate channels.

Browsers talk to the application over Socket.io, which brings automatic reconnection, a long-polling fallback and one room per user. There they find the connected modules, realtime telemetry, sequence building, accounts and notifications. The ESP32 modules talk over raw WebSocket, in short JSON messages with authentication on connect: Switch Track, Launch Track, Lift Hill, Audio module, Smoke Machine and the simulators. At the centre, the WebApp in Node.js, Express and MySQL is the only one that knows the full state of the layout.

Socket.io towards the browsers. Automatic reconnection, a long-polling fallback, one room per user. It is comfortable on the web side and it tolerates a temperamental network.

Raw WebSocket towards the ESP32s. No extra layer, no transport negotiation: a microcontroller has neither the memory nor the need for a Socket.io client. The modules authenticate on connection, then exchange short JSON messages.

This is also where the system's authority sits. A module never decides to move on its own: it carries out an order from this application, which is the only one that knows the full state of the layout.

02 Structure

Repository tree. api: the event handlers, modules, users, notifications. websocket: the link to the ESP32 modules. bdd: data access, one DAO per entity. routes: the HTTP routes. middleware: authentication and access control. views: the page templates. public: the assets served as they are. locales: the interface translations. sql: the schema and the seed data. esp: the reference firmwares for the modules. sim: the module simulators, to develop without hardware. tests: the automated tests. utils: the shared helpers.

The sim/ folder deserves a word: it holds simulators that pass themselves off as real modules. You develop and test the orchestration of a complete layout without having to wire anything at all.

03 Installation

git clone https://github.com/Microcoaster/MicroCoasterWebApp.git
cd MicroCoasterWebApp
npm install
cp .env.example .env

Fill in .env, then create the database:

mysql -u root -p < sql/schema.sql
mysql -u root -p < sql/default_data.sql

04 Development

npm start           # start
npm test            # tests
npx eslint .        # static analysis

The cycle is the organisation's: an issue describes the work, a branch starts from develop, a pull request comes back onto it and goes through review before reaching main.

05 Ecosystem

The modules driven by this application each have their own repository: Switch Track, Launch Track, Lift Hill, Audio module, Smoke Machine. The common base is the WiFi Manager.


MicroCoaster · Authors: Cybertrist, Yamakajump