Skip to content

Commit

Permalink
Add chat context
Browse files Browse the repository at this point in the history
  • Loading branch information
marein committed Sep 28, 2024
1 parent 219aa36 commit 997daa0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,41 @@ The platform features a modular, reactive, domain-driven backend architecture. E
[context](https://martinfowler.com/bliki/BoundedContext.html) ships as a [module](/src) or
[service](https://github.com/gaming-platform?q=service-) that scales independently by defining its own
resources, such as databases, and communicates via messaging to reduce temporal coupling.
RabbitMQ serves as the primary messaging system, enabling integration between all contexts.

Check out the purpose and architectural decisions of each context in the sections below.

<details>
<summary>Chat</summary>

### Chat

**Purpose**: [Chat](/src/Chat) allows other contexts, like Connect Four, to initiate chats. Authors can list and write messages
in these chats based on their access rights.

**Integration**: Its use cases are exposed via
[messaging](https://www.enterpriseintegrationpatterns.com/patterns/messaging/Messaging.html), utilizing
[request-reply](https://www.enterpriseintegrationpatterns.com/patterns/messaging/RequestReply.html),
with some directly invoked by the Web Interface to reduce network hops and abstractions.
To notify other contexts about what has happened, [Domain Events](https://martinfowler.com/eaaDev/DomainEvent.html)
are stored in a [transactional outbox](https://en.wikipedia.org/wiki/Inbox_and_outbox_pattern) and
later published using
[publish-subscribe](https://www.enterpriseintegrationpatterns.com/patterns/messaging/PublishSubscribeChannel.html).
A list of available messages [can be found here](https://github.com/gaming-platform/api).

**Architecture**: Internally, it uses
[ports and adapters](https://en.wikipedia.org/wiki/Hexagonal_architecture_(software)) to separate business logic
from external systems. A [mediator](https://en.wikipedia.org/wiki/Mediator_pattern) exposes the
[application layer](https://martinfowler.com/eaaCatalog/serviceLayer.html), routing requests to handlers
and handling cross-cutting concerns like validation and transaction management. Business logic is organized using a
[transaction script](https://martinfowler.com/eaaCatalog/transactionScript.html).

**Storage**: MySQL is used to store chats, messages and events (outbox), while Redis enables
[idempotent messaging](https://www.enterpriseintegrationpatterns.com/patterns/messaging/IdempotentReceiver.html)
to ensure that each message is processed exactly once.

**Scalability**: The module is stateless, enabling it to scale horizontally by adding more instances.
Current usage patterns of MySQL don’t require sharding, but chat IDs would be well-suited for partitioning if needed.
</details>

<details>
Expand Down

0 comments on commit 997daa0

Please sign in to comment.