# MI EKYC Message Documents
MI EKYC Mícroservice Architecture:

MI EKYC Process Flow:

*Caco Design Document* [here](https://cacoo.com/diagrams/ReT3NTxOwM0gI6OJ/8B026)
## Web Service
- Producer Output Kafka TOPIC: MTCNN_REQUEST
- Consumer Input : INSIGHTFACE_REPLY
- Socket IO Room: EKYC_SEVER_ROOM
EKYC_SEVER_ROOM message example:
```
message 1:
message = {"request_id"= "67460e74-02e3-11e8-b443-00163e990bdb"
"request_api_type": "compare_face",
"status":0
"rate":0.7
}
message 2:
message ={"request_id"= "67460e74-02e3-11e8-b443-00163e990bdb"
"request_api_type": "register_license",
"status":1
}
message 3:
message ={"request_id"= "67460e74-02e3-11e8-b443-00163e990bdb"
"request_api_type": "register_license",
"status":0
}
```
- output message example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "compare_face",
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "register_license",
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "register_face",
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
```
- input message to INSIGHTFACE_REQUEST example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "compare_face",
"idface_feature": base64_encode_image(idface_feature),
"face_feature": base64_encode_image(face_feature)
}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"face_feature": base64_encode_image(face_feature)
}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"idface_feature": base64_encode_image(idface_feature)
}
message error 1 :
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"idface_feature": null
}
message error 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"face_feature": null
}
message error 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"idface_feature": null
"face_feature": null
}
```
## MTCNN Service
- Input Kafka TOPIC: MTCNN_REQUEST
- Output Kafka TOPIC:
+ INSIGHTFACE_REPLY
+ INSIGHTFACE_REQUEST
- input message example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "compare_face",
"client_id": 124,
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "register_license",
"client_id": 124,
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = {"request_api_type": "register_face",
"client_id": 124,
"image_shape":(948, 1616, 3)
"image": base64_encode_image(image)}
```
- output message to INSIGHTFACE_REQUEST example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "compare_face",
"client_id": 124,
"idface": base64_encode_image(aligned_idface),
"face": base64_encode_image(aligned_face)
}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
"face": base64_encode_image(aligned_face)
}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"client_id": 124,
"idface": base64_encode_image(aligned_idface)
}
```
- output message to INSIGHTFACE_REPLY example:
```
message 1 :
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"client_id": 124,
}
message 2 :
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
}
message 3 :
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "compare_face",
"client_id": 124,
}
```
## Insightface Service
- Input Kafka TOPIC: INSIGHTFACE_REQUEST
- Output Kafka TOPIC: INSIGHTFACE_REPLY
- input message example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "compare_face",
"client_id": 124,
"idface": base64_encode_image(aligned_idface),
"face": base64_encode_image(aligned_face)
}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
"face": base64_encode_image(aligned_face)
}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"client_id": 124,
"idface": base64_encode_image(aligned_idface)
}
```
- output message example:
```
message 1:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "compare_face",
"client_id": 124,
"idface_feature": base64_encode_image(idface_feature),
"face_feature": base64_encode_image(face_feature)
}
message 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
"face_feature": base64_encode_image(face_feature)
}
message 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"client_id": 124,
"idface_feature": base64_encode_image(idface_feature)
}
message error 1 :
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_license",
"client_id": 124,
"idface_feature": null
}
message error 2:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
"face_feature": null
}
message error 3:
key = b"67460e74-02e3-11e8-b443-00163e990bdb"
value = { "request_api_type": "register_face",
"client_id": 124,
"idface_feature": null
"face_feature": null
}
```