Skip to content

[Bug]: Confusion alert API endpoint has no rate limiting #1065

Description

@Shreya-nipunge

Bug Description

The confusion alert endpoint (src/app/api/confusion/route.ts) allows authenticated students to submit confusion alerts without any rate limiting or deduplication.

Repeated requests can create many duplicate confusion alerts, causing inaccurate teacher dashboard data and unnecessary database load.

Steps to Reproduce

  1. Join a classroom as a student.
  2. Send repeated POST requests to /api/confusion with a valid classroom ID and topic.
  3. Submit many requests within a short period (for example, 100 requests in 1 second).
  4. Open the teacher dashboard.
  5. Observe duplicate confusion alerts being displayed.
  6. Check the confusionAlerts table and observe multiple duplicate records.

Expected Behavior

The endpoint should limit repeated confusion alerts from the same user and classroom.

For example:

  • Allow one alert per user/classroom within a short time window.
  • Deduplicate repeated alerts with the same topic.

Actual Behavior

The endpoint accepts unlimited confusion alert submissions, allowing duplicate records and inaccurate dashboard counts.

Screenshots

N/A

Environment

  • OS: Any
  • Browser: Any modern browser
  • Node.js version: Any supported version
  • Screen size: Desktop/Mobile

Console Errors

No console errors.

Additional Context

Adding rate limiting and deduplication would improve dashboard accuracy and reduce unnecessary database writes.

Metadata

Metadata

Labels

backendAPI routes, database, server logicgssoc'26GSSoC program issuelevel:intermediateIntermediate level tasktype:bugBug fix

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions