title onboarding

participant "customer" as cs
participant "admin" as a
participant "frontend" as fe
participant "backend" as be
database "database" as db
participant "s3" as s3
participant  "appman" as am
participant  "DAP" as dp

group client onbaording
 group PAGE:{URL}/authentication/signup/type
cs -> fe: click select invester type
fe-->cs:
end
group PAGE:{URL}:/authentication/signup/addindividualaccount
 cs->fe: filled customer infomation
cs->fe:Cilck next form
fe->be: [POST]/api/v1/individual/ico/precreate
be->be: check dulipcate email mobile citizenID
be->be: create registerID
be<->db:save
be-->fe: registerID
fe->be: init appman
be<->am: init appman
be-->fe: appman url
fe-->cs: redirect to appman
end

group APPMAN Service
cs->am: ID Card liveness ocr
am-->fe: 
fe-->cs: redirect 
end

group PAGE {URL}:/authentication/signup/backCardwebcaminstructions
fe->be: [POST]/api/v1/appman/result
be<->am: Get IDCard liveness ocr result
be<->db: save
be<->appman: check pep
be<->dp: check dopa
be<->dp: check amlo
be<->dp: check led
be<->db : save
be-->fe : registerID

cs->fe : upload backID Card
fe->be:[POST]/upload/onboarding
be<->db:save
be<->s3:upload
be-->fe:
fe-->cs:redirect
end


group PAGE{URL}:/authentication/signup/basicinfo
cs->fe: filled address occupation banks
cs->fe:Cilck next form
fe->be:[POST]/api/v1/individual/ico/postcreate
be->be:create risk score
be<->db:save
be-->fe:
fe-->cs:redirect
end
group PAGE{URL}:/authentication/signup/suittestfatca
cs->fe:filled suitetest fatca
cs->fe:Cilck next form
fe->be: [POST]/api/v1/suitetest/ico/result/individual/save
be<->db:save
be -->fe:
fe-->cs: redirect
end
group PAGE{URL}:/authentication/signup/otpemailconfirm
cs->fe: verify otp
fe->be:[POST]/api/v1/user/verify/mobile
be<->db:save
be<->resend: send OTP
be-->fe:
fe-->cs:
resend-->cs: OTP
cs->fe: filed OTP
cs -> fe: confirm
fe->be:[POST]/api/v1/user/verify/mobile/check
be<->db: get
be->be: check otp
be-->fe:
fe-->cs:
cs-> fe: verify email 
fe->be: [POST]/api/v1/user/verify/email
be<->db: save
be<->email:
email-->cs: send email
be-->fe:
fe-->cs:[URL]/authentication/signup/emailconfirmsucess
end

group Confrim email
cs->email: confirm email
email-->fe: 
fe->be: [POST]/api/v1/user/verify/email/check
be-->fe:
fe-->cs:[URL]/authentication/signup/identityverification
end
group ThaiD :{URL}/authentication/signup/identityverification
cs->fe: Cilck Select THAID
fe-->cs:
cs->fe:click do thaiD
fe->be:[POST]/api/v1/thaid/initial
be<->db:save
be->fe: dap url
fe-->cs: redirect to dap\n
cs->thaiD : verify
dp<->thaiD:
dp ->be: user data
be<->db:save
be->dp:
dp-->fe: \n
fe-->cs:[URL]/authentication/thaid/success

dp-->thaiD:


end 
end

group Admin

  group maker
a->fe: [URL]/create-job/change-individual-account/view
fe->be:[POST]/api/v1/individual/list
be<->db: get data
be-->fe:
fe-->a:
a->fe: bank verify
fe->be: upload [POST]/api/v1/admin/upload/onboarding
be<->db:save
be<->s3: upload
be-->fe:
a->fe: Select approve/reject/blacklist
fe->be:[POST]/api/v1/individual/approveocr
be<->db:update status
be-->fe:
fe-->a:
  end
alt maker Approved
  group checker
    a->fe:[URL]/todo-list/individual-account-opening
fe->be:[POST]/api/v1/individual/list/pending
be<->db: get
be-->fe:
fe-->a:
a->fe: approve/reject
fe->be:[POST]/api/v1/user/individual/approve
be<->db: update status
alt approve And risk score is medium

be->be: create account
be<->db:create
be<->email:send email
email-->cs: account/password

end
be-->fe:
fe-->a:
end
group Approver

 a->fe:[URL]/todo-list/individual-account-opening
fe->be:[POST]/api/v1/individual/list/pending
be<->db: get
be-->fe:
fe-->a:
a->fe: approve/reject
fe->be:[POST]/api/v1/user/individual/approve
be<->db: update status
alt approve
  be->be: create account
be<->db:create
be<->email:send email
email-->cs: account/password
end
be-->fe:
fe-->a:
end
end
end
