WP-01 API spec
The module is in afia-api. Contract types: contracts.md. Wire: exchange/identity.md.
Usage
IdentityService.requestOtp(phone) starts a challenge. verifyOtp(phone, code) returns Session. me(session) returns Account. Deletion uses the same Account row. Phone or email identifies the account.
Domain
Accountathealth.afia.app.identity.Account. ContractAccount.Roleathealth.afia.app.identity.Role. ContractRole.Sessionathealth.afia.app.identity.Session. ContractSession.Consentathealth.afia.app.identity.Consent. ContractConsent.
Persistence
AccountEntity table account. One row per login. Admin does not create a second user table. ConsentEntity table consent when consent lands. Session storage is an implementation choice inside this package. Do not expose it on HTTP.
HTTP DTOs
OtpRequestDtoinbound. Fieldphone.OtpVerifyDtoinbound. Fieldsphone,code.AccountResponseDtooutbound. Same fields as contractAccount.DeleteAccountDtoinbound.phoneoremail.
JSON lives in the exchange file. Validate on these DTOs.
Mappers
AccountMapper.toResponse(Account) -> AccountResponseDto
AccountMapper.toDomain(AccountEntity) -> Account
ConsentMapper.toDomain(ConsentEntity) -> Consent
Hand-written. No MapStruct.
Services
IdentityService
requestOtp(phone) -> void
verifyOtp(phone, code) -> Session
me(session) -> Account
deleteAccount(session, phoneOrEmail) -> void
recordConsent(session, purpose) -> Consent
OTP sketch unless a later ADR replaces it.
Controllers
AuthControlleron reserved/api/v1/afia/auth.POSTrequest and verify.MeControlleron reserved/api/v1/afia/me.GETcurrent account. Deletion on the same prefix.
Use EndpointUri constants that WP-00 reserved.
Does not do
Patient, clinician, diagnostics, or admin packages. A second user table. Flutter types. Invented login screens. Spring Security unless an ADR picks it.