🚀 DPPS Quick Start Guide
Goal: Ship a working Digital Product Publishing System in ≤ 2 weeks
✅ What Already Exists (Foundation Validated)
Backend (Java/Spring)
- ✅ Product, Invoice, LineItem — ThorAPI-generated models
- ✅ DigitalAsset, DownloadAccess, FileRecord — Digital fulfillment entities
- ✅ DigitalFulfillmentService — ACL-based download grants + signed URLs
- ✅ FileController — Multipart uploads (
/files/uploads/init,/files/uploads/complete) - ✅ StripeCheckoutModule, StripeWebhookModule — Payment integration
- ✅ ProductFunnelWizard — Funnel generation workflow
- ✅ AclService — Permission management (
/v1/auth/acl/grant,/v1/auth/acl/revoke)
Frontend (React/TypeScript)
- ✅ RTK Query services — Auto-generated for all entities
- ✅ FileUploadSession — Upload state management
- ✅ ProductFunnelWizard — Funnel creation hooks
🎯 What Needs to Be Built (6 Key Pieces)
1. OpenAPI Schema Enhancement (30 min)
Add missing fields to Product schema for digital delivery:
# Add to valkyrai/src/main/resources/openapi/api.hbs.yaml
Product:
properties:
contentDataId: # Link to uploaded file
type: string
format: uuid
deliveryMode: # NEW: Digital vs Physical
type: string
enum: [DIGITAL_DOWNLOAD, STREAMING, LICENSE_KEY, PHYSICAL]
default: DIGITAL_DOWNLOAD
maxDownloads: # NEW: Download limits
type: integer
expiresAfterDays: # NEW: Entitlement expiry
type: integer
Action: Regenerate ThorAPI models after adding these fields.
2. Backend: DPPS Orchestration Service (2 hours)
File: valkyrai/src/main/java/com/valkyrlabs/valkyrai/service/DppsOrchestrationService.java
Purpose: Coordinates Upload → Product → Funnel → Checkout flow
Key Methods:
public Product createProductFromUpload(UUID fileRecordId, CreateProductRequest request)
public ProductFunnelWizard publishProduct(UUID productId, PublishRequest request)
Dependencies:
FileRecordService(existing)DigitalAssetService(existing)ProductService(existing)ProductFunnelWizardService(existing)AclService(existing)
Action: Copy implementation from DPPS_IMPLEMENTATION_PLAN.md Phase 2.2
3. Backend: Purchase Fulfillment Workflow (3 hours)
File: valkyrai/src/main/java/com/valkyrlabs/workflow/definitions/DppsPurchaseFulfillmentWorkflow.java
Purpose: Auto-register workflow that fires on payment success
Tasks:
- VerifyPayment (StripeWebhookModule)
- GrantAccess (DigitalFulfillmentModule — wrapper around existing
DigitalFulfillmentService) - NotifyBuyer (MailtrapSendModule)
- PostPurchase (optional: Slack, CRM webhook)
Action: Copy implementation from DPPS_IMPLEMENTATION_PLAN.md Phase 2.3
4. Backend: Download Endpoint with Signed URLs (2 hours)
File: valkyrai/src/main/java/com/valkyrlabs/valkyrai/controller/DownloadController.java
Endpoint: GET /v1/download/{downloadAccessId}?validityMinutes=15
Logic:
- Verify ACL READ permission
- Check DownloadAccess status (ACTIVE, not expired)
- Enforce max downloads limit
- Generate signed URL via
DigitalFulfillmentService - Increment download counter
Security: Uses existing Spring ACL @PreAuthorize on DownloadAccess entity
Action: Copy implementation from DPPS_IMPLEMENTATION_PLAN.md Phase 2.5
5. Frontend: DPPS Wizard Component (4 hours)
Files:
web/typescript/valkyr_labs_com/src/components/dpps/FileUploader.tsxweb/typescript/valkyr_labs_com/src/components/dpps/ProductForm.tsxweb/typescript/valkyr_labs_com/src/components/dpps/PublishProduct.tsxweb/typescript/valkyr_labs_com/src/pages/DppsWizard.tsx
Flow:
Upload File → Create Product (Draft) → Configure Funnel → Publish → Get Landing Page URL
Key Hooks:
usePostFileUploadSessionMutation()— UploaduseCreateProductMutation()— Product creationuseStartFunnelWizardMutation()— Funnel generationusePublishFunnelMutation()— Publish funnel
Action: Copy implementations from DPPS_IMPLEMENTATION_PLAN.md Phase 3
6. Email Template (30 min)
File: valkyrai/src/main/resources/db/migration/V999__dpps_email_templates.sql
INSERT INTO email_template (id, template_name, subject, body_html, category)
VALUES (
gen_random_uuid(),
'dpps_download_ready',
'Your download is ready: {{productTitle}}',
'<html>...</html>',
'FULFILLMENT'
);
Action: Run migration after implementation
📝 Step-by-Step Implementation (Day-by-Day)
Day 1: Backend Foundation
- ✅ Validate existing entities (DigitalAsset, DownloadAccess)
- 🔧 Enhance Product schema (OpenAPI)
- 🔧 Regenerate ThorAPI models (
mvn clean installin thorapi, then valkyrai) - 🔧 Implement
DppsOrchestrationService - 🧪 Unit tests for orchestration service
Day 2: Workflow & Fulfillment
- 🔧 Implement
DppsPurchaseFulfillmentWorkflow - 🔧 Implement
DigitalFulfillmentModule(ExecModule wrapper) - 🔧 Implement
DownloadControllerwith signed URLs - 🧪 Integration test (upload → product → mock payment → download)
Day 3-4: Frontend Components
- 🔧 Build
FileUploadercomponent (drag-drop + resumable) - 🔧 Build
ProductForm(Formik + validation) - 🔧 Build
PublishProductcomponent - 🔧 Wire up
DppsWizardorchestration page - 🧪 End-to-end frontend test
Day 5: Integration & Testing
- 🔧 Create email template + migration
- 🔧 Test full flow: Upload → Product → Funnel → Stripe (test mode) → Download
- 🔧 Fix ACL permission issues
- 🔧 Add Grafana dashboard for metrics
Day 6-7: Polish & Beta Launch
- 🔧 Admin panel: Orders, Entitlements, Revoke access
- 🔧 Error handling + user-friendly messages
- 🔧 Documentation (API docs, user guide)
- 🚀 Deploy to staging
- 🚀 Internal dogfood (3 test products)
🧪 Testing Checklist
Unit Tests
-
DppsOrchestrationService.createProductFromUpload() -
DppsOrchestrationService.publishProduct() -
DownloadController.getDownloadUrl()(ACL checks)
Integration Tests
- Full flow: Upload → Product → Funnel → Payment → Download
- ACL permissions: Creator vs Buyer vs Admin
- Download limits enforcement
- Expiry date handling
E2E Tests
- Upload 100MB file (resume on failure)
- Stripe test mode payment
- Email delivery (Mailtrap)
- Download link redemption (TTL validation)
🚀 Deployment Checklist
Environment Variables
# Required
STRIPE_SECRET_KEY=sk_test_...
MAILTRAP_API_KEY=...
FILE_STORAGE_DRIVER=s3 # or 'local' for dev
# Optional
STRIPE_WEBHOOK_SECRET=whsec_...
AWS_S3_BUCKET=valkyr-digital-assets
AWS_REGION=us-east-1
Database Migrations
cd valkyrai
mvn flyway:migrate
Rebuild & Deploy
cd thorapi
mvn clean install
cd ../valkyrai
mvn clean package
make harness-up # Docker local dev
📊 Success Metrics (Week 1)
- 3 internal products created successfully
- TTFP (Time-to-First-Product) < 60 seconds
- Upload success rate > 95%
- Download link redemption rate 100%
- Zero ACL permission errors in staging logs
🆘 Troubleshooting
"FileRecord not found"
- Check
FileUploadSession.completedAtis set - Verify file completed multipart upload
- Check
FileRecord.status = AVAILABLE
"Entitlement not found"
- Verify payment success webhook fired
- Check
DownloadAccesstable for buyer principal ID - Inspect workflow execution logs (
Workflow.status)
"Permission denied"
- Check ACL grants:
SELECT * FROM acl_entry WHERE object_id_identity = '<productId>'; - Verify buyer's Principal exists in system
- Test with admin role:
ROLE_ADMINbypasses ACL
"Download link expired"
- Default TTL is 15 minutes
- Check
DownloadAccess.expiresAttimestamp - Regenerate link via
/v1/download/{id}endpoint
🎓 Next Steps After MVP
Phase 2 Features
- Multi-file products (zip on demand with
FileZipModule) - License key generation (add
LicenseModule) - Shopify payment bridge (via RestApiModule)
- Coupon codes (add
Discountentity integration) - Guest checkout (auto-create Principal on payment success)
Phase 3 Features
- Subscription products (recurring payments)
- Streaming delivery (HLS/DASH)
- Webhook notifications (Zapier, Make)
- Affiliate tracking (referral links)
- Analytics dashboard (purchase funnel, conversion rates)
📚 Reference Documentation
- Full Implementation Plan:
DPPS_IMPLEMENTATION_PLAN.md - PRD: Original requirement doc (Section 1-26)
- Existing Services:
DigitalFulfillmentService.java(reference implementation) - Frontend Patterns:
ValorIDE_docs/techContext.md - ACL Guide:
web/src/main/resources/templates/typescript-redux-query/README.ACL.md
✅ Definition of Done
- All acceptance criteria from PRD pass in staging
- No mocks remain; all generated services used
- Observability dashboards deployed (Grafana)
- Security review signed off (ACL tests, link TTL, revocation)
- Runbooks updated for Support & Ops
- 3 internal products successfully published and purchased
Estimated Total Time: 40-50 hours (1-2 weeks for solo developer)
Ready to start? Begin with Day 1, Step 2 (OpenAPI schema enhancement).
Run: code valkyrai/src/main/resources/openapi/api.hbs.yaml