RezinaLMS-BackEnd/docs/demo-and-public-catalog.md

6.8 KiB
Raw Blame History

Public discovery and pre-production demo

Browse without signing in

The web app exposes /catalog and /catalog/courses/:id outside the authenticated admin layout. Visitors to / see the catalog; signed-in staff retain their usual dashboard redirect. The staff login page also links to the catalog.

Anonymous APIs:

Endpoint Result
GET /api/v1/catalog/courses?q=&limit=20&offset=0 Searchable published course highlights, access tiers, chapter/lesson/quiz counts and pagination
GET /api/v1/catalog/courses/:id Published course outline with chapter descriptions, lesson highlights, and quiz titles/question counts

These endpoints accept no authentication requirement and never expand their visibility for staff tokens. Draft courses return 404; draft chapters, lessons, quiz shells and question sets are excluded. Public DTOs contain no video URLs, questions, correct answers, author identities, or learner progress. Playback, question delivery, and completion remain behind the existing learning endpoints and their authentication/subscription rules. Previewing a premium lesson does not grant access to it.

The web app uses VITE_API_BASE_URL with a trailing /admin removed for catalog requests. Requests omit cookies and staff authorization. Optionally set VITE_LEARNER_APP_URL to your customer web/mobile sign-in destination to display a Sign in to learn link. Without it, the page directs visitors to their learning app. The staff login continues to be labeled Staff sign in.

Install the demo fixture

Apply database migrations through 000003_chapters_and_quizzes, then run from the backend directory:

go run ./cmd/demo-seed -environment development

The command reads DB_URL from the environment or the backend .env. It needs only PostgreSQL; it does not start the application or require payment, email, SMS, or storage provider credentials. -environment must explicitly be development, test, or staging. APP_ENV, ENVIRONMENT, or GO_ENV set to production/prod prevents seeding.

For the repository's Docker PostgreSQL:

docker compose up -d postgres
docker compose run --rm migrate
$env:DB_URL = 'postgresql://root:secret@localhost:5592/gh?sslmode=disable'
go run ./cmd/demo-seed -environment development

The Docker host mapping is 5592:5432. Use your actual database credentials when connecting to another development or staging database. A Docker app image also contains /app/bin/demo-seed for explicitly running the same command; it never runs automatically on application startup. Do not use the older broad db/data/db/dev_data scripts for this new hierarchy fixture.

Optional settings:

Variable Default / purpose
DEMO_SEED_PASSWORD RezinaDemo!2026; set a custom password of 12–72 bytes for every demo account
DEMO_VIDEO_URL Public Big Buck Bunny sample clip for testing playback; replace with your own media URL for realistic lesson videos
DEMO_TEST_DB_URL Disposable, fully migrated PostgreSQL database used only by the opt-in integration test

The supplied videos are playback fixtures, not instructional recordings for the lesson subjects. A local SVG course cover is included in the backend image.

Demo accounts

All accounts use RezinaDemo!2026 unless DEMO_SEED_PASSWORD is set.

Email Role Login endpoint Expected access
superadmin@demo.rezina.test SUPER_ADMIN POST /api/v1/admin/team/login Full staff permissions, including team invitations
admin@demo.rezina.test ADMIN POST /api/v1/admin/team/login Administrative permissions under existing role rules
contentmanager@demo.rezina.test CONTENT_MANAGER POST /api/v1/admin/team/login Content management permissions and restricted admin navigation
student@demo.rezina.test STUDENT POST /api/v1/auth/customer-login Unsubscribed learner; verifies premium restrictions
premium@demo.rezina.test STUDENT POST /api/v1/auth/customer-login 30-day Education subscription, refreshed on seed rerun
openlearner@demo.rezina.test OPEN_LEARNER POST /api/v1/auth/customer-login Existing unrestricted learner access rules

Both login endpoints accept {"email":"...","password":"..."}. Staff sign in through the admin web app. Customer accounts use the customer API or learning app; they do not sign in through the staff form. Accounts are active, email verified, and use bcrypt password hashes compatible with the real login paths. No email delivery or invitation acceptance is required for these fixtures.

These cover all currently assignable staff roles and both customer learner roles. Legacy names such as Instructor, Support Agent, Finance, HR, and Analyst are not seeded as team accounts: the current database and team service allow only Super Admin, Admin, and Content Manager. The seeder does not change role restrictions or grant every role administrator permissions. Standard RBAC seeds are applied; restart a running backend after seeding so its permission cache reloads.

Included learning data and reruns

  • Everyday English: 2 chapters, 6 lessons, 2 quizzes; free course.
  • Workplace Communication: 2 chapters, 6 lessons, 2 quizzes; premium course.
  • Digital Skills Essentials: 2 chapters, 6 lessons, 2 quizzes; free course.
  • Each quiz contains 3 published multiple-choice questions with correct answers.
  • One unpublished course verifies that public discovery hides drafts.
  • One inactive demo subscription plan provides the premium test account access without appearing as a purchasable production plan.

The fixture runs in one transaction under an advisory lock. It uses generated IDs and the demo_seed_entities ownership map rather than fixed IDs or table truncation. Reruns reuse existing content, preserve edits to it, reset the six demo account passwords/statuses to the configured test credentials, and refresh the seed-owned premium subscription. Existing unrelated accounts and learning content are not deleted. Keep these fixtures in a separate pre-production database; this command is not part of production migration or startup.

Verification

go test ./internal/demoseed ./internal/services/examprep ./internal/web_server/... ./internal/apidocs/...

For the database-backed seed and catalog test, use a disposable migrated database:

$env:DEMO_TEST_DB_URL = '<disposable migrated PostgreSQL URL>'
go test ./internal/demoseed -run TestDemoSeedAndPublicCatalogIntegration -count=1 -v

That test writes demo data, runs the seed twice, checks login password hashes, and verifies unpublished-course/descendant filtering. It is skipped unless DEMO_TEST_DB_URL is explicitly provided and never reads application DB_URL. In RezinaLMS-Admin, run npm run test:learning and npm run build.