Datastore /

Datastore is a delightful service giving you access to a powerful time machine!
Purposeโ
The purpose of this project is to offer a system enabling
easily all the power of Event-Source systems. This project
is strongly opiniated regarding the implementation of this
pattern and will gives you the opportunity to start working
with Event-Source models.
Datastore is a service deployed between your application and a
MongoDb application. You can offboard the Datastore whenever
you want by removing this service and reconnecting your previous
Data layer on the State collections of the MongoDB database.
Benefitsโ
โฑ Historyโ
Every single entity you will handle with the Datastore is
respecting the Event-Source pattern meaning that you have
naturally access to the entire history of any entity available
in your database.
[
{
"created_at": "2022-03-24T09:25:35.790Z",
"type": "CREATED",
"firstname": "Alice",
"version": 0,
"user_id": "623c390fb0f17a0c02c8d815"
},
{
"created_at": "2022-03-29T05:29:11.348Z",
"type": "UPDATED",
"firstname": "Bernard",
"version": 1,
"user_id": "623c390fb0f17a0c02c8d815"
}
]
๐งพ Contractualizationโ
If we think in terms of long term benefits, the very first
benefit of using the Datastore is the contracts you will
write to define precisely your Data.
- User Schema
- User entity
- User Events
{
"additionalProperties": true,
"properties": {
"firstname": {
"type": "string",
"description": "Firstname of the user"
}
}
}
{
"created_at": "2022-03-24T09:25:35.790Z",
"firstname": "Alice",
"updated_at": "2022-03-24T09:25:35.790Z",
"version": 0,
"user_id": "623c390fb0f17a0c02c8d815"
}
[
{
"_id": "623c390fb0f17a0c02c8d816",
"created_at": "2022-03-24T09:25:35.790Z",
"type": "CREATED",
"v": "0_0_0",
"firstname": "Alice",
"version": 0,
"user_id": "623c390fb0f17a0c02c8d815"
}
]
๐ช Standardizationโ
Because Datastore is choosing industry standards such as
JSON Schema1 or OpenAPI 3.02, your models are immediately
available to your entire tech stack:
- the API client can be generated from
OpenAPI 3.0specification - the events are entirely contractualize with
JSON Schemaand can then be used in RabbitMQ 3, Redis 4 or Kafka 5.
Why time traveling is important?โ
Having access to the full history of your data is important in the current days. For sure, you want to address the following use cases:
- know the value of an object in your database at a given date
- restore an object in your database to a given version
available at a specific date - accurately identify changes over time
3 small steps for man before the Stars โจโ
Install Dockerโ
https://docs.docker.com/engine/install/
Deploy MongoDBโ
docker run --name mongo6 -p 27017:27017 mongo:6 mongodb
docker exec -it mongo6 mongo --eval 'rs.initiate({"_id":"rs","members":[{"_id":0,"host":"localhost:27017"}]})'
Start the Datastoreโ
docker run -d --name datastore --network host -e FEATURE_API_ADMIN=true getanthill/datastore:latest
or
git clone git@gitlab.com:getanthill/datastore.git
cd datastore
npm i
TELEMETRY_LOGGER_LEVEL=50 TELEMETRY_LOGGER_JSON=false FEATURE_API_ADMIN=true npm run dev
Now you can jump to the tutorials
to start playing with the Datastore.