README.md

# ream

[![Package Version](https://img.shields.io/hexpm/v/ream)](https://hex.pm/packages/ream)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/ream/)

REAM is an event-sourcing system.

The REAM server is a simple TCP server that's receiving events from aggregators which are
sending the event and a status update. The idea is:

- The Aggregator receives a command.
- The aggregator validates the command and generates:
    1. One or more events are generated by the aggregator and published into REAM.
    2. A modification in the state is performed in the aggregator and stored in REAM.
- Subscribers, mainly projectors receive the event.
- These subscribers perform a change in the schema and publish changes into projections.

Therefore we have three different but related storage:

- Events. It's getting events in different streams. We can create as many streams as we need.
- Aggregations. It's storing the state for the aggregators based on the last processed event for a specific stream.
- Projections. Stored the projections based on the information provided by the projectors.

The main idea is to provide an easy way for implementing aggregators and projectors to process the data we need in the way we need it.

## Quick start

```sh
gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell
```

## Installation

If available on Hex this package can be added to your Gleam project:

```sh
gleam add ream
```

and its documentation can be found at <https://hexdocs.pm/ream>.

## Architecture and Design

You can check the protocol [here](docs/protocol.md) and how the storage is going to take place [here](docs/storage.md).

## License

Apache License Version 2.0, see [LICENSE](LICENSE)

Copyright 2023 Altenwald

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.