# Setup environment

For development purposes, it’s convenient to have a local Platforma backend running with access to the local file system and `PATH`.

## Run local backend

You can easily start a local backend using the `@platforma-sdk/bootstrap` package:

```bash
pnpx @platforma-sdk/bootstrap@latest start local s3 --license <your_license_code>
```

This command will download the latest Platforma backend binary, start a local [Min.IO](https://min.io) service as the default S3-compatible storage, and run the backend service with the default settings.

Alternatively, you can run the backend in a Docker container with the following command:

```bash
pnpx @platforma-sdk/bootstrap@latest start docker s3 --license <your_license_code>
```

> **Note:**
>
> When using `bootstrap` in `local` mode, the Runner Controller can execute commands available in the local `PATH`, which is useful for development purposes.

To view all available options for `bootstrap`, run:

```bash
pnpx @platforma-sdk/bootstrap@latest start local s3 --help
```

## Set path to development blocks

To add a local development block registry, specify the path to the directory containing your development blocks in the `devBlocksPaths` section of the settings in the desktop app:

![](/_astro/add-dev-blocks-path.BHADFF_x_Z1StxP5.webp)

The path can point to a directory with multiple blocks, making them all available in Platforma:

```plaintext
└── /directory/with/dev/blocks/
    ├── block1
    │   └── ...
    ├── block2
    │   └── ...
    └── block3
        └── ...
```

You can add multiple paths.

## Generate block boilerplate

Generate a block boilerplate with the following command:

```bash
pnpx @platforma-sdk/bootstrap@latest create-block
```

You will be prompted to enter the following information:

- Name of publishing organization in NPM registry: The NPM organization name used for publication. For example, the [Platforma Open Community](https://pl-open.science) uses `@pl-open`. If developing private blocks not intended for publication, any identifier can be used.

- Name of developer organization: Your organization or lab’s name.

- Package name of block The block’s identifier, written in lowercase letters without spaces (distinct from the block title).

The resulting block package will have the following structure:

```text
<@npm-publisher>/<organization>.<block>
```

After generation, modify the root `package.json` to fill in the block’s meta information in the `block.meta` section:

See block meta information

```json
"block": {
  "meta": {
    "title": "Block Title",
    "logo": "file:logos/block-logo.png",
    "url": "https://github.com/milaboratory/block-boilerplate",
    "docs": "https://github.com/milaboratory/block-boilerplate/docs",
    "support": "mailto:support@milaboratories.com",
    "description": "Block description",
    "longDescription": "file:./docs/description.md",
    "changelog": "file:CHANGELOG.md",
    "tags": ["tutorial"],
    "organization": {
      "name": "MiLaboratories Inc",
      "url": "https://milaboratories.com",
      "logo": "file:logos/milaboratories.png"
    }
  }
}
```

## Build block

First, install dependencies with `pnpm install`:

```bash
pnpm install
```

To build the block for development, run the below command. It creates a development version of the block that uses the local software package.

```bash
pnpm run build:dev
```

Use this when your block is ready for distribution. This build assumes the software package is published to the registry and will be downloaded from there when users run the block

```bash
pnpm run build
```

To build only a specific component, such as the model, navigate to the model directory and run:

```bash
cd model
pnpm run build
```

Once built, you can add the block to Platforma:

![](/_astro/add-block-hello-world.DCbe6fUb_ZcKY8t.webp)

## Open block in IDE

Finally, open the block repository in Visual Studio Code to facilitate development. Simply use File -> Open Folder:

![alt text](/_astro/vscode.QCfx2GSD_1TBmi.webp)

Source: https://docs.platforma.bio/sdk-dev-environment/
