Skip to content

RavenHursT/source-document-management-system

Repository files navigation

Self-Healing Content System

Memorang take-home exercise: detect, triage, and heal GCP Professional Cloud Architect practice questions when upstream Google Cloud sources change.

Live demo: source-document-management-system-five.vercel.app

Features

  • Cache-aware source polling with Vercel Cron
  • Change detection, provenance-based impact analysis, and triage
  • AI healing proposals (Vercel AI SDK + OpenRouter)
  • Human review workflow (approve / reject / edit)
  • Cloud Next simulation with SSE progress UI
  • Dashboard, sources, changes, review queue, and content views

Prerequisites

  • Node.js 20+
  • pnpm
  • Supabase project (free tier)
  • OpenRouter API key (for auto-healing proposals)

Setup

  1. Install dependencies:
pnpm install
  1. Copy environment variables:
cp .env.example .env.local

Fill in values from your Supabase project dashboard (Project Settings → API Keys):

Variable Description
NEXT_PUBLIC_SUPABASE_URL Project URL
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY Publishable key (sb_publishable_...)
SUPABASE_SECRET_KEY Secret key (sb_secret_..., server-only)
CRON_SECRET Random string for Vercel Cron auth
OPENROUTER_API_KEY OpenRouter API key for healer agent
OPENROUTER_HEALER_MODEL Optional; defaults to openai/gpt-oss-120b:free
  1. Apply the database migration:

Run supabase/migrations/20250610120000_initial_schema.sql in the Supabase SQL editor.

pnpm db:migrate
  1. Seed baseline data:
pnpm db:seed
  1. Start the dev server:
pnpm dev

Open http://localhost:3000.

Demo Walkthrough

1. Explore baseline state

  • Dashboard — source counts, open changes, review queue depth
  • Sources — five registered GCP URLs with v1 snapshots
  • Content — twelve practice questions with provenance links

2. Live polling (optional)

Poll registered sources against live URLs (requires network; may take several minutes if healing runs):

pnpm poll:sources:force

3. Cloud Next simulation (recommended for demo)

  1. Open the Dashboard
  2. Click Simulate Google Cloud Next Update
  3. Watch per-source progress in the dialog
  4. Use Minimize to collapse to a floating spinner; click it to restore
  5. When complete, dashboard stats refresh and new items appear in Changes and Review

The simulation injects pre-authored v2 snapshots for four doc sources; the exam guide stays unchanged.

4. Human review

  1. Go to Review — proposals sorted by priority
  2. Open a proposal — side-by-side current vs proposed, diff excerpt, citations
  3. Approve, Reject, or Edit and approve

5. Verify healed content

  • Content — updated questions return to active
  • Changes — drill into a change event for affected items and proposals

Scripts

Command Description
pnpm dev Start Next.js dev server
pnpm build Production build
pnpm db:seed Load baseline GCP PCA data
pnpm db:migrate Migration reminder
pnpm poll:sources Poll due sources
pnpm poll:sources:force Reset schedule and poll all sources

Vercel Deployment

  1. Import the repository in Vercel
  2. Add all environment variables from .env.example
  3. Deploy — cron runs /api/cron/poll-sources daily
  4. Simulation SSE (/api/simulation/progress) requires sufficient function duration (maxDuration = 300 on Pro plan recommended for full healing runs)

See docs/SYSTEM_DESIGN.md for architecture and technical decisions.

About

Self-healing content system for GCP certification source documents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors