DocHub
AI-generated personalized courses — stores the full course JSON with audio and workbook data

custom_courses

What It Stores

When a user purchases a custom course, AI generates a personalized hypnotherapy course just for them. This table stores the complete course data as JSON — including audio file references, workbook content, scripts, and metadata.

Course code for custom courses is always X99ENB (or similar X-prefix codes).

When Rows Are Created

Created during the custom course generation flow:

  1. User purchases a custom course
  2. submit-custom-course triggers script generation via n8n
  3. Audio is generated and uploaded to Cloudflare R2
  4. update_json updates the data column with audio metadata
  5. calculate_checksum computes the checksum and file size

Columns

Column Type Required Default Description
id uuid Yes auto-generated Custom course ID.
user_id uuid Yes Who owns this custom course.
course_code text Yes Always something like X99ENB.
title text Yes User-defined or AI-generated title.
description text Yes Course description.
data json Yes Full course JSON. Contains audio_files (URLs, checksums, durations), workbooks, scripts, and all metadata needed to render the course in the app.
checksum text Yes MD5 of the data JSON. Used by handshake for sync comparison.
file_size_bytes integer Yes Size of the JSON data in bytes.
created_at timestamptz Yes now() When the course was created.
updated_at timestamptz Yes now() Last update (e.g., when new audio is appended).

Key Relationships

  • auth.usersuser_id (course owner)
  • custom_course_purchases — child table tracking purchase info

Who Can Access

Server only — no RLS policy. Edge functions access with service-role key.

Used By These Edge Functions

  • handshake — includes custom courses in sync response
  • submit-custom-course — triggers the generation flow
  • update_json — appends new audio entries to data
  • calculate_checksum — computes/updates checksum and file_size_bytes
  • manage-regen-requests — handles audio regeneration