Skip to content

SCMS [SCMS] Add admin endpoint to sync Lab Notes from filesystem 🔄#15

Merged
AdaInTheLab merged 1 commit intomainfrom
feat/sync-md-notes
Jan 7, 2026
Merged

SCMS [SCMS] Add admin endpoint to sync Lab Notes from filesystem 🔄#15
AdaInTheLab merged 1 commit intomainfrom
feat/sync-md-notes

Conversation

@AdaInTheLab
Copy link
Owner

🧠 What & Why

This PR introduces an explicit, admin-controlled sync mechanism for ingesting Lab Notes from Markdown files on the server into the API database.

Markdown files are now deployed into the API filesystem by the main site. This PR completes the loop by giving the API a deliberate, observable way to convert that content into runtime data.

Filesystem is the source of truth → Database is the serving layer

No background jobs. No deploy-time side effects. No hidden behavior.


🔁 What changed

  • Adds a new admin-only endpoint:
POST /admin/notes/sync
  • Reads Markdown files from LABNOTES_DIR
  • For each locale:
  • Parses frontmatter
  • Renders Markdown → HTML
  • Upserts notes into lab_notes
  • Returns a deterministic JSON summary:
  • scanned
  • upserted
  • skipped
  • errors (if any)

🧩 How it fits into the system

End-to-end Lab Notes flow:

  1. Markdown authored in main site repo
  2. Main site deploy publishes Markdown into API filesystem
  3. Admin triggers Sync Markdown → DB
  4. API ingests content into SQLite
  5. Public /lab-notes endpoints serve synced data

This preserves a clean separation of responsibilities:

  • Main site = authoring & publishing
  • API = ingestion, validation, serving

🛡 Guardrails

  • Sync is explicitly admin-triggered
  • Endpoint is auth-gated
  • No runtime auto-sync
  • No deploy-time DB mutations
  • Safe to re-run (idempotent upserts)

🧪 How to verify

  1. Ensure LABNOTES_DIR is set in API env
  2. Confirm Markdown files exist in:
lab-api/content/labnotes/{locale}/*.md
  1. Open Admin → Lab Notes
  2. Click Sync Markdown → DB
  3. Verify response summary shows expected counts
  4. Confirm /api/lab-notes reflects new/updated entries

🗒 Notes

  • Sync logic is filesystem-driven and deterministic
  • Locale handling assumes (slug, locale) uniqueness
  • UI wiring is intentionally minimal and observable

This PR establishes the canonical ingestion path for Lab Notes going forward.

- Add POST /admin/notes/sync (auth-gated)
- Read LABNOTES_DIR and ingest Markdown → HTML → DB upsert
- Return deterministic JSON summary (scanned/upserted/skipped/errors)

co-authored-by: Lyric <lyric@thehumanpatternlab.com>
co-authored-by: Carmel <carmel@thehumanpatternlab.com>
@AdaInTheLab AdaInTheLab merged commit a460488 into main Jan 7, 2026
1 check passed
@AdaInTheLab AdaInTheLab deleted the feat/sync-md-notes branch January 7, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant