---
# System prepended metadata

title: Abstract

---

# Abstract

During SEV-2 postmortem meeting (28-01-2022) we have seen that PMS Sync module is called 
from multiples environments (local development, dev, staging, beta ...) which generates 
request to external services. 

Also the credential management is plain stored in each database which consumes data from 
any external services.

# MVP Propoposal solution

## Actual State

```mermaid
flowchart
    A[Business Logic]
    B[Integration system]
    C[Connection layer]
    
    subgraph Leonardo App
    A --> B
    B --> C
    end
```

## Desired State

Write a proxy to centralize all requests to external PMS's in one point that:

* cache requests to avoid perform duplicated requests to external services.
* centralize credential management to avoid share external (and hard to revoke) credentials to all dev teams
* we can add RBAC subsystem to avoid changes in external systems. Usualy PMS's hava all or nothing permission system. This avoid actual risks (or realities) of data corruption because work-orders can be created from staging enviroments for all accounts.

```mermaid
flowchart LR
    A[Business Logic]
    B[Integration system]
    C[Connection layer]
    
    subgraph Leonardo App
    A --> B
    end
    subgraph PMS Proxy
    B <--> C
    end
```

We can maintain responsabilities of proxy to cover minimal requirements at now.

# Future work

## Better connection layer

Add more features in middle place:

* Add trazability of connections performed against PMS's
* Better good citizen consumer:
    * Implement circuit breaker patterns to avoid overload 
      remote systems on their failures
    * Adapt to anti-throttling policies
* Not enabled features by our RBAC system can be mocked for easier development
* Add dashboards
* ...

## Convert PMS Integration Sync into a set of micro-services

```mermaid
flowchart LR
    A[Business Logic]
    B[Integration API]
    C[Integration Service]
    D[Connection layer]
    E[Credential System]
    F[Credential API]
    
    subgraph Leonardo App
    A
    end
    subgraph PMS Integration Service
    A --> B
    B --> C
    E --> C
    C --> D
    F --> E
    end
```

PMS Integration Service could act as a middleware to simplify how Leonardo App acts with PMS's
* Improve how Work Order API interacts with other systems
* Simplify new integration setup via Credential API
* Monitorize changes in data
* Enforce POD isolation by improving how Integration Team interacts with
  Leonardo Plaform.
* ...

