I'm writing a node app which consists of a producer that takes in rest calls and pops them as jobs onto a job queue. Then also a number of worker apps that will consume the messages from the queue and perform their long running tasks. The producer will probably run on a single server, the workers will run (using PM2 to keep them alive and manage the threads) on multiple servers.
I'm after some advise on how best to structure the app, as once deployed there will need to be two apps (producer and consumer) run up on at least one of the servers.
Would it be best to completely separate the components in the project into folders like so...
ProjectRoot
|
+--producer
| +--bin
| +--node_modules
| |--app.js
|
+--consumer
| +--bin
| +--node_modules
| |--app.js
Or can I still use some common components, for instance, bring the node_modules and maybe a common to the project root level? Like so...
ProjectRoot
|
+--node_modules
+--common
+--producer
| +--bin
| |--app.js
|
+--consumer
| +--bin
| |--app.js
I realise this question could be considered subjective/opinion based, but it's best practises I'm after really.