An open API service indexing awesome lists of open source software.

https://github.com/bigraph-toolkit-suite/bigraphs-by-examples.vendingmachine-webservice

Object-oriented Bigraphs
https://github.com/bigraph-toolkit-suite/bigraphs-by-examples.vendingmachine-webservice

bigraphs cdo object-oriented-programming vending-machine

Last synced: about 1 month ago
JSON representation

Object-oriented Bigraphs

Awesome Lists containing this project

README

          

# Bigraphs by Examples: A RESTful Vending Machine

This project is a template for building **database-driven, object-oriented bigraphical applications**
with execution logic defined by **formally verified bigraphs**.
It bridges **analysis and execution** by using bigraphical model checking to verify system behavior before deployment.

#### Screenshots

| | |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| Screenshot of the UI: The web UI allows interaction with the vending machine. | Screenshot of the CDO Explorer: Bigraphs are stored as Ecore models in a database. |

## Features

**Bigraph-centric Design**
- All application data and logic are modeled and stored as bigraphs (Ecore format) in a CDO-based in-memory database

**Integration of Formal Verification**
- The system behavior is subject to model checking
- Results of this analysis influence the application logic (e.g., web endpoints)

**Reactive via Web Endpoints**
- Bigraphical reactions (i.e. state transitions of the application) are triggered through RESTful API calls
- Ideal for interfacing with external systems or simulations

**Model-Based State Evolution**
- Design-time configuration: The initial state, rules, and predicates are set by placing the corresponding bigraph files in `src/main/resources`. These files are the output of formal analysis as implemented in [`Analysis.java`](src/test/java/org.example/Analysis.java).
- Runtime modification: The application behavior can be changed dynamically by editing the model in the CDO database (e.g., add a coin, or change the effect of a rule)

## Getting Started

### Via the IDE (Eclipse, IntelliJ IDEA, Visual Code, ...)

- Run the class `src/main/java/org/example/Application.java`
- Wait until you see in the terminal: "Application has successfully started ..."

### Via the Terminal
Using Maven, issue the following command:
```shell
$ mvn clean package -DskipTests
```

The JAR file is created within the `target` folder of the project's root folder.

To run the application JAR file, execute the following command:
```shell
$ java -jar ./target/code-samples-1.0-SNAPSHOT.jar

# To change the server port
$ java -jar ./target/code-samples-1.0-SNAPSHOT.jar --server.port=9090
```

- Wait until you see in the terminal: `Application has successfully started ...`

### Open the Browser

Afterward, open any browser and go to the following URL: [http://localhost:8080/](http://localhost:8080/)

If the bigraph doesn't appear to reflect the current state, simply refresh the page (press F5 or Ctrl+R) to update it.

**Database Explorer (Optional):**
To view and modify the bigraph within the database, download CDO Explorer via the [Eclipse Installer](https://www.eclipse.org/downloads/packages/installer).
Use Eclipse Version 2025-12 (4.38.0), which supports CDO protocol version *54*.

## Remarks

### Software Stack

- Java >=21
- Maven 3.8.7
- Spring 3.3.5
- [Bigraph Framework](https://github.com/bigraph-toolkit-suite/bigraphs.bigraph-framework) 2.4.0
- [BDSL Grammar](https://github.com/bigraph-toolkit-suite/bigraphs.bdsl-grammar) 2.0.1 and [Interpreter](https://github.com/bigraph-toolkit-suite/bigraphs.bdsl-interpreter-parent) 2.2.1
- [Spring Data CDO](https://github.com/bigraph-toolkit-suite/spring-data-cdo) 0.8.0

### Database & Configuration

- The database configuration file is stored here: `src/main/resources/config/cdo-server.xml`
- Every time the application starts, a fresh in-memory CDO database is created
- The state of the program is not persisted, when the application is shut down
- Listeners for concrete objects in CDO can be attached _before_ they are stored in the database (it is recommended to register listeners after)
- See: [`VendingMachineObject`](src/main/java/org/example/domain/data/VendingMachineObject.java) and [`VMRuleSet`](src/main/java/org/example/domain/behavior/VMRuleSet.java)

### Analysis

- Analysis is placed in the `./src/test` folder of this project
- Execute the unit tests to perform the analysis
- With the IDE or via Maven `mvn -Dtest=Analysis test`

- The results are stored in the resource folder
- Rules, predicates and the metamodel
- The results are re-used for the implementation