Skip to content
88 changes: 88 additions & 0 deletions docs/app-specification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Arduino App specification

This is the specification for the `Arduino App` (from now on called App) format to be used with `arduino-app-cli` and `Arduino App Lab`.

# Arduino App Folder structure

An App is a self-contained folder that includes the following components:

- `app.yaml` (mandatory) the file descriptor of the app in YAML format.
- `sketch` (optional) the folder containing an Arduino [Sketch](https://arduino.github.io/arduino-cli/1.3/sketch-specification/)).
- `python` (optional) the folder containing the Python code.

At least one on `sketch` or `python` folder must be present.
The App must be self-contained (it does not contain references to external files) because this means it can be exported, shared, or zipped easily.

The user-defined apps are saved into `/home/arduino/ArduinoApps` folder.
The builtin-apps are stored into `home/arduino/.local/share/arduino-app-cli/examples` folder.

Example of a `my-app` folder structure

```
my-app/
README.md
app.yaml
sketch/
sketch.ino
sketch.yaml
python/
main.py
```

## `README.md` file

An (optional) readme file in markdown.
The link to local resources must be in the same folder of the app. For example, a png inside the folder `myapp/docs/my-banner.png` can be referenced using ![My App](docs/my-banner.png) syntax.

### `app.yaml` file descriptor

The `app.yaml` (or `app.yml`) is a YAML file that describes an App.

- `name`: (optional) a short name of the app.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name optional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the optional piece. Maybe we should just specify what's mandatory, implying that everything else is optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, better, we should provide a JSON SCHEMA file (as we did for the Arduino CLI configuration) https://github.com/arduino/arduino-cli/blob/master/internal/cli/configuration/configuration.schema.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, currently an empty app.yaml is valid and the ardiuno-app-cli is able to run it.

arduino@merola:~/ArduinoApps/my-app$ cat app.yaml

- `description`: (optional) a brief description of the app.
- `icon`: (optional) the emoji of the app
- `ports`: (optional) a list of ports to be exposed externally. If not given a random port is opened (if necessary).
- `bricks` (optional) a list of bricks used by the app with its variable definitions.

Example:

```yaml
name: My Arduino App
description: An example app showcasing what you can do
icon: 🍓
ports:
- 7000

bricks:
- arduino/dbstorage:
variables:
ROOT_PASSWORD: ${secret.db_password}
PORT: 8080
- arduino/text-generation:
model: gemma-1
- arduino/objectdetection:
model: yolo
```

### `sketch` sub folder

The content of the `sketch` subfolder contains the Ardiuno skecth.
It must omply with the [Sketch specification](https://arduino.github.io/arduino-cli/1.3/sketch-specification/).

If present it must contain the followign files:

- `sketch.ino`
- `sketch.yaml` that is compliant to the [Sketch project file](https://arduino.github.io/arduino-cli/1.3/sketch-project-file/)

### `python` sub folder

The content of the `python` contains the python code.

If present, it must contain the `main.py` with the python code of the main.
Optionally, a `requirements.txt` with additional python package dependencies to be installed.

### Other

Other sub-folders or files can be added to the app folder.
The reserved folder names are `sketch` and `python`.
The reserved file names are `app.yaml` and `sketch.yaml`.
Comment on lines +94 to +98
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should discourage adding extra files in the root folder; maybe we could reserve an extras folder for user-specific data.