---
# System prepended metadata

title: Babelfish Component

---

# Babelfish Component

## Simple Scenario

An organizations wants to exchange data with another organization.

### Traditional Approach

```plantuml
@startuml
participant subject [
    =Data Subject
    ----
    ""Organization A""
]
participant controller [
    =Data Controller
    ----
    ""Organization B""
]
hide footbox
@enduml

subject -> controller: create entry
```

**Problems with this approach:**
* the incumbent defines the interface
    * a new organizations needs to implement API and data model for the existing platform (e.g., register at Amazon)
    * a new platform needs to onboard existing organizations with their infrastructure (e.g., establish an Amazon competitor)
* governance is established beforehand
    * not machine readable
    * no negotiation phase
* documentation of the data exchange happens by the entities itself (leading to data silos)

### Babelfish Approach

```plantuml
@startuml
autonumber
boundary Initiator as init
entity "Organization A" as orgA
queue Babelfish as babelfish
entity "Organization B" as orgB
collections ontochain as "Ontochain\nEnvironment"
@enduml

== Preparation ==
orgB -> babelfish: register service to\nconsume data
babelfish -> ontochain: document registration

orgA -> babelfish: register service to\nprovide data

babelfish -> ontochain: document registration

== Data Exchange ==
init -> babelfish: trigger data exchange
babelfish -> babelfish: check governance &\ncreate Data Agreement

babelfish -> orgA: retrieve data
babelfish -> babelfish: transform data for \nOrganization B
babelfish -> orgB: send data
babelfish -> ontochain: document data exchange\n(incl. Data Agreement and Provenance)
```

&nbsp;

**Notes for each step:**

1. & 3. *register service*
    provide service description either as JSON or as DID
    * interface using: Open API Spec 3.0
      https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md
    * data model using: https://ownyourdata.github.io/soya/
    * governance using Data Privacy Vocabulary (https://w3c.github.io/dpv/dpv/)
        SOyA structure https://soya.ownyourdata.eu/UsagePolicy (draft)

    Gatway API: `POST /service`

#### Service Description

  <details><summary>JSON structure</summary>

  ```json=
  {
      "interface": {["API description"]},
      "data": "reference to SOyA structure",
      "governance": {["attributes from DPV"]}
  }
  ```
  </details>

  <details><summary>Example</summary>

  `POST /service`
  ```json=
  {
    "interface": {
      "service": "write_data",
      "party": "data_provider",
      "path": "POST /api/data"
    },
    "data": "zQmbEC1LtiwcVZQa5XH4pKZN3Lrv5pxDAh4WpjHFAeeDZTm",
    "governance": {
      "dpv:hasProcessing": ["dpv:Copy", "dpv:Transform", "dpv:Use"],
      "dpv:hasPurpose": "dpv:Purpose",
      "dpv:hasExpiryTime": "2023-11-15T00:00:00"
    }
  }
  ```
  </details>


2. & 4. *document registration*

* define schema
* just write to blockchain / available Ontochain services?

5. *trigger Babelfish*

* can be either Data-providing or Data-using service (therefore, the artifical instance of an "initiator")


6. *check Usage Policy & create Data Agreement*

* use reasoner to check if both Usage Policies match
* generate Data (Sharing) Agreement statement

7. *retrieve data*

* retrieve data from Data-providing service(s) according to API specification in service description

8. *transform data*

* align data models from data-providing and data-using service and perform transformation
    consider intermediate data format / common concept instead of m:n mapping


9. *send data*

* write data to Data-using service(s) according to API specification in service description

10. *document data exchange*

* generate provenance record
* just write to blockchain / available Ontochain services?


## Simplified Approach used in D2

```plantuml
@startuml
autonumber
entity "Entity A" as orgA
queue Babelfish as babelfish
entity "Entity B" as orgB
collections ontochain as "Storage\nProvider"
@enduml

== Preparation ==
orgA -> babelfish: trigger data exchange
orgB -> babelfish: trigger data exchange
babelfish -> babelfish: check governance &\ncreate Data Agreement

== Data Exchange ==
autonumber stop
ontochain --> orgA
autonumber resume
babelfish -> orgA: retrieve data
babelfish -> babelfish: optionally transform\ndata for Entity B
babelfish -> orgB: send data
autonumber stop
babelfish --> ontochain
autonumber resume
babelfish -> ontochain: document data exchange\n(incl. Data Agreement and Provenance)
```
