Skip to content

Commit e8c8ca0

Browse files
authored
Feature/#607 (#26)
* Updates as per PR comments. * Story #607 - Update to the README.md. Created the onboarding.md. * Included Architecture and Technologies Overview as requested in the review. * Included new images. * Changed images to png since svg is not displaying correctly. * Updated with additional suggestions as per review.
1 parent 5124735 commit e8c8ca0

File tree

4 files changed

+298
-52
lines changed

4 files changed

+298
-52
lines changed

README.md

Lines changed: 87 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,94 @@
1-
# Notification service
1+
# Central Event Processor Service
2+
[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/central-event-processor.svg?style=flat)](https://github.com/mojaloop/central-event-processor/commits/master)
3+
[![Git Releases](https://img.shields.io/github/release/mojaloop/central-event-processor.svg?style=flat)](https://github.com/mojaloop/central-event-processor/releases)
4+
[![Docker pulls](https://img.shields.io/docker/pulls/mojaloop/central-event-processor.svg?style=flat)](https://hub.docker.com/r/mojaloop/central-event-processor)
5+
[![CircleCI](https://circleci.com/gh/mojaloop/central-event-processor.svg?style=svg)](https://circleci.com/gh/mojaloop/central-event-processor)
6+
7+
The Central Event Processor (CEP) service provides the capability to monitor for a pre-defined/configured set of business rules or patterns such as breaching the threshold set for a particular limit (or Net Debit Cap) or a Position Adjustment based on a Settlement.
8+
9+
In the current iteration, the rules are set to monitor for three criteria:
10+
11+
1. Breaching of a threshold on the Limit of Net Debit Cap (which may be set as part of on-boarding)
12+
2. Adjustment of the limit - Net Debit Cap
13+
3. Adjust of position based on a Settlement.
14+
15+
The CEP can then be integrated with a notifier service, to send out notifications or alerts. In this instance, it integrates with the email-notifier to send out alerts based on the aforementioned criteria.
216

317
## Contents
4-
<!-- vscode-markdown-toc -->
5-
* 1. [Stories](#Stories)
6-
* 2. [Tasks](#Tasks)
7-
* 3. [Reacts on](#Reactson)
8-
* 4. [Used technologies](#Usedtechnologies)
9-
* 5. [Local storage](#Localstorage)
10-
* 6. [Architecture overview](#Architectureoverview)
11-
* 7. [General process overview](#Generalprocessoverview)
12-
* 7.1. [enums](#enums)
13-
* 7.2. [Rules](#Rules)
14-
* 7.3. [Config](#Config)
15-
* 8. [Limit Adjustment Rules flow](#LimitAdjustmentRulesflow)
16-
* 9. [Limit Position Threshold Breach flow](#LimitPositionThresholdBreachflow)
17-
* 10. [Actions Agent flow](#ActionsAgentflow)
18-
* 11. [Scheduler flow](#Schedulerflow)
19-
* 12. [Notifier flow (separate service)](#Notifierflowseparateservice)
20-
21-
<!-- vscode-markdown-toc-config
22-
numbering=true
23-
autoSave=true
24-
/vscode-markdown-toc-config -->
25-
<!-- /vscode-markdown-toc -->
26-
27-
## 1. <a name='Stories'></a>Stories
28-
Central Event Processor
29-
=======================
30-
31-
stories
32-
-------
18+
* [Deployment](#1-deployment)
19+
* [Notes](#2-notes)
20+
* [Tasks](#3-tasks)
21+
* [Reacts on](#4-reacts-on)
22+
* [Used technologies](#5-used-technologies)
23+
* [Local storage](#6-local-storage)
24+
* [Architecture overview](#7-architecture-overview)
25+
* [Architecture and Technologies Overview](#8-architecture-and-technologies-overview)
26+
* [General process overview](#9-general-process-overview)
27+
* [enums](#91-enums)
28+
* [Rules](#92-rules)
29+
* [Config](#93-config)
30+
* [Limit Adjustment Rules flow](#10-limit-adjustment-rules-flow)
31+
* [Limit Position Threshold Breach flow](#11-limit-position-threshold-breach-flow)
32+
* [Actions Agent flow](#12-actions-agent-flow)
33+
* [Scheduler flow](#13-scheduler-flow)
34+
* [Notifier flow (separate service)](#14-notifier-flow-separate-service)
35+
36+
## 1. Deployment
37+
See the [onboarding guide](onboarding.md) for running the service locally.
38+
39+
## 2. Notes
3340

3441
* [#517 - Notification for changes to NetDebitCap or Position adjustments](https://github.com/mojaloop/project/issues/517)
3542
* [#518 - Notification for approaching Net Debit Cap Threshold](https://github.com/mojaloop/project/issues/518)
3643

37-
## 2. <a name='Tasks'></a>Tasks
44+
## 3. Tasks
3845
* send notifications when current position breaches the limit threshold value after a successful transfer was commited
3946
* send notifications when the limit was adjusted
4047
* make it extendable and flexible
4148

42-
## 3. <a name='Reactson'></a>Reacts on
49+
## 4. Reacts on
4350
* messages consumed from the notification topic
4451
* data read from the central-ledger API
4552

46-
## 4. <a name='Usedtechnologies'></a>Used technologies
53+
## 5. Used technologies
4754
* [RxJS](https://github.com/ReactiveX/rxjs)
4855
* [json-rule-engine](https://github.com/cachecontrol/json-rules-engine)
4956
* [mongoose](https://github.com/Automattic/mongoose)
5057

51-
## 5. <a name='Localstorage'></a>Local storage
58+
## 6. Local storage
5259
* Mongo DB
5360
* Mongoose is used for schema validations and ORM functions
5461
* to set up connection the following environmental variables might be used: `CEP_DATABASE_URI` and `CEP_DATABASE_NAME`
55-
* full database documentation can be found [here](docs/database/Mojaloop_central-notifications_Db_ver1.0.html)
62+
* full database documentation can be found at [Mojaloop central notifications Database](docs/database/Mojaloop_central-notifications_Db_ver1.0.html)
63+
64+
## 7. Architecture overview
5665

57-
## 6. <a name='Architectureoverview'></a>Architecture overview
5866
![architecture](docs/images/1.png)
5967

68+
[Architecture Overview](docs/images/1.png)
6069

6170
This is standalone service which is connected to Kafka Notification topic into the mojaloop environemnt and monitors the topic for messages which match certain rules and takes actions accordingly.
6271

63-
The service is developed using [RxJS](https://github.com/ReactiveX/rxjs) for observing the system and acting accordingly. The decissions for actions are taken by the [json-rule-engine](https://github.com/cachecontrol/json-rules-engine).
72+
The service is developed using [RxJS](https://github.com/ReactiveX/rxjs) for observing the system and acting accordingly. The decisions for actions are taken by the [json-rule-engine](https://github.com/cachecontrol/json-rules-engine).
73+
74+
## 8. Architecture and Technologies Overview
75+
76+
![ArchTechOverview](docs/architechDiagrams/CEPArchTechOverview.png)
77+
78+
[Architecture and Technologies Overview](docs/architechDiagrams/CEPArchTechOverview.svg)
79+
80+
## 9. General process overview
6481

65-
## 7. <a name='Generalprocessoverview'></a>General process overview
6682
![process](docs/images/2.png)
6783

84+
[Process Overview](docs/images/2.png)
85+
6886
The rules validations are triggered upon commited transfers. As soon as a commited transfer notification is produced from the central-ledger to the notification topic, the central-notifications service picks it up, gathers more information, runs few rules validations and acts based on rules engine outcome.
6987

7088
The data for performing rules validation is requested from the central-ledger admin API calls using observables, available [here](src/observables/centralLedgerAPI.js) some mapping and wiring is done through below [enums](src/lib/enum.js) properties:
7189

72-
### 7.1. <a name='enums'></a>enums
73-
```
90+
### 9.1. enums
91+
```javascript
7492
const notificationActionMap = {
7593
NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL: {
7694
enum: 'NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL',
@@ -95,41 +113,58 @@ const limitNotificationMap = {
95113
}
96114
```
97115

98-
### 7.2. <a name='Rules'></a>Rules
116+
### 9.2. Rules
99117
Currently two separate Rules are validated:
100-
1. Limit Adjustment Rule [here](src/observables/rules/ndcAdjustment.js)
101-
2. Limit Position Threshold Breach Rule [here](src/observables/rules/ndcBreach.js)
118+
1. [Limit Adjustment Rule](src/observables/rules/ndcAdjustment.js)
119+
2. [Limit Position Threshold Breach Rule](src/observables/rules/ndcBreach.js)
120+
102121
In the current implementation for each separate rule, an observable has to be created, like the couple above, and configured when and how to trigger it into the [setup](src/setup.js)
103122
The Rules outputs should be chained to common Action Agent.
104123

105-
### 7.3. <a name='Config'></a>Config
124+
### 9.3. Config
125+
126+
The default [config](config/config.json)
106127

107-
The default config is available [here](config/config.json)
108128
To use Environmental Variables for MongoDB URI and database name use:
109129
`CEP_MONGO_URI` and `CEP_MONGO_DATABASE`
110130

111-
## 8. <a name='LimitAdjustmentRulesflow'></a>Limit Adjustment Rules flow
131+
## 10. Limit Adjustment Rules flow
132+
112133
![limitAdjustment](docs/sequenceDiagrams/seq-cep-10.2-adjustment-rule-validation.svg)
113134

135+
[Limit Adjustment Rules flow](docs/sequenceDiagrams/seq-cep-10.2-adjustment-rule-validation.svg)
136+
114137
This rule is triggered on each limit response from the central-ledger admin API.
115138

116139

117-
## 9. <a name='LimitPositionThresholdBreachflow'></a>Limit Position Threshold Breach flow
140+
## 11. Limit Position Threshold Breach flow
141+
118142
![limitPositionThresholdBreach](docs/sequenceDiagrams/seq-cep-10.3-breaching-threshold-percentage-limit.svg)
119143

144+
[Limit Position Threshold Breach flow](docs/sequenceDiagrams/seq-cep-10.3-breaching-threshold-percentage-limit.svg)
145+
120146
This rule is triggered when all data for the participants in the current transfer is received.
121147

122-
## 10. <a name='ActionsAgentflow'></a>Actions Agent flow
148+
## 12. Actions Agent flow
149+
123150
![actionAgent](docs/sequenceDiagrams/seq-cep-10.4-action-flow.svg)
124151

125-
The Action Agent - [here](src/observables/actions) - takes care of action preparation regrding the data from central-ledger admin API and various settings.
152+
[Actions Agent flow](docs/sequenceDiagrams/seq-cep-10.4-action-flow.svg)
153+
154+
The [Action Agent](src/observables/actions) - takes care of action preparation regrding the data from central-ledger admin API and various settings.
155+
156+
## 13. Scheduler flow
126157

127-
## 11. <a name='Schedulerflow'></a>Scheduler flow
128158
![schedulerFlow](docs/sequenceDiagrams/seq-cep-10.5-scheduler-flow.svg)
129159

160+
[Scheduler flow](docs/sequenceDiagrams/seq-cep-10.5-scheduler-flow.svg)
161+
130162
The scheduler coordinates the Action Object that requires to be dispatched. It would typically action a scheduled event that qualifies by insure only the prescribed number of notifications are dispatched within the set time frame defined.
131163

132-
## 12. <a name='Notifierflowseparateservice'></a>Notifier flow (separate service)
164+
## 14. Notifier flow (separate service)
165+
133166
![notifier](docs/images/6.png)
134167

135-
Email notifier service is a separate app, that observes the same topic for messages with field *from* = `SYSTEM`. Its code is available [here](https://github.com/mojaloop/email-notifier)
168+
[Notifier flow](docs/images/6.png)
169+
170+
Email notifier service is a separate app, that observes the same topic for messages with field *from* = `SYSTEM`. Its code is available in the [email-notifier](https://github.com/mojaloop/email-notifier) repository.
58.5 KB
Loading

0 commit comments

Comments
 (0)