Skip to content

feat: overhaul realistic demo seeding#217

Merged
ldsgroups225 merged 5 commits intomasterfrom
feat/realistic-demo-seeding
Mar 30, 2026
Merged

feat: overhaul realistic demo seeding#217
ldsgroups225 merged 5 commits intomasterfrom
feat/realistic-demo-seeding

Conversation

@ldsgroups225
Copy link
Copy Markdown
Owner

@ldsgroups225 ldsgroups225 commented Mar 30, 2026

Summary

  • overhaul demo seeding to follow a production-like school lifecycle across catalog, classes, operations, reporting, and finance
  • harden Neon HTTP execution with batched, retry-aware seeding and realistic attendance/finance/reporting behavior
  • add direct coverage for KPI metrics, profile ordering, and realism-gate validation so regressions fail in tests instead of live reruns

Test Plan

  • pnpm exec vitest run src/tests/demo-finance-helpers.test.ts src/tests/demo-metrics-helpers.test.ts src/tests/demo-profile-kpi-helpers.test.ts src/tests/demo-catalog-realism-helpers.test.ts src/tests/demo-academic-realism-helpers.test.ts src/tests/demo-operations-helpers.test.ts
  • pnpm typecheck
  • live realistic demo seed completed successfully on Neon HTTP for DEMO-REAL

Summary by CodeRabbit

  • New Features

    • Demo seeding now generates realistic, production-like school data including academic curriculum, class schedules, attendance records, grades, conduct incidents, and complete finance lifecycle (fees, payments, accounting).
    • Added validation to ensure demo schools include sufficient coverage of critical tables for operational viability.
  • Documentation

    • Added realistic demo seeding guidelines and table coverage requirements.
  • Configuration

    • DemoSeedConfig now requires explicit gradeNames declaration for demo profiles.
  • Tests

    • Added comprehensive test coverage for all demo seeding helpers and utilities.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request implements a comprehensive "Realistic Demo Seeding" system that transforms demo data initialization from simple scaffolding into production-like scenarios. It adds academic catalog seeding, realistic finance pipelines with transactions and account balances, comprehensive operations data (timetables, attendance, grades, reporting), engagement signaling, and hardened retry-aware data operations. The changes span documentation, configuration, core orchestration, 15+ new helper modules, seeder updates, and extensive test coverage.

Changes

Cohort / File(s) Summary
Documentation
docs/demo-data-seeding-system.md, docs/superpowers/plans/2026-03-30-realistic-demo-seeding-status.md, docs/superpowers/plans/seeded-table-coverage-checklist.md
Added documentation for realistic demo seeding requirements, project status/completion metrics, and table coverage checklist to guide implementation.
Configuration
packages/data-ops/src/seed/demo/config.ts
Extended DemoSeedConfig with required gradeNames: readonly string[] field; added defaultDemoGradeNames constant; updated all profile exports to use the new field.
Core Seeding Orchestration
packages/data-ops/src/seed/demo/index.ts, packages/data-ops/src/seed/demo/reset.ts
Added seedAcademicCatalog and seedOperations pipeline steps; expanded computeDemoStats with attendance/finance metrics; introduced validateRealisticDemoCoverage gate; refactored reset logic with chunked deletion and retry support.
Academic Catalog & Realism Helpers
packages/data-ops/src/seed/demo/seeders/academic-catalog.seeder.ts, packages/data-ops/src/seed/demo/seeders/academic-realism-helpers.ts, packages/data-ops/src/seed/demo/seeders/catalog-realism-helpers.ts
New seeders and helpers for program templates, chapter assignments, grade-aware class subjects, curriculum artifacts (sessions, completions, progress), coefficient overrides, and coverage validation.
Class & Enrollment Planning
packages/data-ops/src/seed/demo/seeders/classes-helpers.ts, packages/data-ops/src/seed/demo/seeders/classes.seeder.ts, packages/data-ops/src/seed/demo/seeders/teachers.seeder.ts
Refactored class generation to derive from configured grade names; added planSeededClassArtifacts helper for deterministic bulk class/subject/enrollment creation; updated teacher subject assignment to use school-scoped coverage.
Operations Seeding
packages/data-ops/src/seed/demo/seeders/operations.seeder.ts, packages/data-ops/src/seed/demo/seeders/operations-helpers.ts
New comprehensive operations seeder (1100+ lines) for timetable slots, class sessions, curriculum artifacts, student attendance, report cards, and teacher engagement messaging; includes timetable scheduling algorithm and lifecycle computations.
Student Activities & Engagement
packages/data-ops/src/seed/demo/seeders/student-activity-helpers.ts, packages/data-ops/src/seed/demo/seeders/engagement-helpers.ts, packages/data-ops/src/seed/demo/seeders/attendance.seeder.ts, packages/data-ops/src/seed/demo/seeders/conduct.seeder.ts
Added deterministic scenario-driven attendance and conduct generation; new engagement signal mapping and message thread/notification builders; refactored existing seeders to use bulk helpers.
Finance & Transactions
packages/data-ops/src/seed/demo/seeders/finance-helpers.ts, packages/data-ops/src/seed/demo/seeders/finance.seeder.ts
New finance module (220+ lines of helpers) for payment allocation, transaction line building, account balance state tracking, and fee-type resolution; refactored finance seeder (890+ lines) to model realistic accounting with payments, receipts, transactions, and journal entries with retry/chunk resilience.
Reporting & Grades
packages/data-ops/src/seed/demo/seeders/reporting-helpers.ts, packages/data-ops/src/seed/demo/seeders/grades-helpers.ts, packages/data-ops/src/seed/demo/seeders/grades.seeder.ts
New helpers for building student averages with weighted coefficients, report card lifecycle/narratives, and teacher comments; added deterministic seeded grade ID generation; refactored grade seeder to use bulk chunked insertion with retry.
Student & User Provisioning
packages/data-ops/src/seed/demo/seeders/students-helpers.ts, packages/data-ops/src/seed/demo/seeders/students.seeder.ts
Added batch user provisioning planning; refactored student seeder to deduplicate and bulk-insert parent users with deterministic matricule generation.
Data Resilience & Utilities
packages/data-ops/src/seed/demo/seeders/seed-resilience-helpers.ts, packages/data-ops/src/seed/demo/seeders/profile-kpi-helpers.ts, packages/data-ops/src/seed/demo/seeders/demo-metrics-helpers.ts, packages/data-ops/src/seed/demo/seeders/curriculum-library.ts, packages/data-ops/src/seed/demo/utils/matricule.ts, packages/data-ops/src/tests/setup.ts
New resilience module with retry, chunking, and adaptive chunk-size reduction; KPI estimation helpers; metrics aggregation; Excel-based curriculum library loader; deterministic matricule generation; updated test environment variable resolution.
Test Coverage
packages/data-ops/src/tests/demo-*.test.ts (15 new files)
Comprehensive Vitest suites covering all new helpers: academic realism, catalog realism, classes, engagement, finance, grades, matricule, metrics, operations, KPI estimation, reporting, resilience, student activities, and student helpers.

Sequence Diagram(s)

sequenceDiagram
    participant Seed as Seed Orchestrator
    participant Catalog as Academic Catalog
    participant Classes as Classes Seeder
    participant Ops as Operations Seeder
    participant Finance as Finance Seeder
    participant Validate as Coverage Validator

    Seed->>Catalog: seedAcademicCatalog(gradeNames)
    Catalog->>Catalog: Load grades, subjects, coefficients
    Catalog->>Catalog: Build/insert program templates & chapters
    Catalog-->>Seed: schoolSubjects, schoolSubjectCoefficients

    Seed->>Classes: seedClasses(gradeAwareAssignments)
    Classes->>Classes: planSeededClassArtifacts(gradeNames)
    Classes->>Classes: Bulk insert classes, classSubjects, enrollments
    Classes-->>Seed: classes, classSubjects, enrollments

    Seed->>Ops: seedOperations(contexts)
    Ops->>Ops: Provision staff users & roles
    Ops->>Ops: assignTimetableSlots(classSubjects)
    Ops->>Ops: Generate class sessions & curriculum artifacts
    Ops->>Ops: buildSeededAttendanceRows(scenarios)
    Ops->>Ops: buildStudentAverages(grades)
    Ops->>Ops: buildReportCards(averages, attendance)
    Ops->>Ops: buildOperationalEngagementArtifacts(signals)
    Ops->>Ops: Bulk insert with chunked retry
    Ops-->>Seed: attendance, curricula, averages, reports, messages

    Seed->>Finance: seedFinance(config)
    Finance->>Finance: Ensure chart of accounts
    Finance->>Finance: Resolve feeTypeTemplateIds(blueprints)
    Finance->>Finance: allocatePaymentToCharges(scenarios)
    Finance->>Finance: buildChargeTransactionLines() + buildPaymentTransactionLines()
    Finance->>Finance: applyTransactionLinesToAccountMap()
    Finance->>Finance: Chunked writes with adaptive retry
    Finance-->>Seed: payments, transactions, account balances

    Seed->>Validate: validateRealisticDemoCoverage()
    Validate->>Validate: Count covered tables
    Validate->>Validate: summarizeRealisticDemoCoverage()
    Validate-->>Seed: {isValid, missingTables}
    alt Coverage Complete
        Seed-->>Seed: Seeding succeeded
    else Coverage Gaps
        Seed-->>Seed: Throw error, fail fast
    end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes

Possibly related PRs

Poem

🐰 With whiskers twitched and careful paws,
I sowed the seeds without a flaw—
Grade names declared, transactions flow,
Attendance tracked from head to toe!
Timetables click, accounts align,
A realistic demo school sublime!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: overhaul realistic demo seeding' directly and clearly summarizes the main change: a comprehensive refactor of the demo seeding system to improve realism across the entire lifecycle.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/realistic-demo-seeding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ldsgroups225 ldsgroups225 merged commit 7e37ef8 into master Mar 30, 2026
15 of 16 checks passed
@ldsgroups225 ldsgroups225 deleted the feat/realistic-demo-seeding branch March 30, 2026 06:46
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.

2 participants