Skip to main content

Local Development

This page will walk you through the installation of Dara framework and the creation of a simple 'Hello World' app.

Requirements

There are two prerequisites to being able to use the Dara framework:

  • Python v3.8+
  • NodeJS v14+ (Don't worry you don't need to understand any JS, this is used to build the application in production mode)

You can install both of these via the Homebrew package manager on MacOS or follow the instructions on their websites: Python node.

Once you have these tools installed the best way is to create a Python virtual environment or start a new Python Poetry project so that our dependencies don't conflict with anything you have installed on your wider system.

Installation - Starting a new project

There are two methods in which you can start a new Dara project:

  • The first is through using the CLI for creating apps.
  • The second is by manually starting a project with poetry or pip.

The CLI can be installed globally with

pip install create-dara-app
You can also use `pipx` to install the CLI in an isolated global virtual environment

pipx installation instructions are available here but the short version is:

python3 -m pip install --user pipx
python3 -m pipx ensurepath

You might need to restart your terminal after installing pipx. The ensurepath command adds necessary directories to your PATH, the changes might not be reflected in your terminal until you restart it.

To install the CLI globally with the pipx package, run the following command:

pipx install create-dara-app

You should see a message saying that the CLI has been installed successfully. Check that the CLI is available by running the following command:

create-dara-app --version

Building your app

The following will go through two examples of building a simple app - one using the create-dara-app command line interface and the other using Poetry manually.

If you have installed the create-dara-app package, you can follow these instructions.

create-dara-app creates an app with two pages. The first page is an introductory page with a welcome message, and the second page is a gallery of components, providing a simple example of how to use each component offered in dara-components.

- <your-app-name>/
- <your_app_name>/
- pages/
- intro_page.py
- components_page.py
- utils/
- components.py
- template.py
- main.py
- pyproject.toml
- README.md

To create this app run the following command:

create-dara-app
note

By default the CLI will attempt to scaffold your project with poetry but will fall back to pip if poetry is not present. This can be overriden with --packaging pip or --packaging poetry flag.

Running your application

Once you've got your project setup, you will want to run the application so you can see your application in action. This can be done with a single command from the root of your project:

To start the app:

poetry run dara start --reload
tip

The --reload flag here will cause it to automatically reload the backend and UI whenever any changes are made and saved.

By default it will infer and watch the parent directory of the module containing your config variable. This can be overriden using the --reload-dir flag which can be used multiple times to watch multiple specified directories instead of the default one.

# Example structure
- decision-app/
- decision_app/
- main.py
- pages/
- utils/
- pyproject.toml

# Will watch for changes in these directories: ['(...)/decision-app/decision_app']
dara start --reload
# Will watch for changes in these directories: ['(...)/decision-app/decision_app/pages']
dara start --reload-dir decision_app/pages
# Will watch for changes in these directories: ['(...)/decision-app/decision_app/utils', '(...)/decision-app/decision_app/pages']
dara start --reload-dir decision_app/pages --reload-dir decision_app/utils

This command will start a local development server and will start your application at http://localhost:8000.

If you have used the create-dara-app CLI, your app will look like the following:

Gallery of Components App

If you have set up your app manually, your app will look like the following:

Hello World App