Handover workspace

ERS, Todo, OfferReview, and Docu in one view

Imported from live server docs, code structure, and deployment notes.

Apr 3, 2026, 12:38 PM

DocuHandshake

Reza DocuHandshake — Architecture & Data Reference

`set_documents_updated_at()` keeps `documents.updated_at` current on every update.

03_ARCHITECTURE_AND_DATA.md

Updated Apr 1, 2026, 4:33 AM

Reza DocuHandshake — Architecture & Data Reference

Frontend Routes

RouteComponentPurpose
/IndexPageUser portal: magic-link auth + upload
/auth/verifyAuthVerifyPageToken verification
/thank-youThankYouPagePost-submission confirmation
/adminSigningDashboardPageAdmin dashboard
/loginredirect to /Alias
/signinredirect to /Alias
/authredirect to /Alias
/uploadredirect to /Alias
/startredirect to /Alias
/homeredirect to /Alias
/index.htmlredirect to /Alias
/auth/*redirect to /Alias catch-all
*NotFoundPage404

Backend Utility and API Routes

RoutePurpose
/Small backend utility page for local testing
/apiAPI info payload
/api/healthHealth check

PostgreSQL Schema

Table: documents

ColumnTypeDescription
iduuidPrimary key
user_emailtextUploader email
user_phonetextOptional, unused in current UI
filenametextOriginal filename
file_pathtextRelative path to the current file on disk
file_sizebigintFile size in bytes
mime_typetextCurrently application/pdf
statustextpending, signed, completed
commenttextUpload description
suggested_signature_positionsjsonbOptional array of signature positions
signature_datatextJSON string of the final placed signature positions
signed_attimestamptzWhen signing completed
archivedbooleanArchive toggle used by dashboard filter
created_attimestamptzInsert timestamp
updated_attimestamptzAuto-maintained update timestamp

Table: document_audit_trail

ColumnTypeDescription
iduuidPrimary key
document_iduuidFK to documents.id
actiontextdocument_uploaded, signed, rejected
user_emailtextActor email
timestamptimestamptzEvent time
ip_addressinetOptional metadata
user_agenttextOptional metadata

Table: magic_link_tokens

ColumnTypeDescription
iduuidPrimary key
emailtextRecipient email
token_hashtextSHA-256 hash of the magic-link token
expires_attimestamptzExpiration timestamp
used_attimestamptzSet once token is consumed
created_attimestamptzCreation timestamp

Table: app_settings

ColumnTypeDescription
keytextSetting key
valuejsonbSetting payload
updated_attimestamptzLast update time

Trigger

set_documents_updated_at() keeps documents.updated_at current on every update.

File Storage

Storage is filesystem-based under STORAGE_ROOT (default: storage/).

Relative Path PatternContent
documents/{timestamp}-{uuid}-{sanitized-name}Original uploaded PDF
signed/{documentId}/{timestamp}_{sanitized-name}Signed PDF

documents.file_path always points at the file currently used for download. After signing, it is updated to the signed file path.

Backend API

All API routes are mounted in server/index.ts.

Auth Routes

  • POST /api/auth/magic-link/request
    • Body: { email }
    • Creates a token record and sends a magic link email
  • POST /api/auth/magic-link/verify
    • Body: { token }
    • Marks the token used and sets the session cookie
  • GET /api/auth/session
    • Returns the current signed-in user or null
  • POST /api/auth/logout
    • Clears the session cookie

Document Routes

  • POST /api/documents/upload
    • Auth: user session cookie required
    • Multipart fields: file, comment, suggestedSignaturePositions
  • GET /api/documents/:id/file
    • Auth: owner session cookie or valid admin password
    • Admin callers use the query string or x-admin-password header
  • GET /api/documents/public/download/:token
    • Auth: signed JWT download token
    • Used for public download links in signed-document emails

Admin Routes

  • POST /api/admin/list-documents
    • Auth: admin password required
  • POST /api/admin/get-document-audit-trail
    • Auth: admin password required
  • POST /api/admin/get-signature-preset
    • Auth: admin password required
  • POST /api/admin/update-signature-preset
    • Auth: admin password required
  • POST /api/admin/update-document
    • Auth: admin password required
    • Allowed update fields: archived, status, signed_at, signature_data, file_path
  • POST /api/admin/upload-signed-file
    • Auth: admin password required
    • Multipart upload of the final signed PDF
  • POST /api/admin/analyze-document
    • Current auth behavior: no admin password required
    • Sends extracted PDF text to OpenAI gpt-4o-mini
  • POST /api/admin/generate-signature
    • Current auth behavior: no admin password required
    • Returns an OpenAI-generated handwritten signature or SVG fallback

Notification Route

  • POST /api/notifications/send
    • Current auth behavior: no auth required
    • Types:
      • document_received
      • document_signed
      • document_rejected

Environment Variables

Frontend

  • VITE_API_BASE_URL
  • VITE_ADMIN_PASSWORD

Backend Required

  • DATABASE_URL

Backend Commonly Set

  • PORT
  • HOST
  • APP_BASE_URL
  • API_BASE_URL
  • JWT_SECRET
  • ADMIN_PASSWORD
  • OTP_EXPIRY_SECONDS
  • SESSION_EXPIRY_DAYS
  • STORAGE_ROOT

Optional Integrations

  • RESEND_API_KEY
  • RESEND_FROM_EMAIL
  • REZA_EMAIL
  • OPENAI_API_KEY

Current Behavioral Notes

  • User session cookie name is rdh_user_session.
  • Magic links default to a 24-hour expiry.
  • Signed download links expire after 20 minutes.
  • Rejected documents currently use status = 'completed'; the rejection reason is delivered by email rather than stored in a dedicated column.