I began by setting up the monorepo structure using Turborepo. Next, I developed the Next.js web app, focusing on creating the first video template.
After that, I implemented the Discord bot, which takes inputs from the user, validates them, and sends them to the rendering service via an HTTP request. This led me to the next step: building the rendering service.
Rendering a video has two steps: first, selecting the template that the user has chosen, and then applying the user input to the template before starting the rendering process. To inform the user of the rendering progress, I used RabbitMQ to communicate with the Discord bot (where the request originates). After the Discord bot sends the render request, it begins consuming messages from the message broker. These messages contain the progress of the render, which comes from the rendering service.
The web app follows the same process as the Discord bots it takes the input and sends it to the rendering service. but, instead of consuming progress messages from the message broker, I implemented polling since I cannot use a message broker on the client side. Polling involves sending HTTP GET requests to the rendering service, which returns the progress as a response.
Managing Multiple Users: Rendering is time-consuming and resource-intensive, and since my server doesn't auto-scale, this is where queues come into play. When a request comes to the rendering service, I send it to the queue and store the user's queue position in Redis because RabbitMQ doesn't provide user positions. Now, when a request comes to the rendering service, I put it in the queue. If the queue is clear, I start updating the user with the rendering progress. If the user is in the queue, I update them with their current position.