https://github.com/ralphv/gallifrey-rules-sample
A minimal sample application utilizing gallifrey-rules
https://github.com/ralphv/gallifrey-rules-sample
Last synced: about 1 month ago
JSON representation
A minimal sample application utilizing gallifrey-rules
- Host: GitHub
- URL: https://github.com/ralphv/gallifrey-rules-sample
- Owner: ralphv
- Created: 2024-08-09T03:29:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-19T21:03:06.000Z (almost 2 years ago)
- Last Synced: 2025-10-10T17:08:13.706Z (10 months ago)
- Language: TypeScript
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Gallifrey Rules Sample
A modern robust framework for handling real-time events
## What is it
Gallifrey Rules Sample is a sample application using the library [gallifrey-rules](https://github.com/ralphv/gallifrey-rules)
This sample application use case does the following:
1. Listen to a kafka topic called `new-orders`
2. Translate the message into a gallifrey-rules event using the event dispatcher [new-order-dispatcher](https://github.com/ralphv/gallifrey-rules-sample/blob/main/src/modules/providers/NewOrdersDispatcher.ts)
3. Runs the **rule** [notify-customer-new-order-rule](https://github.com/ralphv/gallifrey-rules-sample/blob/main/src/modules/plugins/rules/NotifyCustomerNewOrderRule.ts)
4. The **rule** will call the **data object** [customer-info-data-object](https://github.com/ralphv/gallifrey-rules-sample/blob/main/src/modules/plugins/data-objects/CustomerInfoDataObject.ts) to get customer info, prepare an email
and then use the **action** [send-email-action](https://github.com/ralphv/gallifrey-rules-sample/blob/main/src/modules/plugins/actions/SendEmailAction.ts) to email the customer that his new order was received.
### Getting started
This will install modules, build and start off the application locally.
```shell
npm start
```
`Note: this will fail because of missing environment variables and this is expected`
To build your application docker image `gallifrey-rules-sample`
### Building docker image
```shell
npm run docker-build
```
To start your docker image
```shell
docker run --rm -it gallifrey-rules-sample
```
### Test it all together
```shell
docker compose up -d
```
This will start a kafka server and your application image, once running, you can call
```shell
npm run produce-message
```
To send a message into the kafka topic.
The sample application should consume it nicely, check the logs using
```shell
docker logs gallifrey-rules-sample -f
```
You should be able to see in the logs at least
```
Email sent to: "Doctor Who"
----------------------------------------------------------
Hello Doctor Who
Thank you so much for your recent order ID: 13
Your order contains the following items:
Name: Children of Earth, Qty: 1, Price: 12.43
Name: Type 40 TT Capsule, Qty: 500, Price: 26
Have a great day!
----------------------------------------------------------
```
You can also open [http://localhost:8080](http://localhost:8080) to open kafka ui and produce messages directly from there.