0% found this document useful (0 votes)
1 views11 pages

ERD & API Specification

The document outlines API specifications for three services: NDC for identity verification, CMS for criminal history checks, and CIC for credit score assessments, detailing endpoints, request and response formats. It also includes an entity-relationship diagram (ERD) and suggested database tables for managing customer data, verification records, and loan information. Each API specifies required fields, expected responses, and possible HTTP status codes for error handling.

Uploaded by

huythn.work
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views11 pages

ERD & API Specification

The document outlines API specifications for three services: NDC for identity verification, CMS for criminal history checks, and CIC for credit score assessments, detailing endpoints, request and response formats. It also includes an entity-relationship diagram (ERD) and suggested database tables for managing customer data, verification records, and loan information. Each API specifies required fields, expected responses, and possible HTTP status codes for error handling.

Uploaded by

huythn.work
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

3.

ERD & API Specs


3.1. API Specs
3.1.1. NDC (National Data Center) API:
Endpoint: /api/ndc/verify-identity Method: POST Header:

Header Value Description

Content-Type application/json Request uses JSON format

Authorization Bearer <token> Authorization API access

Request Body Fields:

Field Type Description

national_id string National Identity ID; required,


12/0 digits

Example Request:
json
{
"national_id": "012345678912"
}
Response Fields:

Field Type Description


nationality_id string Residential National
Identity ID

full_name string Residential full name

Date of birth, format


date_of_birth string
YYYY-MM-DD

age integer System-calculated age

address array List Residential address

“true” if resident in
is_resident_vietnam boolean
Vietnam

HTTP status code


message string
message

Example Success Response (Code 200):


json
{
"nationality_id": "012345678912",
"full_name": "nguyen van a",
"date_of_birth": "2001-04-03",
"age": 24,
"address": ["123 Le Loi, Ho Chi Minh City, Vietnam"],
"is_resident_vietnam": true,
"message": “Success”
}
HTTP Status Code message:

HTTP
Message
Status code

200 Success

400 Bad Request: Invalid request data

401 INVALID_AUTHORIZATION
500 Internal Server Error: Unexpected error in processing the request

3.1.2. CMS (Crime Management System) API:


Endpoint: /api/cms/check-criminal-history Method: POST Header:

Header Value Description

Content-Type application/json Request uses JSON format

Authorization Bearer <token> Basic Authorization

Request Body Fields:

Field Type Description

National Identity ID; required,


national_id string
12/0 digits

Example Request: json


{
"national_id": "012345678912"
}
Response Fields:

Field Type Description

Residential National
nationality_id string
Identity ID

has_criminal_record boolean True if user has any


criminal history, otherwise
false

criminal_records array List of criminal records


(empty array if none)

message string HTTP status code


message

Example Success Response (Code 200):


json
{
"nationality_id": "012345678912",
"has_criminal_record": false,
"criminal_records": [],
"message": "Success"
}

HTTP Status Code message:

HTTP
Message
Status code

200 Success

400 Bad Request: Invalid request data

401 INVALID_AUTHORIZATION

500 Internal Server Error: Unexpected error in processing the request

3.1.3. CIC (Credit Information Center) API:


Endpoint: /api/cic/check-credit-score Method: POST Header:

Header Value Description

Content-Type application/json Request uses JSON format

Authorization Bearer <token> Basic Authorization


Request Body Fields:

Field Type Description

National Identity ID; required,


national_id string
12/0 digits

Example Request: json


{
"national_id": "012345678912"
}
Response Fields:

Field Type Description

Residential National Identity


nationality_id string
ID

credit_score integer User's credit score

Error message (null if


error_message string
successful)

Example Success Response (Code 200):


json
{
"nationality_id": "012345678912",
"credit_score": 650,
"message": “Success”
}

HTTP Status Code message:

HTTP
Message
Status code
200 Success

400 Bad Request: Invalid request data

401 INVALID_AUTHORIZATION

500 Internal Server Error: Unexpected error in processing the request

3.2. ERD & Database table


3.2.1. ERD diagram

3.2.2. Suggest Database table


Customer Table:
Primary Foreig
Field Name Type Description
Key n Key

id integer x Primary Key, unique


customer ID

full_name string Customer's full legal


name

date_of_birt
date Date of birth
h

national_id string National Identity ID

address string Residential address

created_at datetime datetime record created

updated_at datetime datetime record updated

NationalIDVerification Table:

Primary Foreig
Field Name Type Description
Key n Key

id integer x Primary Key, unique


verification record

customer_id integer x Foreign Key to


Customer(id)

age integer Calculated age at


time of check

is_vietnam_resi boolean Residency status


d ent from NDC

created_at datetime datetime record


created
updated_at datetime datetime record
updated

CriminalCheck Table:

Field Name Type Primary Foreign Description


Key Key

id integer x Primary Key, unique


verification record

customer_id integer x Foreign Key to


Customer(id)

has_criminal_re boolean True if customer has a


cord criminal record

created_at datetim datetime record


e created

updated_at datetim datetime record


e updated

CreditScoreCheck Table:

Primar Foreign
Field Name Type Description
y Key Key

id integer x Primary Key, unique


verification record

customer_id integer x Foreign Key to


Customer(id)

credit_score integer Credit score value from


CIC

created_at datetime datetime record created


updated_at datetime datetime record updated

Loan Table:

Field Name Type Primary Foreig Description


Key n Key

id integer x Primary Key, unique


verification record

customer_id integer x Foreign Key to


Customer(id)

loan_status string Loan request status


(pending, approved,
etc.)

eligible_nationa boolean Nationality ID eligible


l ityid status (if true when all
conditions are pass)

criminal_record array List of criminal


s records (empty array
if none)

created_at datetime datetime record


created

updated_at datetime datetime record


updated

3.2.2. Table Relationship

Relationship Type Description

Customer — 1:N Customer can have multiple NDC


NationalIDVerification record request

Customer — 1:N Customer can have multiple Criminal


CriminalCheck record request

Customer — 1:N Customer can have multiple CIC


CreditScoreCheck request

Customer — Loan 1:N Customer can have multiple loan

You might also like