# E2E User Flow

#### Phase 1: Frontend DID Selection

1. The user selects the type of verification they want to perform (e.g., "18+ Age Verification") from the dApp's UI.
2. The frontend calls the `get_did_type_info` function to fetch details about the selected DID, such as its name, description, and required documents.

#### Phase 2: Start Verification On-Chain

3. The user clicks "Start Verification," which triggers a transaction calling the `start_verification` function. This creates a new `UserDID` object on-chain with the status set to `PENDING`.

#### Phase 3: Document Submission & Off-Chain Verification

4. The user is prompted to submit the required documents (e.g., Aadhar QR code, face capture) to a secure backend.
5. A Python backend processes these documents to verify their authenticity.
6. Upon completion, the backend updates its internal database and pushes a result message to a Kafka queue.
   * Kafka Message Example:

     JSON

     ```
     {
       "user_address": "0x123...",
       "did_type": 1,
       "verification_result": true,
       "user_did_id": "0xabc..."
     }
     ```

#### Phase 4: Rust Backend Updates Contract

7. A Rust service consumes the message from the Kafka queue and calls the `update_verification_status` function on the `Simple DID Registry` contract, updating the `UserDID` object's status to `VERIFIED` or `REJECTED`.

#### Phase 5: SSE Update to Frontend

8. The backend sends a Server-Sent Event (SSE) to the user's frontend to notify them that the verification is complete.
9. The UI updates to show a new "Upload Documents" button.

#### Phase 6: Encrypted Document Upload & NFT Claim

10. The user uploads their sensitive documents. These are encrypted on the client side using Seal and uploaded to decentralized storage (Walrus).
11. The frontend calls the `register_user_document` function on the `Government Whitelist` contract to log the `encryptionId` and `blobId`.
12. Finally, the user signs a transaction to call the `claim_did_nft` function. This mints their Soul-Bound NFT, which serves as their official on-chain credential, and marks the `UserDID` object as claimed.
