Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions 010_aiida_gui/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# AEP 010: A dedicated Graphical User Interface for AiiDA

| AEP number | 010 |
|------------|--------------------------------------------------------------|
| Title | A dedicated Graphical User Interface for AiiDA |
| Authors | [Xing Wang](mailto:xingwang1991@gmail.com) (superstar54) |
| Champions | [Xing Wang](mailto:xingwang1991@gmail.com) (superstar54), [Edan Bainglass](mailto:edan.bainglass@psi.ch) (edan-bainglass) [Kristjan Eimre](mailto:kristjaneimre@gmail.com) ( eimrek), [Bud Macaulay](mailto:bud.macaulay@psi.ch) (bud-macaulay)|
| Type | S - Standard Track AEP |
| Created | 18-June-2025 |
| Status | Draft

---

## Table of Contents

1. [Background](#background)
2. [Proposed Enhancement](#proposed-enhancement)

* [Key Features](#key-features)
3. [Implementation Details](#implementation-details)

* [Backend: FastAPI & aiida-restapi](#backend-fastapi--aiida-restapi)
* [Frontend: React & Component Library](#frontend-react--component-library)
* [Plugin Architecture](#plugin-architecture)
* [Apps Integration](#apps-integration)
* [CLI & Deployment](#cli--deployment)
* [Security & Authentication](#security--authentication)
4. [Usage Examples](#usage-examples)
5. [Design Considerations](#design-considerations)

* [Integration with AiiDA Core](#integration-with-aiida-core)
* [Performance and Scalability](#performance-and-scalability)
* [Extensibility and Maintainability](#extensibility-and-maintainability)
6. [Optional apps integration](#optional-apps-integration)
7. [Conclusion](#conclusion)

---

## Background

AiiDA’s command-line interface (CLI) is powerful and scriptable, yet many users, especially newcomers, find the text-based tools steep to learn and lacking in interactivity. Modern computational science benefits greatly from visual summaries of running processes, interactive data viewers (for crystal structures, band structures, arrays…), and plugin-driven dashboards that can be composed on the fly. While tools like AiiDAlab and Materials Cloud offer some GUI functionality, they either run within Jupyter notebooks or impose heavy deployment overhead. A dedicated, self-hosted AiiDA GUI would lower the barrier to entry, speed up common tasks, and provide a solid foundation for community-built extensions.


---

## Proposed Enhancement

Provide a standalone web-based graphical interface for AiiDA, **AiiDA GUI**, that allows users to inspect and control processes, explore data nodes in rich viewers, and extend its functionality through plugins.


### Key Features

* **Core Views**

* **Process Table:** live view of running and completed processes, with filters, search, and status badges, and control buttons (pause, resume, kill, delete).
* **Data nodes Table:** browse Data nodes with faceted filters and custom projections.
* **Node Group Table:** create, edit, and query Groups of nodes or processes.
* **Daemon Control:** start/stop/restart the AiiDA daemon and monitor logs in real time.
* **Computer & code:** Configure and manage computers and codes.
Comment on lines +53 to +59
Copy link
Member

Choose a reason for hiding this comment

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

What are correspond API endpoints? It is one or some operations requires a combined operations?
This influence the decision about whether the restAPI is better, or using GraphQL to make complex query, or using protobuff (gRPC) to have one-to-one operations bind between frontend and backend.

Copy link
Member Author

@superstar54 superstar54 Jun 24, 2025

Choose a reason for hiding this comment

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

The list of endpoints is replied in another comment.
In the current design, the FastAPI endpoints are enough to cover all the use cases. But, as written in the AEP, we need to Refactor aiida-restapi to allow query-time projections and filters.

Copy link
Member

@unkcpz unkcpz Jun 25, 2025

Choose a reason for hiding this comment

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

But, as written in the AEP, we need to Refactor aiida-restapi to allow query-time projections and filters.

You didn't list any detail how you gonna to refactoring, what endpoint need to change etc. Please list them out.


* **Rich Data Viewers**

* Raw JSON inspector for any node
* Specialized renderers: crystal structure (using weas), band structure plots, array and dict, and more.
Comment on lines +61 to +64
Copy link
Member

Choose a reason for hiding this comment

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

In my note of you presentation, @giovannipizzi mention maybe not considered the actually viewer but just dump the data to the browser. Then it has full flexibility how it can be improved after and I am more confident to see the raw data structure and how the data is being validate than a "fancy" web component.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what is proposed here:

  • Raw JSON inspector for any node
    and
  • Specialized renderers, as an additional (rich) viewer for selected AiiDA data node, e.g., the AiiDA data node in the aiida-core. However, we also leave the flexibility to mount the rich viewer from the plugins.

Copy link
Member

@unkcpz unkcpz Jun 25, 2025

Choose a reason for hiding this comment

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

Don't "leave the flexibility", the flexibility comes when it required, for the aiida-gui, keep it small from beginning so it is finish-able. All other feature creep takes brain-energy to discuss.


* **Rich Process Viewers**

* Interactive WorkChain and workflow graphs (e.g., inspired by `WorkGraph`), as well as process report, summary etc.
* `CalcJob` viewers similar to Materials Cloud.
* Provenance graph visualization or table: inputs, outputs, and dependencies.

* **Plugin Ecosystem**

* Load frontend dynamically into sidebar, new pages or data viewers.
* Shared React component library (`aiida-react-components-base`) published to npm

* **CLI Integration**

* `pip install aiida-gui` (or `verdi gui install`)
* Commands: `aiida-gui start|stop|restart|status`
* Mount the React frontend into FastAPI so only a single process is needed

* **Security & Multi-User Support**
Copy link
Member

Choose a reason for hiding this comment

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

out of scope.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • Token-based access (?token=…) akin to Jupyter notebooks

This is suggested by @giovannipizzi , and I also think we need to support, thus avoid different users from the same computer has access to other user's data.

  • Optional integration with JupyterHub deployment for centralized authentication

As it said, this is "Optional", and a nice feature, e.g., in the aiida tutorial, if we use AiiDAlab depoyment, the user can use this feature.

Copy link
Member

Choose a reason for hiding this comment

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

thus avoid different users from the same computer has access to other user's data.

Token is not assigned by user, so this is not true statement.

As it said, this is "Optional", and a nice feature, e.g., in the aiida tutorial, if we use AiiDAlab depoyment, the user can use this feature.

Then you want to add it in the implementation or not? In the AEP, just list things you will execute in the implementation.


* Token-based access (`?token=…`) akin to Jupyter notebooks
* Optional integration with JupyterHub deployment for centralized authentication

---

## Implementation Details

### Backend: FastAPI & aiida-restapi

* **Leverage** the existing [aiida-restapi](https://github.com/aiidateam/aiida-restapi) endpoints, adding new ones as needed.
* **Refactor** aiida-restapi to allow query-time projections and filters (e.g. selecting only certain columns).
Copy link
Member

Choose a reason for hiding this comment

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

Can you list all you can expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

All the endpoints listed in another reply need to be refactored to support this.

Copy link
Member

Choose a reason for hiding this comment

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

please list them out.

* **Expose** new routes for plugin registration and discovery.
* **Mount** plugin routers automatically by scanning entry points under `aiida_gui.plugins`.

### Frontend: React & Component Library

* **Framework:** React (latest stable), built with Vite or Next.js in ESM mode.
* **Component Package:** `aiida-react-components-base` on npm, containing:

* Data viewers, e.g., StructureViewer, BandsPlot, TableGrid.
Copy link
Member

Choose a reason for hiding this comment

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

What payload to send and what you expect to return from the requests? Is current restAPI support all off it or you need some modification on the returned response?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the /nodes/{id} endpoints, it returns all the node attributes.
For some node that needs more info than the attributes, we can provide specific endpoints for that node type.

Copy link
Member

Choose a reason for hiding this comment

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

Why more endpoint? why not query attributes, why not through a payload? Please provide more details those are things required in an "enhancement proposal". Please read some PEP to see how those structured and I am nicely remind you to clean up the chatgpt polished text.

* Common UI elements, e.g., Code selection, process tree.
* **Build & Mount:**

* Build output is a static bundle served by FastAPI at `/static/`.
* FastAPI serves `index.html` at `/`, embedding the React app.

### Plugin Architecture

* **Backend:** Plugins declare entry points under `aiida_gui.plugins` which provide a FastAPI Router. On startup, the core app includes these routers under `/plugins/{name}`.
* **Frontend:** Plugins publish an ESM bundle, with its entry describing routes and components to mount in the sidebar or as standalone pages. The core React app loads and mounts these dynamically.

### CLI & Deployment

* **Entry Point:** `aiida-gui` console script
* **Commands:**

* `aiida-gui start [--host HOST] [--port PORT] [--token TOKEN]`
* `aiida-gui stop`
* `aiida-gui restart`
* `aiida-gui status`
* **Configuration:** `~/.config/aiida/gui-config.json` holds defaults for host/port, token, plugin enable/disable.

### Security & Deployment

* **Token Auth:** generate a random token at first run; all GUI requests must include `?token=` or `Authorization: Bearer`.
* **JupyterHub Integration:** provide optional flags to respect JupyterHub’s proxy authentication and mount under user’s namespace, e.g., under `/user/{name}/aiida-gui/`.
Comment on lines +127 to +130
Copy link
Member

Choose a reason for hiding this comment

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

non-functional feature I believe, would be nice to have but could you give reasons why it is important to support authentication?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a nice feature that is needed for the deployment. For example, people can use it inside an AiiDAlab deployment on Microsoft Azure, e.g., in the aiida tutorial.

Copy link
Member

Choose a reason for hiding this comment

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

If it is something that you insist to add here, add a paragraph to argue that, please.



---

## Usage Examples

```bash
pip install aiida-gui
aiida-gui start --port 8080
```

* Open `http://localhost:8080?token=3f8d2a…` in your browser.
* Browse running processes, inspect nodes, and control the daemon.

To install a community plugin:

```bash
pip install aiida-gui-myplugin
aiida-gui restart
```

The plugin’s sidebar entry appears; clicking it loads its custom page and data viewers.

---

## Design Considerations

### Integration with AiiDA Core

* **Non-intrusive:** No changes to `aiida-core` are required beyond optional dependency mount the cli command to `verdi`.

### Performance and Scalability

* **Backend:** FastAPI + Uvicorn supports async concurrency; use caching where appropriate for heavy queries.
Copy link
Member

Choose a reason for hiding this comment

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

I assume "caching" means the HTML caching? Be careful that can cause the inconsistent behavior when you have update the backend data at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Caching where appropriate for heavy queries refers to caching on the backend side, specifically for expensive database queries. It's not related to HTML caching.

* **Frontend:** Code-splitting ensures only needed plugins are loaded.

### Extensibility and Maintainability

* **Plugin-First:** Every new feature should live as a plugin until it proves broadly useful for the core.
* **Shared Components:** Encourage reuse via the `aiida-react-components-base` package.
* **Documentation & Testing:** Provide cookie-cutter plugin template, and CI pipelines for core and plugins.

---

## Optional apps integration

Apps differ from standard plugins, which are JavaScript modules dynamically loaded into the core GUI. Instead, apps are collections of AiiDA GUI applications delivered as fully self-contained static bundles (HTML, JS, and CSS) that run independently of the main React router. They provide complete, task-specific frontends with their own UI and workflow logic, while still interacting with AiiDA via its REST API, e.g., a DFT app that submits Quantum Espresso calculations, streams job status, and visualizes results.

* **Packaging:** apps are static HTML/JS/CSS bundles under `/apps/{app_name}/` deployed alongside the core GUI.
* **Discovery and launch:** the GUI’s "Apps" page lists installed apps with names, icons, and metadata; users can launch them directly in a new tab or window.
* **Reuse:** apps may import shared components from `aiida-react-components-base` to maintain a consistent UX.

---

## Conclusion

The proposed AiiDA GUI brings a modern, user-friendly interface to AiiDA, reducing the learning curve and enabling rich, interactive exploration of workflows and data. By building on FastAPI and React, and embracing a plugin ecosystem, the GUI will be flexible, performant, and easily extensible by the community. This enhancement promises to accelerate AiiDA adoption and catalyze the development of domain-specific extensions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Accepted AEPs can be easily browsed and read on the [online documentation](https
| 007 | implemented | [Abstract and improve the file repository](007_improved_file_repository/readme.md) |
| 008 | implemented | [Allow `CalcJob`s to be actively monitored and interrupted](008_calcjob_monitors/readme.md) |
| 009 | implemented | [Improved Docker images](009_improved_docker_images/readme.md) |
| 010 | draft | [AiiDA GUI](010_aiida_gui/readme.md) |

## Submitting an AEP

Expand Down