migrate motia => bullmq - #247
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes the Motia event-driven service and replaces it with BullMQ for background job processing. The change simplifies the architecture by eliminating a separate microservice and consolidates all background job processing within the main backend using Redis-backed queues.
Key Changes:
- Replaced Motia framework with BullMQ for async task processing
- Removed Motia service container from Docker Compose
- Implemented 4 BullMQ workers: page save, image upload, image cleanup, and task reminders
- Added comprehensive documentation for the new BullMQ architecture
Reviewed Changes
Copilot reviewed 52 out of 55 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Removed Motia service from monorepo installation and startup scripts |
| docker-compose.yml | Removed Motia service container and related dependencies |
| backend/package.json | Added BullMQ dependency (v5.63.0) |
| backend/src/config/queue.js | New BullMQ queue configuration with 4 queues (page-save, image-upload, image-cleanup, task-reminder) |
| backend/src/config/schedulers.js | New scheduled jobs configuration for image cleanup (every 6 hours) and task reminders (every 5 minutes) |
| backend/src/workers/*.worker.js | New BullMQ workers replacing Motia event handlers |
| backend/src/controllers/v2/page.controller.js | Updated to use BullMQ queue instead of Motia HTTP calls |
| backend/server.js | Integrated BullMQ initialization and graceful shutdown |
| docs/bullmq-jobs.md | Comprehensive documentation for the new BullMQ architecture |
| motia/** | Entire Motia service directory removed |
| .github/workflows/docker-build.yml | Removed Motia Docker image build job |
Files not reviewed (1)
- backend/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
backend/server.js:1
- Character encoding issue: the environment icon displays as '�' instead of '📍'. This appears to be a regression from the original emoji. Restore the correct emoji character.
/**
backend/server.js:1
- Character encoding issue: the link icon displays as '�' instead of '🔗'. This appears to be a regression from the original emoji. Restore the correct emoji character.
/**
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pageSaveQueue, | ||
| imageUploadQueue, | ||
| imageCleanupQueue, | ||
| taskReminderQueue, |
There was a problem hiding this comment.
The default export contains the initial null values of the queues, not the actual initialized queue instances. When importing from this module, consumers will receive null even after initializeQueues() is called. Remove the queue variables from the default export object or use a getter function to return current values.
| pageSaveQueue, | |
| imageUploadQueue, | |
| imageCleanupQueue, | |
| taskReminderQueue, | |
| // Getter functions to always return the current queue instances | |
| getPageSaveQueue: () => pageSaveQueue, | |
| getImageUploadQueue: () => imageUploadQueue, | |
| getImageCleanupQueue: () => imageCleanupQueue, | |
| getTaskReminderQueue: () => taskReminderQueue, |
|
|
||
| // Update page | ||
| page.pageData = newPageData; | ||
| await page.save(); | ||
|
|
||
| // Handle image reference updates | ||
| const currentImageIds = getContentImageIds(newPageData); |
There was a problem hiding this comment.
Image ID extraction is performed twice on newPageData (lines 45 and 52). The previousImageIds should be extracted from page.pageData before the update, and currentImageIds from newPageData. Cache the currentImageIds result before updating the page to avoid redundant computation.
| // Update page | |
| page.pageData = newPageData; | |
| await page.save(); | |
| // Handle image reference updates | |
| const currentImageIds = getContentImageIds(newPageData); | |
| const currentImageIds = getContentImageIds(newPageData); | |
| // Update page | |
| page.pageData = newPageData; | |
| await page.save(); | |
| // Handle image reference updates |
| // import motiaRoutes from './motia.routes.js'; | ||
|
|
There was a problem hiding this comment.
Remove commented-out import statement for motiaRoutes. Since the Motia service has been completely removed, this commented code should be deleted rather than left in place.
| // import motiaRoutes from './motia.routes.js'; |
| // router.use('/motia', motiaRoutes); | ||
|
|
There was a problem hiding this comment.
Remove commented-out route registration for motiaRoutes. Since the Motia service has been completely removed, this commented code should be deleted rather than left in place.
| // router.use('/motia', motiaRoutes); |
No description provided.