> For the complete documentation index, see [llms.txt](https://outline-1.gitbook.io/outline/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://outline-1.gitbook.io/outline/design-and-architecture/data-model.md).

# Data model

ER Diagram

<figure><img src="https://3688977829-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQOJE6aViGSPYJ08xzzcA%2Fuploads%2FFee1n7vetBMUux06MSGh%2Fimage.png?alt=media&amp;token=7aa7081b-a712-4a0d-8b22-78ef1f3fc3e8" alt=""><figcaption></figcaption></figure>

***

#### Schema Explanations

<br>

**documents**

&#x20;**Table**

* id (uuid, PK, default gen\_random\_uuid())

  Unique identifier for each document.
* filename (varchar(255), NOT NULL)

  Original filename of the uploaded document.
* file\_type (varchar(10), NOT NULL, CHECK in \['pdf','docx'])

  File extension/type (must be either pdf or docx).
* upload\_timestamp (timestamp, default now())

  Timestamp when the file was uploaded.
* title (text)

  Parsed title from the document’s front matter.
* document\_type (varchar(100))

  Type of document (e.g., “Diplomsko delo,” “Magistrsko delo”).
* student\_name (varchar(255))

  Name of the student (extracted from the document).
* study\_program (text)

  Program of study (extracted from the document).
* study\_direction (varchar(255))

  Study direction or field (extracted from the document).
* mentor (varchar(255))

  Name of the primary mentor.
* co\_mentor (varchar(255))

  Name of the co-mentor (if any).
* lecturer (varchar(255))

  Name of the reviewer/editor (lektor).
* overall\_score (integer)

  Computed structure suitability score (0–100).
* total\_sections (integer)

  Total number of required sections (front matter + body).
* found\_sections (integer)

  Count of sections actually found in the document.
* missing\_critical\_count (integer)

  Number of missing “critical” sections (e.g., abstract, introduction, conclusion).
* uvod\_quality (integer)

  Quality metric for the “Uvod” section (e.g., number of subsections found).
* front\_matter\_analysis (jsonb)

  JSON object mapping each front‐matter element → true/false.
* body\_sections\_analysis (jsonb)

  JSON object mapping each body section (e.g., “Uvod,” “Metodologija”) → true/false.
* missing\_sections (text\[])

  Array of front‐matter section names that were not found.
* missing\_body\_sections (text\[])

  Array of body section names that were not found.
* recommendations (text\[])

  List of suggested improvements based on analysis.
* table\_of\_contents (jsonb)

  Parsed table of contents entries (number, title, level).
* uvod\_content (text\[])

  Array of all paragraphs under the “Uvod” section.
* created\_at (timestamp, default now())

  When the record was created.
* updated\_at (timestamp, default now())

  When the record was last updated.

<br>

**document\_paragraphs**

&#x20;**Table**

* id (uuid, PK, default gen\_random\_uuid())

  Unique identifier for each paragraph record.
* document\_id (uuid, NOT NULL, FK → documents.id)

  References the parent document. On delete cascade ensures paragraphs are removed if the document is deleted.
* paragraph\_order (integer, NOT NULL)

  The zero‐based index/order of this paragraph within the document.
* paragraph\_id (varchar(255), NOT NULL)

  A UUID string (from the document parser) uniquely identifying this paragraph.
* paragraph\_style (varchar(100))

  Style name (e.g., “Heading 1,” “Normal”) from Word/PDF conversion.
* content (text, NOT NULL)

  The actual paragraph text.
* created\_at (timestamp, default now())

  When the paragraph record was created.
* Indexes:
  * Index on (document\_id) for quickly finding all paragraphs of a document.
  * Composite index on (document\_id, paragraph\_order) to preserve ordering.

<br>

**profiles**

&#x20;**Table**

* id (uuid, PK, FK → auth.users.id)

  Matches the Supabase Auth user ID. On delete cascade removes profile if the Auth user is deleted.
* name (text)

  User’s full name (optional).
* email (text)

  Email address (optional; may duplicate auth.users.email).
* image (text)

  URL to user’s avatar or profile picture (optional).
* customer\_id (text)

  Identifier for a billing customer (if applicable).
* price\_id (text)

  Identifier for a subscription or pricing plan (if applicable).
* has\_access (boolean, default false)

  Indicates whether this user can upload and analyze documents.
* created\_at (timestamp, default now() AT TIME ZONE 'UTC')

  When the profile was created.
* updated\_at (timestamp, default now() AT TIME ZONE 'UTC')

  When the profile was last updated.
* Triggers:
  * update\_profiles\_updated\_at automatically sets updated\_at on each update.

***
