Reza DocuHandshake — User Flows
Flow 1 — User Submits a Document
Step 1 — Magic-Link Verification
- User visits
https://docu.r32a.com/. - The
AuthFormcomponent asks for an email address. - Frontend calls
POST /api/auth/magic-link/request. - Backend inserts a one-time token hash into
magic_link_tokensand sends a Resend email. - The email links to
/auth/verify?token=.... AuthVerifyPagecallsPOST /api/auth/magic-link/verify.- Backend marks the token as used and sets the
rdh_user_sessionHTTP-only cookie. - Frontend checks session state with
GET /api/auth/sessionand shows the upload form.
Step 2 — Document Upload
- User sees
DocumentUploadCard. - User selects or drags in a PDF.
- Client validation allows only PDF files up to 10 MB.
- User enters an optional description.
- Optional: user enables
SignatureAreaMarkerand clicks on the PDF preview to mark suggested signature locations. - Frontend submits multipart form-data to
POST /api/documents/upload.
Step 3 — Upload Processing
requireUserverifies the session cookie.- Backend saves the file under:
documents/{timestamp}-{uuid}-{sanitized-filename} - Backend inserts a row into
documentswith:status = 'pending'commentsuggested_signature_positions
- Backend inserts an audit entry with
action = 'document_uploaded'. - Backend attempts to email Reza about the new upload.
- If notification email fails, the upload still succeeds and the warning is logged server-side.
Step 4 — Thank-You Page
- Frontend navigates to
/thank-you. - User sees confirmation that the document was received.
- Clicking "Back to Main Page" signs the user out through
POST /api/auth/logoutand returns to/.
Flow 2 — Admin Reviews and Signs a Document
Step 1 — Admin Sign-In
- Reza visits
/admin. AdminAuthchecks the entered password againstVITE_ADMIN_PASSWORD.- After frontend sign-in succeeds, the dashboard loads documents through
POST /api/admin/list-documents. - Backend validates the password against
ADMIN_PASSWORDbefore returning data.
Step 2 — Dashboard List View
The admin dashboard includes:
- Search by filename or uploader email
- Pagination with 6 documents per page
- Active vs archived toggle based on
documents.archived - Status badges for
pending,signed, andcompleted - Analytics view
- Settings view
- Bulk ZIP download of signed documents
Step 3 — Settings View
The Settings view lets Reza define a reusable signature preset:
- Text signature mode
- Image upload signature mode
- Adjustable signature scale
The preset is stored in the backend as the shared source of truth and also cached in browser localStorage under rdh_admin_signature_preset_v1.
That means:
- desktop and mobile now use the same saved signature preset
- an older desktop-only local preset can seed the shared backend preset the first time the admin signs in after the update
Step 4 — Document Viewer and Analysis
- Reza opens a document from the list.
- Frontend loads the PDF from:
GET /api/documents/:id/file?adminPassword=... react-pdfrenders the file in-browser.DocumentAnalysiscan extract text from the loaded PDF in the browser and callPOST /api/admin/analyze-document.- The backend sends the extracted text to OpenAI
gpt-4o-mini. - The analysis result currently returns:
summarykeyPointsreviewAreasrisksriskAssessment
Step 5 — Placing Signature Markers
- Reza enters "Place Signature" mode.
- Clicking the page adds signature markers for the current PDF page.
- Existing markers can be dragged to fine-tune placement.
- Markers can be removed individually or cleared all at once.
- If the uploader supplied suggested positions, the admin can load them with "Use Suggested Positions".
- Page navigation and zoom controls are available while reviewing the document.
Step 6 — Completing the Signature
All PDF editing happens in the browser:
- Frontend downloads the original PDF bytes from the secure document URL.
signPdfBytes()loads the file withpdf-lib.- For each marker, the app renders either:
- the configured signature image, or
- a text signature fallback
- The app also draws a small footer with signer name plus signed date/time.
- The finished PDF is uploaded to
POST /api/admin/upload-signed-file. - Backend stores the signed file under:
signed/{documentId}/{timestamp}_{sanitized-filename} - Frontend calls
POST /api/admin/update-documentto set:status = 'signed'signed_atsignature_data(JSON string of signature positions)file_path(the signed file path)
- The same update request can write an audit entry with
action = 'signed'. - Frontend calls
POST /api/notifications/sendwithtype = 'document_signed'. - Backend attaches the signed PDF to the email and also includes a tokenized public download link valid for 20 minutes.
Step 7 — Post-Signing Actions
After review, Reza can:
- Resend the signed document email
- Download the signed PDF directly
- Reject the document with a reason
Current rejection behavior:
- Frontend sets
status = 'completed'. - Backend inserts an audit entry with
action = 'rejected'. - Frontend calls
POST /api/notifications/sendwithtype = 'document_rejected'. - The rejection email tells the uploader to resubmit via the main portal.
Signed documents are locked in the viewer and marker editing is disabled.
Flow 3 — Bulk Download All Signed Documents
- Reza clicks "Download All Signed (N)" in the dashboard.
- Frontend filters the current document set to rows where
status === 'signed'. - Each signed PDF is fetched through the secure document endpoint.
- Files are added to a JSZip archive using:
{first8DocumentId}_{originalFilename} - If a filename collides, a counter is appended.
- Browser download starts as:
signed-documents-YYYY-MM-DD.zip
Flow 4 — Analytics View
Analytics are computed client-side from non-archived documents and support these time filters:
- All time
- Today
- Last 7 days
- Last 30 days
- Last 90 days
- Last year
Displayed metrics:
- Trees saved estimate
- Time saved estimate
- Unique senders
- Completion rate
- Average processing time
- Top senders
- Document type distribution
- Status distribution
- Monthly submission trends
- Peak submission days
- File size distribution
- Largest documents
- Recent activity