# reactioncommerce/reaction architecture

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

- Interactive diagram: https://gitdiagram.com/reactioncommerce/reaction
- Repository: https://github.com/reactioncommerce/reaction

## Overview

##### Project type and purpose
- This is a monorepo for Mailchimp Open Commerce (formerly Reaction Commerce): an API-first, headless commerce platform.
- Built with Node.js, MongoDB and GraphQL.
- Uses a plugin architecture: a core API plus dozens of domain-specific plugins (accounts, carts, orders, payments, etc).
- Provides both API (apps/reaction) and example frontends (apps/meteor-blaze-app).

##### File structure
- Top level: configuration (Docker, CircleCI, ESLint, pnpm-workspace), root package.json.
- apps/meteor-blaze-app: sample Meteor Blaze storefront.
- apps/reaction: the GraphQL API server, uses .env, Dockerfile, src/index.js, schema and plugin loader.
- packages/api-core: the heart of the GraphQL/Apollo server and plugin loader.
- packages/api-plugin-*: each subfolder is a self-contained GraphQL plugin (accounts, carts, catalogs, discounts, etc).
- packages/*: utility libraries (api-utils, file-collections, logger, random, etc).
- docker-compose*.yml: dev & CI orchestration.
- pnpm-workspace.yaml: monorepo package management.

##### README for additional insights
- Confirms Node.js + GraphQL + MongoDB stack.
- Plugin-based, multi-tenant, scalable.
- CLI driven (“reaction” CLI to scaffold and run API, admin, storefront).
- Uses changesets for versioning and CircleCI for automation.

##### Essential details
- Monorepo boundary and workspace manager (pnpm).
- Dynamic plugin loading at startup in the API server.
- CI/CD flow: GitHub → CircleCI → npm registry.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Monorepo Configuration"
        PNPM["pnpm-workspace.yaml"]:::infra
        PKG["package.json"]:::infra
        CIRCLE[".circleci/config.yml"]:::infra
        DCALL["docker-compose*.yml"]:::infra
    end

    subgraph "Developer Workstation"
        CLI["Reaction CLI"]:::infra
    end

    CLI -->|"runs workspace"| PNPM
    CLI -->|"reads manifest"| PKG
    CLI -->|"executes"| BUILD["Docker Compose"]:::infra

    subgraph "Containers"
        subgraph "API Container"
            ApiCore["GraphQL API Server Core"]:::core
            Loader["Plugin Loader"]:::core
            Registry["plugins.json"]:::core
            ApiCore --> Loader
            Loader -->|"reads manifest"| Registry
        end
        subgraph "MongoDB Replica Set"
            MongoDB["MongoDB"]:::infra
        end
        subgraph "Optional Frontend"
            Blaze["Meteor Blaze Storefront"]:::frontend
        end
    end

    BUILD -->|"launches container"| ApiCore
    BUILD -->|"launches container"| MongoDB
    BUILD -->|"launches container"| Blaze

    subgraph "Domain Plugins"
        Accounts["accounts"]:::plugin
        Carts["carts"]:::plugin
        Orders["orders"]:::plugin
        Payments["payments"]:::plugin
        Catalogs["catalogs"]:::plugin
        Discounts["discounts & codes"]:::plugin
    end

    Loader -->|"imports"| Accounts
    Loader -->|"imports"| Carts
    Loader -->|"imports"| Orders
    Loader -->|"imports"| Payments
    Loader -->|"imports"| Catalogs
    Loader -->|"imports"| Discounts

    subgraph "Utilities"
        Utils["api-utils"]:::core
        Logger["logger"]:::core
        Random["random"]:::core
    end

    Utils --> ApiCore
    Logger --> ApiCore
    Random --> ApiCore

    subgraph "External Services"
        SMTP["SMTP / Email"]:::infra
        FileStore["File Storage"]:::infra
        PaymentGW["Payment Gateway"]:::infra
        TaxSvc["Tax Service"]:::infra
    end

    ApiCore -->|"GraphQL HTTP"| Blaze
    Blaze -->|"GraphQL HTTP"| ApiCore
    ApiCore -->|"MongoDB Protocol"| MongoDB
    ApiCore -->|"API Calls"| SMTP
    ApiCore -->|"API Calls"| FileStore
    ApiCore -->|"API Calls"| PaymentGW
    ApiCore -->|"API Calls"| TaxSvc

    subgraph "CI/CD Pipeline"
        GH["GitHub Workflows"]:::infra
        CI["CircleCI"]:::infra
        NPM["npm Registry"]:::infra
    end

    GH --> CI
    CI -->|"publish packages"| NPM

    click PNPM "https://github.com/reactioncommerce/reaction/blob/trunk/pnpm-workspace.yaml"
    click PKG "https://github.com/reactioncommerce/reaction/blob/trunk/package.json"
    click CIRCLE "https://github.com/reactioncommerce/reaction/blob/trunk/.circleci/config.yml"
    click DCALL "https://github.com/reactioncommerce/reaction/blob/trunk/docker-compose.yml"
    click CLI "https://github.com/reactioncommerce/reaction/tree/trunk/apps/reaction/bin/"
    click BUILD "https://github.com/reactioncommerce/reaction/blob/trunk/docker-compose.yml"
    click ApiCore "https://github.com/reactioncommerce/reaction/blob/trunk/packages/api-core/src/ReactionAPICore.js"
    click Loader "https://github.com/reactioncommerce/reaction/blob/trunk/packages/api-core/src/importPluginsJSONFile.js"
    click Registry "https://github.com/reactioncommerce/reaction/blob/trunk/apps/reaction/plugins.json"
    click Blaze "https://github.com/reactioncommerce/reaction/tree/trunk/apps/meteor-blaze-app/"
    click Accounts "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-accounts/"
    click Carts "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-carts/"
    click Orders "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-orders/"
    click Payments "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-payments/"
    click Catalogs "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-catalogs/"
    click Discounts "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-plugin-discounts/"
    click Utils "https://github.com/reactioncommerce/reaction/tree/trunk/packages/api-utils/"
    click Logger "https://github.com/reactioncommerce/reaction/tree/trunk/packages/logger/"
    click Random "https://github.com/reactioncommerce/reaction/tree/trunk/packages/random/"
    click GH "https://github.com/reactioncommerce/reaction/tree/trunk/.github/workflows/"
    click CI "https://github.com/reactioncommerce/reaction/blob/trunk/.circleci/config.yml"
    click NPM "https://github.com/reactioncommerce/reaction/tree/trunk/.changeset/"

    classDef core fill:#bbdefb,stroke:#1976d2,stroke-width:2px
    classDef plugin fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
    classDef frontend fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px
    classDef infra fill:#eeeeee,stroke:#424242,stroke-width:2px
```
