# SMART RESTful API Gateway
https://articonf1.itec.aau.at:30401/api/ui/ 

The API Gateway serves as an interface to external applications. Here, users are authenticated and blockchain transactions are added.

## Authentication
```POST https://articonf1.itec.aau.at:30401/api/tokens``` with body:
```
{
  "username":"regular@itec.aau.at",
  "password":"2bViezK0Tst2LzsTIXix"
}
```
returns the JWT token for authentication, e.g. 
```
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
```
This token is used for authentication as _regular user_ on all microservices currently supporting authentication. Therefore the authentication header "```Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...```" has to be added to the request.

## Blockchain transactions
```POST https://articonf1.itec.aau.at:30401/api/trace``` with body:
```
{
  "ApplicationType": "use-case identifier as string",
  "key": "value",
  ...
}
```
adds a blockchain transaction entry for ApplicationType with all the keys and values. These will be converted and stored in our own format for creating multilayers and communities.

# Business Logic Microservice
https://articonf1.itec.aau.at:30420/api/ui/

This microservice contains use-case specific informations, like schemas and contexts.

## Schema information
```GET https://articonf1.itec.aau.at:30420/api/use-cases/{use-case}/tables``` returns all schema mappings for the use-case identifier. The mapping is used to flatten nested input from the blockchain.

## Context information
```GET https://articonf1.itec.aau.at:30420/api/use-cases/{use-case}/layers``` returns all layers from the schema used for clustering interally.

# Trace Retrieval Microservice
https://articonf1.itec.aau.at:30001/api/ui/

This microservice contains the nodes from the transactions preprocessed as defined in *Schema Information*.

```GET https://articonf1.itec.aau.at:30001/api/use_cases/{use_case}/transactions``` returns all flattened transactions, before splitting them into layers.

# Semantic Linking Microservice
https://articonf1.itec.aau.at:30101/api/ui/

This microservice splits the preprocessed transactions into multipe layers, calling the splitted transaction per layer nodes.

```GET https://articonf1.itec.aau.at:30101/api/use-cases/{use_case}/tables/{table_name}/layers/{layer_name}/nodes ``` returns all splitted transactions, called nodes, for the layer layer_name.

# Role Stage Discovery Microservice
https://articonf1.itec.aau.at:30103/api/ui/

This microservice contains the communities based on clusters and similarities between communities. It additionally contains time slices with subsets of clusters, which's transaction happened in the corresponding time window. 
Schemas and Input data are supplied by the [Business Logic microservice](https://articonf1.itec.aau.at:30420/api/ui), [Semantic Linking microservice](https://articonf1.itec.aau.at:30101/api/ui/) and [Trace Retrieval microservice](https://articonf1.itec.aau.at:30101/api/ui/).

## Layers
Contains information about the schema copied from the Business Logic microservice.
Returns the Schemas and/or Input data used for calculating the clustering which is further used for calculating the similarity.

```GET https://articonf1.itec.aau.at:30103/api/use-cases/{use_case}/layers``` returns layer infos for the given use-case.

```GET https://articonf1.itec.aau.at:30103/api/use-cases/{use_case}/tables/{table}/layers/{layer_name}``` returns the layer information for only the one layer.

```GET https://articonf1.itec.aau.at:30103/api/use-cases/{use_case}/tables/{table}/layers/{layer_name}/nodes``` contains all the nodes contained in the layer fetched from the Semantic Linking microservice.

## Clusters
Contains the clustering results. Clustering is performed on all nodes inside one layer. Furthermore the clusters are partitioned based on timestamps.

```GET https://articonf1.itec.aau.at:30103/api/use-cases/{use_case}/tables/{table}/layers/{layer_name}/clusters``` returns the identified clusters.

```GET https://articonf1.itec.aau.at:30103/api/use-cases/{use_case}/tables/{table}/layers/{layer_name}/timeslices``` returns the identified clusters partitioned based on their nodes' timestamps.

## RunId
When a similarity computation is executed, it has an associated RunId which is used to uniquely identify that execution.

```GET https://articonf1.itec.aau.at:30103/api/runIds``` returns all RunIds in the db.

## Similarity
Returns the computed similarity. Two clusters belonging to the SAME layer will be given a similarity value by comparing them to another cluster belonging to a DIFFERENT layer. This is done for every cluster in the input data. This querry returns all the calculated similarity values, given the criteria (i.e belonging to a use-case,table etc).

```GET https://articonf1.itec.aau.at:30103/api/use_cases/{use_case}/tables/{table}/clusterSimilarity``` returns all similarity values for the given use-case and table.

## Connected Cluster
Intermediary data-structure used only by the function which computes the similarity. Clusters are connected only to other clusters belonging to a DIFFERENT layer.

```GET https://articonf1.itec.aau.at:30103/api/use_cases/{use_case}/tables{table}/connectedClusters``` returns all connected clusters for the given use-case and table.
