Skip to main content

Overview

Reboot provides the rbt CLI tool to automatically generate code and reload your application when your code changes. You can also choose to use an existing build system to generate code by using Reboot's Protobuf plugins directly.

Set up your environment

You can use one of Reboot's GitHub Codespaces or set up your environment manually by installing the prerequisites listed below.

Prerequisites

OS
Linuxx86_64, glibc>=2.35 (Ubuntu Jammy and other equivalent-generation distributions)
macOSarm64 or x86_64 macOS >= 13.0 and Xcode >= 14.3
  • Python == 3.10 is required for Python backends, and fetched automatically for Node.js backends
  • Node.js >= 18.0.0 is required for Node.js backends only
  • Docker
note

Your applications don't need to run "inside of" Docker, but Docker is used to host a service you need to use for local development.

rbt init

The rbt init command initializes your Reboot project with a hello_world template. You can customize the project by selecting specific languages and platforms, and the tool will automatically update your .rbtrc configuration based on your selections.

Python backend

To set up a Python backend, use the following command:

rbt init --name=reboot_hello_world --backend=python

This will generate the necessary source files and include a Python script to test the connection to the backend.

TypeScript backend

For a TypeScript backend, use the following command:

rbt init --name=reboot_hello_world --backend=nodejs

This will create the source files and configure package.json if it doesn't already exist.

Frontend

To initialize a frontend with React, use the following command:

rbt init --name=reboot_hello_world --frontend=react

This command generates the source files and sets up package.json in the web directory for the frontend.

note

You can initialize both backend and frontend simultaneously. Here are examples for Python and TypeScript:

For Python:

rbt init --name=reboot_hello_world --backend=python --frontend=react

For TypeScript:

npx rbt init --name=reboot_hello_world --backend=nodejs --frontend=react

Directory layout

You can layout your directories how ever you like, as long as you pass them correctly to rbt.

Here is a suggested file layout:

FilesDirectory
*.protoapi/
Backend source *.py, *.ts/jsbackend/src
Backend tests *.py, *.ts/jsbackend/tests
Frontendweb

.rbtrc

rbt loads its flags from an .rbtrc file, if present. This is a convenient way of keeping the options you have to type and remember to a minimum.

Here's an example of an.rbtrc file for a Reboot application with a Python backend:

# Generate 'python' code from our '.proto' files in 'backend/api/'.
protoc --python=backend/api/

# Find '.proto' files in 'api/'.
protoc api/

dev run --watch=backend/src/**/*.py

dev run --python

dev run backend/src/main.py

Here's an example of an .rbtrc file for a Reboot application with a Node.js backend:

# Generate 'nodejs' code from our '.proto' files in 'api/'.
protoc --nodejs=api/

# Find '.proto' files in 'api/'.
protoc api/

dev run --tsc='npx tsc'

dev run --watch=backend/src/**/*.ts

dev run --nodejs

dev run dist/backend/src/main.js
note

Note that for Node.js, transpilation of TypeScript to JavaScript can be done via --tsc=... or is left to you and your favorite tools. If you don't pass --tsc then you'll likely want to watch the files in dist/ rather than backend/src so that rbt will only restart your app when they have been correctly transpiled.

note

You can pass any flags directly to protoc by using the -- separator as shown below:

In a terminal:

rbt protoc --python=backend/api/ api/ -- --mypy_out=backend/api/

In .rbtrc:

# Find '.proto' files in 'api/'.
protoc api/

# Generate 'python' code from our '.proto' files in 'backend/api/'.
protoc --python=backend/api/

# Generate 'mypy' code from our '.proto' files in 'backend/api/mypy/'.
protoc -- --mypy_out=backend/api/mypy/

In these examples, the order of the flags is crucial. All flags that appear after -- are passed directly to protoc.

Boilerplate code

The rbt protoc command can generate boilerplate code based on your .proto files, giving you copy-paste-able Python/TypeScript method definitions for which you only need to fill in the implementation. To generate the boilerplate code, use the --boilerplate flag followed by the path to the directory where you want the boilerplate code to be placed:

In Terminal:

rbt protoc --boilerplate=backend/boilerplate/

In .rbtrc:

protoc --boilerplate=backend/boilerplate/
note

It's important not to modify the generated files directly, as they will be overwritten the next time you run rbt protoc. Instead, you should copy (parts of) the generated files to your source directory and make your modifications there.

Running your app for development

Once you've setup your environment as outlined above, all you'll need to run to start live developing your app is:

$ rbt dev run
...

Or if you're building a Node.js backend with npm (after installing @reboot-dev/reboot):

$ npx rbt dev run
...

Persisting state during development and rbt dev expunge

By default your application state will not be persisted across restarts.

To persist state, you can pass a --name=... flag to rbt dev run. While this can be very useful while developing, it is designed to mimic a production environment and thus will not allow you to create any backwards incompatible changes in your .proto files.

This is great if your application is already running in production as it will keep you from causing production outages! But during early development of your application you might encounter a backwards incompatible change that is not an issue because you haven't deployed your application yet.

If you want to delete all of the state of a named application and start from scratch, use rbt dev expunge --name=... where --name=... is the same value you're using for rbt dev run.

Inspecting state

While doing local development you can inspect your application state by pointing your browser at https://dev.localhost.direct:9991/__/inspect (assuming you haven't changed the default port from 9991).