Skip to content

Make Pixel bot's document map configurable by admin #1350

@yiilinzhang

Description

@yiilinzhang

Problem

The document map used by the RAG chatbot pipeline is currently hardcoded as a static JSON file at priv/course_documents/document_map.json. Any changes to the document catalogue (adding new lectures, exams, studios, etc.) require a code change and redeployment.

Proposed Solution

Allow admins to upload a CSV file through the admin panel to update the document map dynamically, without needing to modify source code.

Requirements

  • Upload endpoint — Add a new admin API endpoint (e.g. PUT /courses/:course_id/admin/config/pixelbot_document_map) that accepts a CSV file upload.
  • Validation — Validate the uploaded file against the expected schema (id, title, description, doc_type, year, week, s3_key) before persisting. Then convert the CSV into JSON for storage.
  • Storage — Persist the document map to the database (rather than the filesystem) so it survives deployments and is course-scoped.
  • Cache invalidation — Invalidate the persistent_term cache in Cadet.Chatbot.CourseDocuments when a new map is uploaded so the RAG pipeline picks up changes immediately.
  • Frontend upload UI — Update PixelbotConfigPanel to include a file upload control (CSV) alongside the existing read-only document map display.

Relevant Files

  • backend/priv/course_documents/document_map.json — current hardcoded map
  • backend/lib/cadet/chatbot/course_documents.ex — loads and caches the map
  • backend/lib/cadet_web/admin_controllers/admin_courses_controller.ex — existing get_document_map endpoint
  • frontend/src/pages/academy/adminPanel/subcomponents/PixelbotConfigPanel.tsx — admin UI

Accepted Formats

Format Notes
CSV Header row matching the field names above

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions