# reimagined/resolve architecture

> Architecture diagram of the GitHub repository reimagined/resolve, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reimagined/resolve
- Repository: https://github.com/reimagined/resolve

## Overview

##### Main Components
- Client Layer – which primarily uses React (and optionally Redux) to interact with the back-end. This is where UI components, containers, and client-specific logic reside.
- Command & Query Handling – the server side distinguishes between the Command part (handling writes, invoking aggregates and sagas) and the Query part (handling read models).
- Domain/Business Logic – represented by aggregates (DDD) and sagas for side-effects and process management. The core business rules are implemented here.
- Event Sourcing Infrastructure – central to the framework, this includes event stores (and its various adapters such as eventstore-base, eventstore-lite, as well as adapters for MySQL, PostgreSQL, etc.), which store events as the source of truth.
- Read Model Builders – components that project events into queryable read models; these may have corresponding resolvers, projections, and connectors.
- Runtime Adapters and Modules – these are contained in the “packages/runtime” and “packages/modules” directories. They include adapters for external services (monitoring adapters, readmodel adapters, replicators, etc.), application scaffolding (create-resolve-app), and configurable pieces that integrate with different ecosystems.
- Tools and Scripts – available in “packages/tools” and “internal” directories, which help with building, testing, managing configurations, and working in a monorepo environment.

##### Out the Relationships and Data Flow
- Within the server, clearly separate and show:
– A Command Side: routes incoming commands to aggregates and triggers sagas.
– An Event Store: acts as the event-sourced backbone where events are recorded.
– A Query Side: shows how events are processed into read models, which are then served back to the client.
- Where integrations occur – such as authentication, authorization, and module extensions for additional functionality (e.g., modules for comments, administration, replication, uploading).

##### Architectural Patterns and Design Principles
- Event Sourcing – Use a central component to illustrate how events are stored and replayed to build state, instead of directly storing state changes.
- Modular and Extensible Design – Emphasize that the “modules” and “runtime adapters” sections allow replacing or enhancing parts of the system.
- Functional and Declarative Programming Model – While not depicted by specific symbols, note that the implementation style is functional (pure functions, immutability) throughout the architecture.

##### Relevant Technologies, Frameworks, and Libraries
- Mention React and Redux on the front end.
- Node.js as the runtime environment.
- Use of TypeScript (in many examples and templates) alongside plain JavaScript.
- Build and configuration tools (webpack, Babel, ESLint, Prettier) and continuous integration (GitHub workflows).
- Various adapters (eventstore adapters, monitoring adapters, read model adapters, etc.) and how they plug into a central runtime.

##### Elements
– A third style for adapter/integration components.
- Annotations or legends that explain the CQRS, DDD, and event sourcing patterns within the system.

##### Additional Recommendations
- Be detailed – the file tree shows dozens of examples, templates, and modules; however, focus on the core architectural pillars to avoid clutter.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer (React/Redux)"
        C1["Client App"]:::client
        C2["Client Example"]:::client
    end

    subgraph "Server Layer"
        subgraph "Command & Query Handling"
            CQ1["Command Actions & Sagas"]:::server
            CQ2["Runtime Handlers"]:::server
        end
        subgraph "Domain/Business Logic"
            DB1["Aggregates"]:::business
            DB2["Sagas"]:::business
        end
        subgraph "Event Sourcing & Read Models"
            ES["Event Store Adapters"]:::adapters
            subgraph "Read Model Builders"
                RM1["Read Model Builders"]:::readmodel
                RM2["View Model Integration"]:::readmodel
            end
        end
        subgraph "Runtime Adapters & Modules"
            RA1["Runtime Adapters"]:::runtime
            RA2["Modules"]:::runtime
        end
        subgraph "Peripheral Tools"
            T1["Tools & Scripts"]:::tools
            T2["Internal Scripts"]:::tools
        end
    end

    C1 --> CQ1
    C1 --> CQ2
    C2 --> CQ1
    C2 --> CQ2

    CQ1 --> DB1
    CQ1 --> DB2
    CQ2 --> DB1
    CQ2 --> DB2

    DB1 --> ES
    DB2 --> ES

    ES --> RM1
    ES --> RM2

    RM1 --> C1
    RM2 --> C2

    RA2 --> CQ1
    RA2 --> CQ2
    RA1 --> DB1
    RA1 --> ES

    T1 -.-> DB1
    T2 -.-> DB2

    classDef client fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef server fill:#F08080,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef adapters fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef readmodel fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef runtime fill:#9370DB,stroke:#000,stroke-width:2px;
    classDef tools fill:#D3D3D3,stroke:#000,stroke-width:2px;

    click C1 "https://github.com/reimagined/resolve/tree/dev/packages/core/client"
    click C2 "https://github.com/reimagined/resolve/tree/dev/templates/js/react/client"
    click CQ1 "https://github.com/reimagined/resolve/tree/dev/packages/core/redux/src/command"
    click CQ2 "https://github.com/reimagined/resolve/tree/dev/packages/runtime/runtimes/runtime-base/src/handlers"
    click DB1 "https://github.com/reimagined/resolve/tree/dev/packages/core/core/src/aggregate"
    click DB2 "https://github.com/reimagined/resolve/tree/dev/packages/core/core/src/saga"
    click ES "https://github.com/reimagined/resolve/tree/dev/packages/runtime/adapters/eventstore-adapters"
    click RM1 "https://github.com/reimagined/resolve/tree/dev/packages/core/core/src/read-model"
    click RM2 "https://github.com/reimagined/resolve/tree/dev/packages/core/core/src/view-model"
    click RA1 "https://github.com/reimagined/resolve/tree/dev/packages/runtime"
    click RA2 "https://github.com/reimagined/resolve/tree/dev/packages/modules"
    click T1 "https://github.com/reimagined/resolve/tree/dev/packages/tools/scripts"
    click T2 "https://github.com/reimagined/resolve/tree/dev/internal"
```
