Multi-Document Support (Technical Guide)
Deckly's multi-document engine extends beyond PDFs to support Microsoft Office (PPTX, DOCX, XLSX) and CSV files. This document outlines the technical implementation of the processing pipeline, display modes, and security gating.
Processing Pipeline
1. File Upload & Identification
When a user selects a file in ManageDeck.tsx, the system identifies the file type via extension:
- Supported:
.pdf,.pptx,.docx,.doc,.xlsx,.csv. - Logic: File selection happens in
ManageDeck.tsx, while processing/conversion orchestration now lives inuseManageDeckWorkflow.tsandworkflows/deckProcessing.ts.
2. PDF "Interactive" Processing (Client-Side)
For PDFs, high-fidelity slide viewing and link preservation are handled entirely in the browser:
- Technology: Uses
pdfjs-dist(PDF.js) for rendering and metadata extraction. - Link Preservation:
- The
extractPdfLinkHotspots()utility scans the document's annotation layer. - It identifies
Linksubtypes and extracts their URLs and bounding boxes. - Coordinates are mapped to 0-1 percentages relative to the page viewport.
- The
- Workflow:
- Load: PDF is loaded into browser memory.
- Extract: Links are extracted and stored in the
SlidePage.linksarray. - Rasterize: Each page is rendered to a canvas and converted to a WebP blob.
- Upload: Images and metadata are uploaded through the shared deck processing/storage flow.
3. Office "Interactive" Conversion (Edge Function)
For Office files (PPTX, DOCX), conversion is handled by a Supabase Edge Function (document-processor):
- Provider: Uses ConvertAPI for server-side image generation.
- Current Limitation: Link preservation is currently restricted to native PDF uploads. Office-to-Image conversion produces static rasterized slides without hyperlink metadata.
- Workflow:
- Download: The function downloads the raw file from Supabase Storage.
- Convert: ConvertAPI transforms the file into high-quality JPG images.
- Upload: The resulting images are stored in a unique folder.
- Metadata Update: The
pagesarray in thedeckstable is updated with the image URLs.
Display Modes
1. Interactive Mode (display_mode: 'interactive')
Renders the document as a slide-by-slide web experience using ImageDeckViewer.tsx.
- Data Shape:
Deck.pagescontains an array of image URLs. - Analytics: Supports slide-level engagement heartbeat tracking.
- Requirement: Restricted to PRO users.
2. "Raw" View Mode (display_mode: 'raw')
Integrates the Microsoft Office Online viewer for native-fidelity rendering.
- Implementation: Renders an
<iframe>pointing tohttps://view.officeapps.live.com/op/embed.aspx. - Best For: Multi-sheet Excels or content-heavy Word docs where web-native navigation (PDF-style) isn't the priority.
Tier Enforcement & Gating
The tiered access logic is centralized in src/constants/tiers.ts.
- Feature Flag:
canUseOfficeSupportandcanUseInteractiveMode. - UI Gating:
- Upload:
ManageDeck.tsxprevents uploading Office files for FREE users. - Interactive Toggle: Displays a "PRO" badge; clicking triggers the
TierUpsellModal. - Server-Side: The Edge Function verifies the user's tier before processing, preventing API-level bypasses.
- Upload:
Security Hardening
To protect sensitive pitch data, the processing pipeline includes multiple security layers:
- JWT Verification: Processors require a valid Supabase
access_tokenin the Authorization header. - Ownership Check: The Edge Function queries the database to ensure
auth.uid() === deck.user_idbefore touching any data. - Error Shielding: Errors from ConvertAPI or Storage are caught and logged server-side. The client receives only a generic
Internal Server Errorto prevent leaking infrastructure details. - Data Integrity: Conversion results are stored in isolated, user-specific paths (
userId/deck-id/converted/).
