# RateRight Worker Onboarding Pack - Technical Specification

## Executive Summary

The Worker Onboarding Pack is a hybrid template system that allows construction workers to create a portable, branded professional profile that can be shared with any contractor. The system uses a "hybrid template" approach where basic information is pre-filled and stored on our servers, while sensitive data (TFN, bank details, superannuation) is filled by the worker locally on their device and never transmitted to our servers.

## Feature Overview

### Core Concept
- **Portable Professional Profile**: Workers create a branded PDF that represents their professional credentials
- **Hybrid Template Approach**: Combines server-stored basic info with client-side sensitive data
- **Universal Shareability**: Can be shared with any contractor, not just those on RateRight platform
- **Brand Awareness**: Each PDF includes RateRight branding and QR code for platform discovery

### Key Features
1. Pre-filled template with basic worker information (name, phone, trade, ABN)
2. Client-side completion of sensitive fields (TFN, bank details, superannuation)
3. Professional PDF generation with RateRight branding
4. QR code generation linking to rateright.com.au
5. Document upload for certifications (white card, tickets)
6. Offline-first approach for sensitive data handling

## Technical Requirements

### Frontend Requirements
- Profile completion flow with multi-step form
- Document upload interface with preview
- Client-side PDF generation capability
- Responsive design for mobile devices
- Offline form completion for sensitive data

### Backend Requirements
- API endpoints for profile management
- Document storage service
- PDF template rendering
- QR code generation service
- Analytics tracking

### Security Requirements
- Zero storage of sensitive financial/tax data
- Encrypted document storage
- Secure file upload validation
- Privacy-compliant data handling

## Database Schema

### Profiles Table
```sql
CREATE TABLE worker_profiles (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
  
  -- Basic Information (stored on server)
  first_name VARCHAR(100) NOT NULL,
  last_name VARCHAR(100) NOT NULL,
  email VARCHAR(255) UNIQUE,
  phone VARCHAR(20),
  abn VARCHAR(14),
  
  -- Trade Information
  primary_trade VARCHAR(100),
  experience_years INTEGER,
  license_number VARCHAR(50),
  license_state VARCHAR(3),
  license_expiry DATE,
  
  -- Address Information
  address_line1 VARCHAR(255),
  address_line2 VARCHAR(255),
  suburb VARCHAR(100),
  state VARCHAR(3),
  postcode VARCHAR(4),
  
  -- Profile Status
  profile_completion_percentage INTEGER DEFAULT 0,
  onboarding_pack_generated BOOLEAN DEFAULT FALSE,
  last_generated_at TIMESTAMP WITH TIME ZONE,
  
  -- Metadata
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  
  -- Constraints
  CONSTRAINT valid_completion_percentage CHECK (profile_completion_percentage BETWEEN 0 AND 100)
);

CREATE INDEX idx_worker_profiles_user_id ON worker_profiles(user_id);
CREATE INDEX idx_worker_profiles_email ON worker_profiles(email);
```

### Documents Table
```sql
CREATE TABLE worker_documents (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  worker_profile_id UUID REFERENCES worker_profiles(id) ON DELETE CASCADE,
  
  -- Document Information
  document_type VARCHAR(50) NOT NULL, -- 'white_card', 'license', 'ticket', 'other'
  document_name VARCHAR(255) NOT NULL,
  file_path VARCHAR(500) NOT NULL,
  file_size INTEGER,
  mime_type VARCHAR(100),
  
  -- Document Metadata
  expiry_date DATE,
  document_number VARCHAR(100),
  issuing_authority VARCHAR(255),
  
  -- Verification
  verified BOOLEAN DEFAULT FALSE,
  verified_at TIMESTAMP WITH TIME ZONE,
  
  -- Metadata
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  
  -- Constraints
  CONSTRAINT valid_document_type CHECK (document_type IN ('white_card', 'license', 'ticket', 'other'))
);

CREATE INDEX idx_worker_documents_profile_id ON worker_documents(worker_profile_id);
CREATE INDEX idx_worker_documents_type ON worker_documents(document_type);
```

### Onboarding Pack Analytics Table
```sql
CREATE TABLE onboarding_pack_analytics (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  worker_profile_id UUID REFERENCES worker_profiles(id) ON DELETE CASCADE,
  
  -- Generation Tracking
  generated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  generation_method VARCHAR(50), -- 'web', 'mobile', 'api'
  
  -- Usage Tracking
  download_count INTEGER DEFAULT 0,
  last_downloaded_at TIMESTAMP WITH TIME ZONE,
  
  -- QR Code Tracking
  qr_scans INTEGER DEFAULT 0,
  last_qr_scan_at TIMESTAMP WITH TIME ZONE,
  
  -- Metadata
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

CREATE INDEX idx_analytics_profile_id ON onboarding_pack_analytics(worker_profile_id);
```

## User Flow

### 1. Worker Signup
- User creates account with basic information
- Email verification required
- Profile creation initiated

### 2. Profile Completion
- Multi-step form process:
  - Step 1: Personal Details (name, phone, address)
  - Step 2: Trade Information (trade, experience, license)
  - Step 3: Business Details (ABN, business info)
  - Step 4: Document Upload (white card, licenses, tickets)
  - Step 5: Review & Confirm

### 3. Onboarding Pack Generation
- Worker navigates to "Create Onboarding Pack"
- System displays pre-filled template
- Worker fills sensitive fields locally (TFN, bank, super)
- PDF generated with all information
- No sensitive data transmitted to server

### 4. Download & Save
- PDF available for immediate download
- Option to email to self
- Mobile-optimized for easy saving
- Suggested filename: `[Name] - Onboarding Pack - [Date].pdf`

### 5. Sharing with Contractors
- Worker can share PDF via any method (email, text, print)
- QR code on PDF links to RateRight website
- Contractors can scan QR to learn about RateRight

## Design Requirements

### PDF Template Structure
```
┌─────────────────────────────────────────────────────────────┐
│                    WORKER ONBOARDING PACK                   │
│                    [Worker Name]                           │
├─────────────────────────────────────────────────────────────┤
│ 1. PERSONAL INFORMATION                                     │
│    Name: [First Last]                                      │
│    Phone: [Phone Number]                                   │
│    Email: [Email Address]                                  │
│    Address: [Full Address]                                 │
│                                                            │
│ 2. TRADE DETAILS                                            │
│    Primary Trade: [Trade]                                  │
│    Experience: [X] years                                   │
│    License: [Number] ([State]) - Exp: [Date]              │
│    ABN: [Australian Business Number]                       │
│                                                            │
│ 3. DOCUMENTS                                               │
│    ✓ White Card - Exp: [Date]                             │
│    ✓ [Other Certificates]                                  │
│                                                            │
│ 4. PAYMENT INFORMATION (To be completed by worker)         │
│    Tax File Number: ___________________                    │
│    Bank Details: _____________________                     │
│    Superannuation: ___________________                     │
│                                                            │
│ 5. EMERGENCY CONTACT                                       │
│    Name: ____________________________                      │
│    Phone: ___________________________                      │
│    Relationship: _____________________                     │
│                                                            │
│                                                            │
│ ─────────────────────────────────────────────────────────── │
│  This worker profile was generated using RateRight         │
│  Visit: rateright.com.au                                   │
│  [QR CODE]                                                 │
└─────────────────────────────────────────────────────────────┘
```

### Branding Requirements
- Professional, construction-industry appropriate design
- RateRight logo in footer
- QR code linking to rateright.com.au
- Clean, readable layout optimized for printing
- Subtle color scheme (grays/blues)

### Technical Specifications
- PDF Format: A4 size, portrait orientation
- File size: <2MB with documents
- Resolution: 300 DPI for print quality
- Accessibility: Tagged PDF for screen readers

## API Endpoints

### Profile Management
```
GET    /api/worker/profile
       - Retrieve worker profile
       - Returns: Profile data with completion percentage

PUT    /api/worker/profile
       - Update worker profile
       - Body: Profile fields to update
       - Returns: Updated profile

POST   /api/worker/profile/complete
       - Mark profile as complete
       - Returns: Completion status
```

### Document Management
```
GET    /api/worker/documents
       - List all documents
       - Returns: Array of document metadata

POST   /api/worker/documents
       - Upload new document
       - Body: Multipart form data
       - Returns: Document metadata

DELETE /api/worker/documents/:id
       - Delete specific document
       - Returns: Deletion confirmation

GET    /api/worker/documents/:id/download
       - Download document file
       - Returns: File stream
```

### Onboarding Pack
```
POST   /api/worker/onboarding-pack/generate
       - Generate onboarding pack PDF
       - Body: { includeSensitiveData: false }
       - Returns: { templateId, downloadUrl }

GET    /api/worker/onboarding-pack/template/:id
       - Get template with pre-filled data
       - Returns: Template data (no sensitive info)

POST   /api/worker/onboarding-pack/complete
       - Submit completed PDF (client-side generation)
       - Body: { generatedPdf: base64 }
       - Returns: Success confirmation

GET    /api/worker/onboarding-pack/download/:id
       - Download generated PDF
       - Returns: PDF file
```

### Analytics
```
POST   /api/analytics/onboarding-pack/scan
       - Track QR code scan
       - Body: { packId, location? }
       - Returns: Success

GET    /api/analytics/onboarding-pack/stats
       - Get generation statistics
       - Returns: Analytics data
```

## Security & Compliance

### Data Storage Policy
**We Store:**
- Basic personal information (name, phone, email, address)
- Trade information and qualifications
- Business information (ABN)
- Document images (white cards, licenses, tickets)
- Profile completion metrics

**We NEVER Store:**
- Tax File Numbers (TFN)
- Bank account details
- Superannuation fund information
- Emergency contact information (optional field)

### Privacy Compliance
- Clear privacy policy explaining data usage
- User consent for data storage
- Right to deletion (GDPR compliance)
- Data portability options
- Regular data retention audits

### Document Security
- Files stored with encryption at rest
- Secure upload validation (file type, size, content)
- Access control for document downloads
- Automatic virus scanning on upload
- Document expiry tracking

### Client-Side Security
- Sensitive data fields use local storage only
- PDF generation happens in browser
- No transmission of sensitive data to server
- Clear instructions for worker data protection

## Implementation Phases

### Phase 1: MVP (4 weeks)
**Core Features:**
- Basic profile creation and management
- Simple PDF template with branding
- Client-side sensitive data handling
- Basic document upload

**Technical:**
- Profile API endpoints
- Simple PDF generation (jsPDF)
- Document storage service
- Basic analytics

**Success Criteria:**
- 100 worker profiles created
- 50 onboarding packs generated
- 5% QR code scan rate

### Phase 2: Enhanced Features (3 weeks)
**Additional Features:**
- Advanced PDF template with better design
- Document expiry notifications
- QR code analytics dashboard
- Mobile-optimized generation

**Technical:**
- Advanced PDF generation (PDFKit)
- Notification service
- Analytics dashboard
- Mobile app integration

**Success Criteria:**
- 500 worker profiles
- 200 onboarding packs generated
- 10% QR code scan rate
- 4.5/5 user satisfaction

### Phase 3: Scale & Optimize (2 weeks)
**Optimization:**
- Performance improvements
- Advanced analytics
- A/B testing framework
- Integration with contractor platform

**Technical:**
- CDN for document storage
- Advanced caching
- Real-time analytics
- API rate limiting

**Success Criteria:**
- 1000+ worker profiles
- 500+ onboarding packs
- 15% QR code scan rate
- 99.9% uptime

## Success Metrics

### Primary KPIs
1. **Worker Profile Completion Rate**
   - Target: 70% of registered workers complete profile
   - Measurement: Daily active profiles / Total registrations

2. **Onboarding Pack Generation Rate**
   - Target: 50% of completed profiles generate pack
   - Measurement: Packs generated / Completed profiles

3. **QR Code Engagement**
   - Target: 10% scan rate within 30 days
   - Measurement: Unique scans / Packs generated

### Secondary Metrics
- Average time to complete profile
- Document upload completion rate
- PDF download success rate
- User satisfaction score (survey)
- Contractor sign-ups from QR scans

### Branding Effectiveness
- QR code scan locations
- Contractor platform registrations
- Brand recall surveys
- Social media mentions

## Technical Architecture

### Frontend Stack
- Framework: React/Next.js
- State Management: Redux Toolkit
- PDF Generation: jsPDF + html2canvas
- File Upload: React Dropzone
- QR Code: qrcode.js

### Backend Stack
- Runtime: Node.js/Express
- Database: PostgreSQL (Supabase)
- File Storage: AWS S3
- PDF Service: PDFKit
- Analytics: Mixpanel/PostHog

### Infrastructure
- Hosting: Railway/Fly.io
- CDN: CloudFront
- Monitoring: Sentry
- CI/CD: GitHub Actions

## Risk Assessment

### Technical Risks
1. **PDF Generation Performance**
   - Mitigation: Implement server-side generation fallback
   
2. **Document Storage Costs**
   - Mitigation: Compression, retention policies
   
3. **Mobile Browser Compatibility**
   - Mitigation: Extensive testing, progressive enhancement

### Business Risks
1. **Low Adoption Rate**
   - Mitigation: Incentives, contractor requirements
   
2. **Privacy Concerns**
   - Mitigation: Clear communication, local data option
   
3. **Brand Dilution**
   - Mitigation: Quality control, professional templates

## Future Enhancements

### Short Term (3-6 months)
- Digital wallet integration
- Multi-language support
- Contractor feedback system
- Video profile option

### Long Term (6-12 months)
- Blockchain credential verification
- AI-powered document verification
- Integration with government services
- White-label solutions for large contractors

## Conclusion

The Worker Onboarding Pack represents a strategic initiative to increase RateRight's brand presence while providing genuine value to construction workers. By creating a portable, professional profile system, we position ourselves as the go-to platform for construction industry credentials while respecting worker privacy and data security.

The hybrid template approach balances user convenience with privacy protection, ensuring sensitive information never touches our servers while still providing a seamless experience. This specification provides a complete roadmap for implementation, with clear phases, success metrics, and technical requirements.

Success of this feature will be measured not just by adoption rates, but by the broader impact on RateRight's market position and brand recognition in the construction industry.