feat(backend): implement BullMQ background worker queue for AI feedback (#317)#347
Open
Diwakar-odds wants to merge 1 commit into
Open
feat(backend): implement BullMQ background worker queue for AI feedback (#317)#347Diwakar-odds wants to merge 1 commit into
Diwakar-odds wants to merge 1 commit into
Conversation
Author
|
Hi maintainers, could you please review this PR? ECSoC26 Contribution Analysis & Label Request: Please add the \ECSoC26\ label (if not automatically applied), along with \Level 3\ and \good-backend\ to accurately reflect the work done. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #317.
What is this PR doing?
This PR introduces BullMQ and IORedis as a background worker queue for processing Google Gemini API calls. This architectural shift prevents HTTP timeout errors on the main Express server by offloading heavy AI operations to a background queue. The API now returns an immediate
jobIdfor the client to poll, allowing scalable asynchronous handling.How was it implemented?
ai-jobs) with exponential backoff retries.aiWorker.js). The worker maps job names (likechat,generate-questions) to specific processor functions.jobId./api/jobs/:jobIdendpoint to allow clients to poll for task completion.Files Changed
backend/package.json&package-lock.json: Addedbullmqandioredis.backend/config/queue.js(NEW): Initializes theai-jobsqueue and Redis connection.backend/workers/aiWorker.js(NEW): Contains the BullMQ worker processing logic.backend/controllers/aiController.js: RefactoredgenerateInterviewQuestions,generateConceptExplanation, andgenerateInterviewTipsto add jobs to the queue.backend/routes/aiRoutes.js: Refactored/generatechat route to add jobs to the queue.backend/routes/jobRoutes.js(NEW): Added GET endpoint for polling job status and results.backend/server.js: Mounted/api/jobsrouter and required the background worker.ECSoC26 Contribution Analysis
According to the ECSoC '26 points system, I request the maintainers to evaluate this PR based on the following:
good-backend(+50 XP) label as it solves a critical backend scalability issue (HTTP timeouts during long Gemini response times).Please review and add the
ECSoC26label, and explicitly consider addingLevel 3andgood-backendbased on this analysis.