Get started with NPL
You can start developing NPL in various ways:
- Use Codespaces to get started without installing anything locally
- Set up your local NPL development environment locally
Explore these options below by editing, running and deploying to cloud the sample code of a Hello World application.
Please note that if you are trying to do things within a corporate environment you may be restricted from installing (some of) the required 3rd party tools.
Develop in Codespaces
Prerequisite: a GitHub account with Codespaces access.
In the npl-init repository, click on Use this template (visible once
logged into your GitHub account) and Open in a codespace at the top right of the screen. This will start a GitHub
Codespace, pre-configured with the NPL CLI, the NPL-Dev extension and a sample project.
Once the Codespace is open, you can follow the steps in the README.md.
If you have a NOUMENA Cloud account, your NOUMENA Cloud tenants and applications will be listed in the NOUMENA Cloud pane. Hover over an application and select the upload button to deploy the NPL code. If you have a frontend, you can deploy it as well.
Deploying the Hello World demo frontend from Codespaces to NOUMENA Cloud
In case you want to deploy the complete Hello World demo app, including the frontend, from
Codespaces to NOUMENA Cloud, you may repeat the above steps with the
npl-demo repository. Before deploying the frontend, adjust
webapp/.env, build the frontend and configure users on the NOUMENA Cloud portal as detailed in section
Deploy backend and frontend to NOUMENA Cloud below.
For further step-by-step instructions, check out Starter tracks and How-to guides.
Develop locally
Run locally
Prerequisites: these systems need to be installed on your machine
- Docker how to install
- Git
- should be part of any normal distribution, but if not, how to install
- Noumena Digital NPL CLI how to install,
- Docker Desktop how to install
- Git
- the easiest way to get Git is to install the XCode command line extensions
- Noumena Digital NPL CLI how to install,
- Windows Subsystem for Linux how to install
- Docker Desktop how to install
- Git
- is part of WSL and we recommend to use the WSL Shell for all command line interactions on Windows
- there are several ways to install Git natively on Windows
- Noumena Digital NPL CLI how to install (WSL), how to install (native),
Steps:
-
Create a new project from the NPL starter template containing the
Hello Worldbackend. You can do this by running:npl init --project-dir my-projectHowever, we recommend to clone and deploy the complete
Hello Worlddemo application, including frontend, from the npl-demo repository:git clone https://github.com/NoumenaDigital/npl-demo.git -
Check the NPL is correct and run the supplied unit tests
npl checknpl test -
Start the NPL Runtime locally. From the root of the new project, run:
docker compose up -d --build --wait -
Deploy NPL to the NPL Runtime:
npl deploy -
Follow the remainder of the README.md in project directory to interact with the backend deployed locally.
-
The frontend is built into the demo in development mode and runs in Docker. Navigate to the frontend URL with http://localhost:5173/.
Note that the local deployment uses an embedded OIDC server with seeded users. The embedded OIDC server should be used for development purposes only.
Deploy backend and frontend to NOUMENA Cloud
Prerequisites:
-
The NPL-demo project containing the
Hello Worldapplication running locally (see above). -
npminstalled ordockerwe recommend you usedocker.To clone the NPL-demo repository, run:
git clone https://github.com/NoumenaDigital/npl-demo.git
Steps:
-
Sign up to NOUMENA Cloud
-
Create a new tenant and a new application in the NOUMENA Cloud portal (more details here on application creation, if needed). Pay attention to the resulting tenant and application slugs, as displayed in the
portal.noumena.cloud/TENANT_SLUG/APPLICATION_SLUGURL of your application. -
Adjust the
npl.ymlfile in your project root folder to match your NOUMENA Cloud tenant and application slugs by setting thecloud.tenantandcloud.appproperties accordingly. -
Also log in from the command line using the NPL CLI:
npl cloud loginThis will open a browser window to authenticate with NOUMENA Cloud. Provide your credentials, choose Sign In, and grant access privileges. After successful authentication, you can close the browser window and return to the terminal.
-
Deploy the NPL source code by running the following command from the
npl-demo/root of the cloned repository:npl cloud deploy nplIf you are deploying once more, clear the NPL package first (or implement a migration):
npl cloud clear && npl cloud deploy nplNote that you can also provide the tenant slug, application slug and path to the migration file directly as command line arguments (
--tenant,--app,--migration) to the above commands, overriding the values set innpl.yml. For more information, typenpl cloud deploy help.With this step, you already have a fully functional backend running on NOUMENA Cloud, as reflected by the Swagger UI available under
https://engine-TENANT_SLUG-APPLICATION_SLUG.noumena.cloud. Let's now deploy the frontend to NOUMENA Cloud. -
Change the
webapp/.envfile to match your NOUMENA Cloud tenant and application. Make sure to use the tenant and application slugs rather than the full names -
From the project root directory, build the frontend:
docker compose build webappAlternatively, if you do not have Docker installed, but do have
npminstalled, from the webapp directorynpm i && npm run build -
From the project root directory, deploy the frontend to NOUMENA Cloud
npl cloud deploy frontendThis uses values for the tenant slug, application slug and path to the frontend build that are defined in
npl.yml. You can override these settings with command line arguments (--tenant,--app,--frontend). For more information, typenpl cloud deploy help. -
Configure users on the NOUMENA Cloud portal. You will need to create
alice,bobandcarolusers according to the create application users guide.The hardcoded demo password in the webapp is
password12345678for all users. Feel free to change it to your liking, ensuring that the password of application users created on NOUMENA Cloud is matching the one used across the webapp. -
Navigate to the
https://TENANT_SLUG-APPLICATION_SLUG.noumena.cloudfrontend URL of your NOUMENA Cloud application and try out the Hello World application flow
Edit NPL in your IDE
The tools listed above are the minimum required for the following steps, however to work effectively work with NPL you also need to install an IDE which supports NPL, if you don't already have one. We have NPL support for
- VS Code
- IntelliJ
- The plugin works with any of the IntelliJ variants (Community, Ultimate, WebStorm, PyCharm, etc.)
- IntelliJ is recommended for development work such as debugging and testing
- IntelliJ bundles additional tools like Maven and Gradle
- [Windows] IntelliJ will detect the Git executable in WSL, IntelliJ can be configured to use WSL as the shell
Prerequisites:
- Hello World backend code created with
npl initor complete Hello World application (backend and frontend) code cloned fromnpl-demorepository (see Run locally)
Steps:
-
Install the embedded NPL-Dev Plugin in your IDE (IntelliJ, VS Code, or VS Code-derived)
-
Edit the NPL code in the
api/src/maindirectory. You may for example start by changing the string (Text) returned by thesayHellopermission -
From the
npl-demoroot of the cloned repository, start the NPL Runtime and the Frontend locally. Make sure thewebapp/.envspecifies the local host in the Vite environment variablesgit checkout master webapp/.env docker compose up -d --build --wait -
Clear and upload the NPL code to the NPL Runtime
npl deploy --clear -
The frontend is built into the demo in development mode and runs in Docker. Navigate to the frontend URL with http://localhost:5173/. The
docker composeset up uses volumes, so changes to FE code are picked up by the Vite Hot Module Replacement and there is no need to restart the server. If you need to restart the server you can do thisdocker compose up -d --build --wait --no-deps --force-recreate webapp
Take your next steps
Now you are familiar with development and deployment options:
- Follow Starter tracks to take your next steps
- Explore more NPL examples
- Check out the reference documentation for the NPL Language, the NPL Runtime and NOUMENA Cloud