# PSBio Flows

This document briefly describes the processing flows of *Search*, *Enroll*, *Update* and *Delete* in **PSBio**.

## Search

![Search Flow in PSBio](https://118801336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMy9gZsTdEehR3FxRxgN%2Fuploads%2Fgit-blob-555ebfd124e7cb16b2eac3706b218d4de5f4730a%2Fpsbio1-Search.png?alt=media)

1. Upon receiving a search request (Search), PSBio returns an initial status of *SEARCH\_IN\_PROGRESS*.
2. Two flows are triggered in parallel: the local search (local database and cache) and the remote search on the other PSBios. If the IDN is found (either in the local search or the remote search), the response will be *SEARCH\_MATCH* or *SEARCH\_NOT\_MATCH* depending on the result of the biometric 1:1 match between the query and the existing record with the provided IDN. If the provided IDN is not found (absent from the local database, the local cache, and the other PSBios), the response will be *SEARCH\_FAILED*.

## Enroll

![Enroll Flow in PSBio](https://118801336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMy9gZsTdEehR3FxRxgN%2Fuploads%2Fgit-blob-f36f350068d465b30a8153f5ae3321db66000710%2Fpsbio1-Enroll.png?alt=media)

1. Upon receiving a registration request (Enroll), PSBio returns an initial status of *ENROLL\_IN\_PROGRESS*.
2. The registration data are searched in the *Blacklist*. In case of a biometric match, the transaction is completed with the registration refused and status *ENROLL\_ANOMALY\_BLACKLIST*.
3. The registration's IDN is queried on the other PSBios with an IDN\_Query call. If the IDN is found, the transaction is completed with the registration refused and status *ENROLL\_FAILED*.
4. The biometrics are searched in the local database and cache. If found, the transaction will have response *ENROLL\_ANOMALY* and PSBio will wait for the exception to be handled to complete the transaction. If the match occurs in the cache, an IDE packet is sent to update the other PSBios.
5. An IDE packet is sent to the other PSBios to synchronize caches and the status is changed to *ENROLL\_CACHE\_OK*. When the VRE responses are received, the status changes to *ENROLL\_OK* and the transaction is completed.

## Update

![Update Flow in PSBio](https://118801336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMy9gZsTdEehR3FxRxgN%2Fuploads%2Fgit-blob-a01b771a84c57edd82dc4cc5f056a1074615e18f%2Fpsbio1-Update.png?alt=media)

1. Upon receiving an update request (Update), PSBio returns an initial status of *UPDATE\_IN\_PROGRESS*.
2. The registration data are searched in the *Blacklist*. In case of a biometric match, the transaction is completed with the update refused and status *UPDATE\_ANOMALY\_BLACKLIST*.
3. The registration's IDN is queried in the local database and cache, and also on the other PSBios with an IDN\_Query call. If the IDN is not found, the transaction is completed with the update refused and status *UDPATE\_FAILED*.
4. It is checked which PSBio holds the original registration. If it is another PSBio, the update is refused with status *UPDATE\_REFUSED*.
5. If the registration belongs to this PSBio, the transaction continues to be processed: it is checked whether there is a pending exception for the original registration. If there is, the status is changed to *UPDATE\_REFUSED*, the update is refused and the transaction is completed.
6. A biometric verification is performed between the update biometric data and the original registration. If there is no match, the status is changed to *UPDATE\_ANOMALY*, and the transaction will remain pending until the exception is handled.
7. If it matches, it is checked whether there are new fingerprints. If there are none, the update is performed as a *TRUSTED\_ENROLL*, the status is changed to *UPDATE\_OK* and the transaction is completed.
8. If there are new fingerprints: they are searched in the *blacklist*. If found, the update is refused with status *UPDATE\_ANOMALY\_BLACKLIST* and the transaction is completed.
9. The new fingerprints are searched in the local database and cache. If they are not found, or are found with swapped positions (indices) of the same individual, the update is performed. An IDE packet is sent to the other PSBios (to update their caches). The status is temporarily changed to *CACHE\_OK*, depending on whether there are unavailable PSBios or not. The update is performed, the status changed to *UPDATE\_OK* and the transaction is completed.
10. If the new fingerprints are found in a different individual, the update is not performed, the status is changed to *UPDATE\_ANOMALY* and the transaction will remain pending until the exception is handled.

## Delete

![Delete Flow in PSBio](https://118801336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMy9gZsTdEehR3FxRxgN%2Fuploads%2Fgit-blob-5caaa98ba43cd7e316e87f5849db6416eb3d482e%2Fpsbio1-Delete.png?alt=media)

1. Upon receiving a removal request (Delete), PSBio checks whether the original registration belongs to this PSBio. If not, the removal is refused with status *DELETE\_NOT\_OK*.
2. If the registration belongs to this PSBio, the status is changed to *DELETE\_PENDING* and it is removed from the local database and the local cache.
3. PSBio notifies the removal to all other PSBios, which must remove the registration from the cache and revoke its validity. PSBio waits for the receipt confirmation from all the other PSBios. After receiving all confirmations, it changes the status to *DELETE\_OK* and finalizes the flow.
