sequenceDiagram
participant Citizen as 👤 Citizen
participant Frontend as 🌐 Frontend
Next.js
participant API as 📡 NestJS API
participant DB as 🗄️ PostgreSQL
participant MinIO as 📦 MinIO
participant Blockchain as ⛓️ Besu
Smart Contracts
participant Dept1 as 🏢 Dept 1
Approver
participant Dept2 as 🏢 Dept 2
Approver
participant Webhook as 🔔 Webhook
rect rgb(31, 41, 55)
note over Citizen,API: 1. License Request Submission
Citizen->>Frontend: Create Resort License
Request & Upload
Documents
Frontend->>API: POST /licenses/create
Form Data + Files
API->>DB: Create license_request
status: DRAFT
end
rect rgb(59, 130, 246)
note over API,MinIO: 2. Document Upload & Hashing
API->>MinIO: Upload Documents
(PDF, Images, etc.)
MinIO-->>API: Document URLs
API->>API: Generate SHA-256
Hash of Files
API->>DB: Store document_metadata
with content_hash
end
rect rgb(168, 85, 247)
note over API,Blockchain: 3. Blockchain Recording
API->>Blockchain: Call DocumentRegistrar
recordDocumentHash()
params: licenseHash,
department, timestamp
Blockchain->>Blockchain: Emit DocumentHashRecorded
event
Blockchain->>DB: Store blockchain
tx_hash in license_request
API-->>Frontend: Request Submitted
Frontend-->>Citizen: Confirmation + Request ID
end
rect rgb(20, 184, 166)
note over DB,DB: 4. Update to SUBMITTED State
API->>DB: Update license_request
status: SUBMITTED
API->>DB: Create audit_log entry
end
rect rgb(59, 130, 246)
note over API,Dept1: 5. Route to Department 1
API->>API: Resolve workflow for
Resort License POC
API->>DB: Create approval_request
status: PENDING
department: Tourism
API->>Webhook: Send notification
Webhook->>Dept1: Email: License
Ready for Review
end
rect rgb(139, 92, 246)
note over API,Dept2: 6. Route to Department 2 (Parallel)
par Department 2 Review
API->>DB: Create approval_request
status: PENDING
department: Fire Safety
API->>Webhook: Send notification
Webhook->>Dept2: Email: License
Ready for Review
end
end
rect rgb(34, 197, 94)
note over Dept1,Blockchain: 7. Department 1 Approval
Dept1->>Frontend: Review Documents
& Attachments
Dept1->>API: POST /approvals/approve
approval_id, comments
API->>DB: Update approval_request
status: APPROVED
reviewed_by, timestamp
API->>Blockchain: Call ApprovalManager
recordApproval()
params: licenseHash,
department, signature
Blockchain->>Blockchain: Emit ApprovalRecorded
end
rect rgb(34, 197, 94)
note over Dept2,Blockchain: 8. Department 2 Approval (Parallel)
par Department 2 Review
Dept2->>Frontend: Review Documents
Dept2->>API: POST /approvals/approve
API->>DB: Update approval_request
status: APPROVED
API->>Blockchain: recordApproval()
Blockchain->>Blockchain: Emit ApprovalRecorded
end
end
rect rgb(236, 72, 153)
note over API,Blockchain: 9. Final Approval Processing
API->>API: Check all approvals
complete
API->>Blockchain: Call LicenseRequestNFT
mint()
params: applicant,
licenseURI, metadata
Blockchain->>Blockchain: Mint ERC-721
Soulbound NFT
Blockchain->>Blockchain: Emit Transfer event
end
rect rgb(20, 184, 166)
note over DB,Frontend: 10. Update Final State
API->>DB: Update license_request
status: APPROVED
nft_token_id
API->>DB: Create audit_log
entry: APPROVED
API->>Webhook: Send notification
Webhook->>Citizen: Email: License
Approved!
API-->>Frontend: License Approved
Frontend-->>Citizen: Display NFT &
Certificate
end
rect rgb(96, 125, 139)
note over Citizen,Frontend: 11. License Verification
Citizen->>Frontend: Download License
Certificate
Frontend->>API: GET /licenses/{id}
/verify
API->>Blockchain: query getLicenseNFT()
tokenId
Blockchain-->>API: NFT metadata,
owner, issuer
API-->>Frontend: Verified ✓
Frontend-->>Citizen: Display Verified
License Certificate
end