Notification Engine using Elixir

Hi Everyone,

I am new to Elixir (read the first seven chapters of Elixir in Action and completed some exercises). Programming in Elixir is certainly joyful :-):slightly_smiling_face: Am working in the blockchain space and I need to develop a notification engine. Since this is my first time designing this kind of a system, I need some advice please. The requirement is as follows:

  1. Whenever a transaction is done on a blockchain, like Hyperledger Fabric (HLF), an event can be emitted. In my specific case, the event is a JSON with multiple fields.

  2. HLF has a nodejs SDK which provides the functionality to listen to these events.

  3. These events have to be sent to a notification engine which can do things like below:

a. If an event has been generated with ‘quantity’ > 1000, then notify the ‘supplier’.
b. In a 24 hour window, how many orders have been shipped to me; notify the ‘receiver’.
c. In a 5 minute window, do something based on a ‘field’ or 'fields’ in the event JSON; notify a particular ‘person’ which is mentioned in the event JSON.

The basic design in my mind is below:

  1. Run one server per notification type.
    2.Another server which manages all the notification servers. Basically, this server will maintain a map between the notification type and the notification server pid. This server will also receive the events from the nodejs HLF sdk.

Is this design reasonable? Another question I have is that the notifications have to be persisted as well. Should the database writes happen in a separate process/ task? Lastly, is ther ea good way to implement the notion of a time window in Elixir? Looking forward to some guidance. Thank you!