Credential Flow
Understanding the complete lifecycle of a psychometric credential in PsicoStacks.
Complete Flow Diagram
┌──────────────┐ │ Candidate │ │ Uploads PDF │ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Backend │ │ Extracts Text│ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Mistral AI │ │ Analyzes │ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Frontend │ │Shows Summary │ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Mint on │ │ Stacks │ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Store in DB │ │ (Encrypted) │ └──────┬───────┘ │ ▼ ┌──────────────┐ │ Credential │ │ Ready │ └──────────────┘
Phase 1: Creation
1. Upload & Extract
Candidate uploads a psychometric assessment PDF. Backend extracts text using pdf-parse library.
POST /api/ai-interpret
2. AI Analysis
Mistral AI processes the text and generates a structured analysis with band rating (A/B/C) and key insights.
- Extracts scores and percentiles
- Identifies strengths and areas for development
- Assigns overall performance band
3. Review Summary
Frontend displays AI summary to candidate for review. Candidate can approve or try again with a different file.
4. Blockchain Minting
Smart contract creates SBT with metadata:
(mint-credential recipient schema commit ttl)
Gas fee: ~0.5 STX
5. Encrypted Storage
Full report is encrypted (AES-256-GCM) and stored in Supabase. Only commitment hash goes on-chain.
Phase 2: Sharing
1. Generate Share Token
Candidate requests a shareable link from their credentials dashboard.
POST /api/credentials/share
Token valid for: 2 hours
2. QR Code Generation
Frontend generates QR code containing the verification URL. Can be shared via email, messaging, or scanning.
3. Unlimited Sharing
Candidate can generate as many share links as needed. Each employer gets their own unique verification flow.
Phase 3: Verification
1. Preview (Free)
Employer opens link and sees credential preview without payment.
- Band rating (A/B/C)
- Key performance indicators
- Blockchain verification status
2. Payment
Employer pays 10 STX verification fee via smart contract:
(verify-paid credential-id)
Fee goes to credential owner
3. View Token Generation
After payment confirmation, backend generates a one-time view token.
POST /api/verify/pay
Valid for: 60 seconds, one-time use
4. Full Report Access
Employer accesses decrypted full report via view token.
GET /api/verify/view?token=view_xxx
5. Token Expiration
After 60 seconds or one use, token expires. Employer redirected to expiry page if they try to access again.
Phase 4: Management
Revocation
Candidate can revoke credential at any time via smart contract:
(revoke credential-id)
All future verification attempts will fail
Expiration
Credentials automatically expire after the TTL period (~1 year = 52,560 blocks). Smart contract checks block height on verification.