Skip to main content

Datastore / MIT license Discord Docker

pipeline Quality Gate Status Coverage Security Rating Reliability Rating

FAQ - features - tutorials

What's this?

Datastore is a delightful service giving you access to a powerful time machine!

Become a time traveler ๐Ÿง‘โ€๐Ÿš€ now.

Purposeโ€‹

graph LR; alice_1(Joe) --> | update | alice_2(William) --> | update | alice_3(Jack) -.- alice_4(Joe) --> | update | alice_5(Averell) alice_1 --> |restore | alice_4

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.

Did you know?

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.

JSON Schema of the User entity
{
"additionalProperties": true,
"properties": {
"firstname": {
"type": "string",
"description": "Firstname of the user"
}
}
}

๐Ÿช™ 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.0 specification
  • the events are entirely contractualize with JSON Schema and 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โ€‹

With Docker
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
What's next?

Now you can jump to the tutorials to start playing with the Datastore.