Skip to content

Web SDK Architecture ​

How the eKYC Web SDK is organized internally: the module layout, the five architectural layers, and the classes that make up each one. Useful when extending the SDK or injecting custom views.

Module Layout ​

FieldTypeDescription
CakeEkycSDK.tsmoduleMain entry point, containing the CakeEkycSDK class.
common/directoryUtility classes and constants used across the SDK.
data/directoryData operations — HTTP requests and repository logic.
face/directoryFace scanning, verification and configuration.
nid/directoryNID scanning, verification and configuration.
pipeline/directoryProcessing workflow logic.
utils/directoryUtility functions.

Layers ​

1. Presentation Layer ​

The UI that the user interacts with — renders elements, captures input, displays feedback.

FieldTypeDescription
DefaultCakeFaceScanViewclassFace scanning UI.
DefaultCakeNIDScanViewclassNID scanning UI.
DefaultCakeNIDPreviewclassNID confirmation UI.
DefaultCakeLoadingViewclassLoading UI.

2. Business Logic Layer ​

FieldTypeDescription
CakeEkycSDKclassOrchestrates the flow and connects components.
DefaultCakeFaceScannerclassRuns a face scan.
CakeNIDScanTaskclassRuns an NID scan.
CakeFaceVerifyStepclassVerifies face images.
CakeNIDVerifyStepclassVerifies NID images.
FaceAssessorFactoryclassBuilds the composite face assessor.
NIDAssessorFactoryclassBuilds the composite NID assessor.

3. Data Access Layer ​

FieldTypeDescription
CakeKYCRepositoryinterfaceContract for all API calls.
DefaultCakeKYCRepositoryclassImplementation — handles every API call including image uploads.
HttpClientclassPerforms the HTTP requests.

4. Configuration Layer ​

FieldTypeDescription
SDKConfigParamstypeBase URL, token and resource path.
CakeLivenessConfigclassLocal checks, remote checks and schemas for liveness.
CakeNIDConfigclassLocal and remote checks for NID.
DefaultCakeConfigParsersclassParses configuration fetched from the server.

5. Model Layer ​

FieldTypeDescription
CESUploadRequest / CESUploadResponsetypeImage upload.
CESCardSanityRequest / CESCardSanityResponsetypeCard sanity.
CESCardTamperingRequest / CESCardTamperingResponsetypeCard tampering.
CESReadCardInfoRequest / CESReadCardInfoResponsetypeCard info extraction.
CESFaceSanityRequest / CESFaceSanityResponsetypeFace sanity.
CESFaceLivenessRequest / CESFaceLivenessResponsetypeFace liveness.
CESCompareFaceRequest / CESCompareFaceResponsetypeFace comparison.
CakeNIDCardSideenumFRONT or BACK.

Communication Flow ​

  1. The user interacts with the Presentation Layer.
  2. The Business Logic Layer processes those interactions.
  3. Where needed, it requests data from the Data Access Layer.
  4. The Data Access Layer calls the external service — for example uploading an image.
  5. Results flow back up through the layers to update the UI.

Image upload happens in the Data Access Layer: DefaultCakeKYCRepository.uploadImage() builds a FormData and posts it to the API endpoint.

CakeEkycSDK ​

The main interface.

FieldTypeDescription
containerHTMLElementDOM element where the SDK renders its UI.
faceConfigCakeLivenessConfigConfiguration for face operations.
nidConfigCakeNIDConfigConfiguration for NID operations.
sdkConfigSDKConfigParamsGeneral SDK configuration.
repositoryCakeKYCRepositoryHandles API calls and data operations.

Methods ​

FieldTypeDescription
initialize(container, sdkConfig)Promise<CakeEkycSDK>Initializes the SDK, fetching and parsing configuration from the server.
scanFace()CakeFaceScannerStarts a face scan using a face scan view and assessor.
scanNID(cardSide, elements?)CakeNIDScanner | nullStarts an NID scan for one side, using injected or default views and assessors.
verifyNID(input)CakeNIDVerifyStepVerifies the scanned NID.
verifyFaces(faceImages, isFaceAuth?)CakeFaceVerifyStepVerifies face images for liveness or authentication.
verifyPair(params)Promise<CESCompareFaceResponse>Compares two faces for similarity.
verifyFaceAuthentication(params)Promise<CESVerifyFaceAuthenticationResponse>Verifies face authentication server-side.

CakeKYCRepository ​

The data-access contract. Each method maps to a API endpoint.

FieldTypeDescription
config()Promise<HttpResponse<CESConfigResponse>>Fetches SDK configuration.
uploadImage(params)Promise<HttpResponse<CESUploadResponse>>Upload Image
checkCardSanity(params)Promise<HttpResponse<CESCardSanityResponse>>Verify ID Card Sanity
checkCardTampering(params)Promise<HttpResponse<CESCardTamperingResponse>>Detect ID Card Tampering
readIdCardInfo(params)Promise<HttpResponse<CESReadCardInfoResponse>>Read ID Card Info
checFaceSanity(params)Promise<HttpResponse<CESFaceSanityResponse>>Verify Face Sanity
checFaceLiveness(params)Promise<HttpResponse<CESFaceLivenessResponse>>Verify Face Liveness
compareFace(params)Promise<HttpResponse<CESCompareFaceResponse>>Compare Faces
verifyFaceAuthentication(params)Promise<HttpResponse<CESVerifyFaceAuthenticationResponse>>FaceAuthen verification.

INFO

checFaceSanity and checFaceLiveness are spelled without the second k in the SDK source. Use them as written — this is the actual method name, not a typo in this documentation.

Injecting Custom Views ​

scanNID accepts a CakeNIDScanInjectElements so you can replace the default UI.

FieldTypeDescription
scanViewCakeNIDScanViewImplements render, presentAccessingResult, startCamera, stopCamera.
assessorNIDAssessorImplements execute(input): NIDAssessingResult.
confirmationViewCakeNIDPreviewImplements show, hide, onConfirm, onRetry.

The same pattern applies to face scanning via CakeFaceScanView and FaceAssessor.

Next Steps ​

Developers