Build a backend
A backend gives data to FINOS Workspace. It is a web server that you write and run. The FINOS Workspace API calls it for the browser of the user.
A backend answers these requests:
| Method | Path | Answer |
|---|---|---|
| GET | /widgets.json | The widgets that the backend offers |
| GET | /apps.json | The apps that the backend offers. An empty list is permitted. |
| GET or POST | The endpoint of each widget | The data of the widget |
The API makes the calls, so the backend needs no CORS settings for the web app. Each example in this section comes in Python and in TypeScript. Select the language once, and all the examples show it.
Read this section in this order
The pages go from simple to complex:
- Your first backend: a tutorial. Write a backend with two widgets, connect it, and build a dashboard.
- Write widgets.json: the fields of a widget.
- Widget types: Markdown, HTML, news feed, PDF and iframe.
- Parameters: the controls in the header of a widget.
- Widget settings: when a widget gets its data again.
- Style an HTML widget: HTML that follows the light and dark theme.
- Make a widget readable by the Agent: give the Agent the rows behind a widget.
- Linked widgets and apps: widgets that share a parameter, and an app in
apps.json. - Offer an app: a tutorial. Add an app to your first backend.
- Turn a dashboard into an app: export a dashboard that you built by hand.
- Forms: a form that sends data to the backend.
- Review and debug a backend: find the cause when a backend does not work.
The reference backend
The pages in this section use the reference backend as their example. The reference backend is a complete backend with 31 widgets and one app. It shows all the widget types that FINOS Workspace draws itself, all the kinds of parameters, the widget settings, linked widgets and a form.
- It comes in Python and in TypeScript. The two versions give the same answer to each request.
- All its names, numbers, articles and documents are invented. It reads no outside service and contains no data that needs a license.
- Its code is in the repository at
docs/examples/reference-backend.
Run it, and you see each example of this section in a dashboard.
Files
docs/examples/reference-backend/
├── widgets.json the widgets, served at /widgets.json
├── apps.json the app, served at /apps.json
├── data.json the invented data that both versions read
├── assets/ a sample PDF and an SVG chart, made for this backend
├── python/ main.py and requirements.txt
├── typescript/ main.ts and package.json
└── test/ the test that compares the answers of the two versions
The two versions read the same widgets.json, apps.json and data.json. Only their code is different.
Run it
You need a clone of the FINOS Workspace repository and a FINOS Workspace that runs. The quick start shows how to start FINOS Workspace.
- Python
- TypeScript
You need Python 3.10 or later. From the root of the clone, run these commands:
cd docs/examples/reference-backend/python
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --port 5050
You need Node.js 22.18 or later. Node.js runs TypeScript directly. The backend uses only the modules of Node.js, so you install nothing. From the root of the clone, run these commands:
cd docs/examples/reference-backend/typescript
node main.ts
The backend uses port 5050.
- To use a different port, set
PORT.
To check the backend, open http://localhost:5050/widgets.json. The page shows the widgets.
Connect it
- In FINOS Workspace, select Connections in the sidebar.
- Select Connect Backend.
- In Name, type
Reference backend. - In Endpoint URL, type
http://localhost:5050. - Select Test. The dialog finds 31 widgets and 1 app.
- Select Add.
- Open Apps and select Reference backend tour.
FINOS Workspace creates a dashboard with three tabs: Widget types, Parameters and Linked widgets. The widget catalog shows all the other widgets in the category Reference backend.
Test it
The test starts the two versions and sends the same requests to each. It sends a request to the endpoint of each widget, with variants of the parameters, errors and the form. The test fails if an answer is different.
Install the Python packages first. Then run this command in docs/examples/reference-backend:
PYTHON=python/.venv/bin/python node --test test/parity.test.mjs