• Stars
    star
    606
  • Rank 73,545 (Top 2 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example Storefront is Reaction Commerce’s headless ecommerce storefront - Next.js, GraphQL, React. Built using Apollo Client and the commerce-focused React UI components provided in the Storefront Component Library (reactioncommerce/reaction-component-library). It connects with Reaction backend with the GraphQL API.

Example Storefront

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, and GraphQL. It plays nicely with npm, Docker and Kubernetes.

This Example Storefront is to serve as a reference on how to implement a web based storefront using the Reaction Commerce GraphQL API. You can fork this project as a jumping off point or create your own custom experience using your preferred client-side technology. While we believe our example storefront is full-featured enough to use in production, it may be missing features your shop requires at this time.

Features

Mailchimp Open Commerce comes with a robust set of core commerce capabilities right out of the box. And since anything in our codebase can be extended, overwritten, or installed as a package, you may also customize anything on our platform.

This example storefront is built with Next.js, React, GraphQL, and Apollo Client

Getting Started

Follow the Quick Start Guide to install and run all the services necessary to run the storefront:

Directory: Service URL
reaction: GraphQL API localhost:3000/graphql
reaction-admin: Reaction Admin localhost:4080
reaction: MongoDB localhost:27017
example-storefront: Storefront localhost:4000

Note: The storefront has redirects so that if you open http://localhost:4000/graphql, you'll be redirected to the GraphQL Playground.

Configuration

Set up Stripe

When running the storefront and Reaction for the first time, you will need to configure Stripe payment processing and shipping options to test a complete order checkout flow. After signing up for a Stripe API key, follow these steps:

  1. Add public Stripe API key (STRIPE_PUBLIC_API_KEY) to .env.
  2. Open the Reaction Admin app, at http://localhost:4080. Log in as an Admin user.
  3. Open Payments: Enable Stripe by checking the box. Add a Stripe secret key and public key.
  4. Open Shipping: Enable flat-rate shipping by checking the box. Enable at least one type of flat-rate shipping by clicking on the option in the table and checking the box.

Set up Analytics event tracking

Read the docs for setting up Segment or a custom analytics tracker

Documentation

Development

The Reaction Platform runs the storefront with Docker, so you will have to use Docker commands to view logs, run commands inside the container and more. To run commands specifically for the storefront, make sure to change directories into the example-storefront directory within the reaction-platform repository:

cd example-storefront

Build and run in development mode with logs

Create a symbolic link to use the development Docker image:

ln -s docker-compose.dev.yml docker-compose.override.yml

If running for the first time or environment variables in .env.example have changed execute the command below to update environment variables.

./bin/setup

Start the storefront by executing:

docker-compose up -d && docker-compose logs -f

Run in development against a production API

Change the INTERNAL_GRAPHQL_URL in .env to the production API URL. The URL should end in /graphql, like: https://my-website.com/graphql. Save the .env file and restart the application with:

docker-compose run --rm --service-ports web yarn start

Run commands in container

docker-compose run --rm web [command]

Run any command inside a Docker container and then remove the container. Use this to run any tooling operations. Remember your project directory will be mounted and things will usually just work. See Yarn section below for more examples.

Run tests in container

Run tests locally

docker-compose run --rm web yarn test

Run tests locally without cache (this can be helpful if changes aren't showing up)

docker-compose run --rm web yarn test --no-cache

To run Snyk security tests (this will run tests in the same way as CI)

docker-compose run --rm web sh -c "cp package.json ../ && cp .snyk ../ && cd .. && snyk auth && snyk test"

To run ESLint

docker-compose run --rm web eslint src

Debugging the server with Chrome DevTools

You can use the Google Chrome DevTools to debug the code running in the Node.js application server while it's running inside Docker.

  • run docker-compose run --rm --publish 9229:9229 --publish 4000:4000 -e NODE_ENV=development web node --inspect=0.0.0.0:9229 ./src/server.js
  • Open Chrome and browse to chrome://inspect. Find the process under Remote Target and click inspect.

Yarn Commands

Yarn & NPM should run inside the Docker container. We've taken steps to ensure that the node_modules are placed into a cacheable location. If you run Yarn locally, the node_modules are written directly to the project directory and take precedence over those from the Docker build. Yarn Add

docker-compose run --rm web yarn add --dev [package]

Yarn Install

⚠️ Always rebuild the image and start a new container after modifying yarn.lock or Dockerfile!

docker-compose run --rm web yarn install
docker-compose down --rmi local
docker-compose up -d --build

Testing component library in the storefront

Sometimes we need to test the Example Storefront Component Library components in the context of the storefront. Unfortunately, there isn't an easy wasy to do this within our Docker containers, so we need to run the storefront outside of docker.

  1. cd to your local reaction-component-library repo.
  2. Git checkout the proper branch that you want to link
  3. cd into the package folder of this repo, and run the command yarn install followed by yarn build
  4. After the build is done, cd into the new dist folder it just built and run yarn link to allow the library to be installed into the storefront. This will link @reactioncommerce/components
  5. Inside the example-storefront repo, temporarily rename your .yarnrc file to anything else (i.e. .yarnrc-temp)
  6. Run yarn install and then the command yarn link "@reactioncommerce/components" to set the local version as an override of the published npm version
  7. Inside your .env file, change INTERNAL_GRAPHQL_URL to equal http://localhost:3000/graphql, the same as the EXTERNAL_GRAPHQL_URL
  8. Start the storefront locally by running the command export $(cat .env | xargs) && yarn dev
  9. Your storefront should now be running at localhost:4000
    • If you see errors about not being able to find peer dependency packages, that seems to be an issues with yarn linking. You can just temporarily yarn add each of those packages in the component library package/dist folder. (This folder is gitignored anyway.)
  10. After your changes are tested, shut down the storefront by running the command CTRL+C
  11. Run yarn unlink "@reactioncommerce/components" in the storefront repo folder
  12. cd to the package/dist folder of the reaction-component-library repo. Run the command yarn unlink to unlink the local version of the component library
  13. Undo the renaming of your .yarnrc file
  14. Undo the URL change inside your .env file

Clean up containers

Stop, and retain containers:

docker-compose stop

Stop, and remove containers:

docker-compose down

Stop, and remove containers, volumes and built images:

docker-compose down -v --rmi local

Build and run the production app locally

Sometimes it is helpful during development to make a production build of the app and run that locally.

Run this command to build a Docker image with the production build of the app in it:

docker build --network=host -t  reactioncommerce/example-storefront:X.X.X .

Where X.X.X indicates the tag version you want to use, i.e. 3.1.0

Then, to start the app on your machine, make sure the Reaction API container is already running and enter:

docker run -it --name storefront -p 4000:4000 --env-file .env.prod --network reaction.localhost reactioncommerce/example-storefront:X.X.X

NOTE: You can replace the number before the colon in 4000:4000 with a different localhost port you'd like the application to run at.

NOTE: This is not the way to run the app in actual production deployment. This is only for running the production build locally for development, demo or trial purposes.

To stop the Docker container after starting it with the above command, use:

docker stop reaction-storefront

Contribute

Find a bug, a typo, or something that’s not documented well? We’d love for you to open an issue telling us what we can improve! This project uses semantic-release, please use their commit message format..

Want to request a feature? Use our Reaction Feature Requests repository to file a request.

We love your pull requests! Check our our Good First Issue and Help Wanted tags for good issues to tackle.

Pull Request guidelines

Pull requests should pass all automated tests, style, and security checks.

Automated Tests

Your code should pass all acceptance tests and unit tests. Run

docker-compose run --rm web yarn test

to run the test suites locally. If you're adding functionality to Reaction, you should add tests for the added functionality. You can run the tests locally without cache if necessary by passing the --no-cache flag. This can be helpful if changes aren't showing up.

docker-compose run --rm web yarn test --no-cache

To update a failing snapshot (if you've made changes to a component)

docker-compose run --rm web yarn test -u

Eslint

We require that all code contributed to Reaction follows Reaction's ESLint rules. You can run

docker-compose run --rm web eslint src

to run ESLint against your code locally.

Developer Certificate of Origin

We use the Developer Certificate of Origin (DCO) in lieu of a Contributor License Agreement for all contributions to Reaction Commerce open source projects. We request that contributors agree to the terms of the DCO and indicate that agreement by signing all commits made to Reaction Commerce projects by adding a line with your name and email address to every Git commit message contributed:

Signed-off-by: Jane Doe <[email protected]>

You can sign your commit automatically with Git by using git commit -s if you have your user.name and user.email set as part of your Git configuration.

We ask that you use your real name (please no anonymous contributions or pseudonyms). By signing your commit you are certifying that you have the right have the right to submit it under the open source license used by that particular Reaction Commerce project. You must use your real name (no pseudonyms or anonymous contributions are allowed.)

We use the Probot DCO GitHub app to check for DCO signoffs of every commit.

If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.

License

Copyright 2019 Reaction Commerce

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.

FOSSA Status

More Repositories

1

reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
JavaScript
12,283
star
2

meteor-security

A Meteor package: Logical MongoDB security
JavaScript
258
star
3

reaction-development-platform

Reaction Platform is the quickest way to run Reaction (reactioncommerce/reaction) and dependent services—Reaction Admin (reactioncommerce/reaction-admin) and Example Storefront (reactioncommerce/example-storefront)
Makefile
228
star
4

reaction-component-library

Example Storefront Component Library: A set of React components for the Example Storefront
JavaScript
97
star
5

reaction-admin

Reaction Admin
JavaScript
88
star
6

reaction-docs

Documentation for Reaction, Reaction Platform, Example Storefront, and other supporting services.
CSS
68
star
7

mongo-rep-set

A Dockerized MongoDB for creating a three node replica set across separate hosts.
Shell
56
star
8

meteor-google-spreadsheets

Google Spreadsheets for Meteor
JavaScript
53
star
9

reaction-swag-shop

JavaScript
38
star
10

proxy-traefik

A reverse proxy powered by Traefik for deploying the Reaction Platform on Digital Ocean
35
star
11

reaction-cli

A command line tool for working with Reaction Commerce.
JavaScript
33
star
12

meteor-ddp-login

Meteor DDP login package
JavaScript
27
star
13

reaction-example-plugin

Example files to accompany the "Creating a Plugin" tutorial in the Customization Guide
JavaScript
22
star
14

reaction-devtools

Developer tools for Reaction
JavaScript
21
star
15

reaction-api-base

ARCHIVED: Demo GraphQL API server.
JavaScript
21
star
16

redoc

redoc - generate documentation from multiple project repos.
CSS
20
star
17

reaction-file-collections

Reaction File Collection packages
JavaScript
19
star
18

base

A base Docker image for Reaction Commerce (https://hub.docker.com/r/reactioncommerce/base)
Dockerfile
19
star
19

reaction-example-theme

Reaction Commerce example theme package
JavaScript
15
star
20

reaction-hydra

OAuth2 token server. Integrated with the Reaction development platform.
Shell
14
star
21

reaction-feature-requests

Reaction Feature Requests
14
star
22

spiderable

Docker + Ports friendly Meteor Spiderable
JavaScript
14
star
23

data-factory

Mock data factory util for Reaction Commerce
JavaScript
13
star
24

api-core

This NPM package provides the `ReactionAPICore` class. Use this to build a NodeJS microservice that is compatible with the Reaction Commerce platform, or to build your main Reaction Commerce API if you don't want to start by forking the https://github.com/reactioncommerce/reaction project.
JavaScript
10
star
25

catalyst

Catalyst Design System: A design system built by Reaction Commerce for Reaction Admin.
JavaScript
9
star
26

components-context

A system for injecting React components into other React components from a central components context
JavaScript
9
star
27

reaction-styleguide

A plugin for Reaction, transforming it into a style guide and UI component playground.
JavaScript
9
star
28

random

A drop-in replacement for the "random" Meteor package
JavaScript
8
star
29

reaction-main-street-theme

A theme for Reaction Commerce based on bootstrap 4
CSS
8
star
30

reaction-identity

JavaScript
8
star
31

ci-scripts

Scripts supporting our Continuous Integration (CI)
Shell
8
star
32

kinetic

Kinetic introduces a suite of opinionated admin tools that internal teams can use to manage and run their stores on Open Commerce.
TypeScript
7
star
33

reaction-sample-data

A collection of different datasets for testing and evaluating
7
star
34

pricewatch

Watch prices for change notifications.
Clojure
6
star
35

api-utils

Utility functions for the Reaction API.
JavaScript
6
star
36

federated-gateway

An access aware federated GraphQL API gateway for the Reaction Commerce ecosystem
JavaScript
6
star
37

cli

A command line tool for creating, developing and deploying Open Commerce projects
JavaScript
5
star
38

generator-reaction

Project generator for Reaction NodeJS projects. Built with Yeoman.
JavaScript
5
star
39

reaction-eslint-config

Reaction Eslint Configuration
JavaScript
5
star
40

mongo-s3-backup

A Docker container to backup a MongoDB deployment to S3 and list or restore those backups.
Shell
5
star
41

schemas

The collection schemas API for Reaction Commerce
JavaScript
4
star
42

migrator

Command line interface for migrating MongoDB databases
JavaScript
4
star
43

api-plugin-pricing-simple

Simple Pricing plugin for the Reaction API
JavaScript
4
star
44

reaction-health-check

A package to create a health-check route
JavaScript
4
star
45

api-plugin-example

Boilerplate Example Plugin for moving internal plugins to their own NPM packages for the Reaction API
JavaScript
4
star
46

api-migrations

This project tracks current desired versions for all tracks used by the default Reaction Platform.
JavaScript
4
star
47

docs

4
star
48

nodemailer

Send e-mails with Node.JS
JavaScript
4
star
49

docker-base

Dockerfile
4
star
50

admin-core

JavaScript
4
star
51

micro-frontend-admin

JavaScript
3
star
52

design

Board for design issues
3
star
53

reaction-job-queue

Reaction job queue collection
JavaScript
3
star
54

api-plugin-shops

Shops plugin for the Reaction API
JavaScript
3
star
55

api-plugin-products

Products plugin for the Reaction API
JavaScript
3
star
56

api-plugin-inventory

Inventory service for the Reaction API
JavaScript
3
star
57

mailchimp-open-commerce-helm-chart

Helm chart for deploying Mailchimp Open Commerce ontop of Kubernetes/Openshift.
Mustache
3
star
58

reekwire

Workaround for using CommonJS named exports in ES modules.
JavaScript
3
star
59

api-plugin-payments-stripe

Stripe Payments plugin for the Reaction API
JavaScript
3
star
60

hydra-token

Command line interface that makes it quick and easy to get a valid access token for a Reaction GraphQL API
JavaScript
3
star
61

api-plugin-payments-example

Example Payments plugin for the Reaction API
JavaScript
2
star
62

api-plugin-i18n

i18n plugin for the Reaction API
JavaScript
2
star
63

api-plugin-authentication

Authentication plugin for the Reaction API
JavaScript
2
star
64

api-plugin-files

Files plugin for the Reaction API
JavaScript
2
star
65

api-plugin-sitemap-generator

Sitemap Generator plugin for the Reaction API
JavaScript
2
star
66

api-plugin-taxes

Taxes plugin for the Reaction API
JavaScript
2
star
67

api-plugin-email-smtp

Email SMTP plugin for the Reaction API
JavaScript
2
star
68

api-plugin-email-templates

Email Templates plugin for the Reaction API
JavaScript
2
star
69

logger

Reaction Commerce application logging API.
JavaScript
2
star
70

api-plugin-email

Email plugin for the Reaction API
JavaScript
2
star
71

admin

TypeScript
2
star
72

hooks

The event hooks API for Reaction Commerce
JavaScript
2
star
73

api-plugin-accounts

Accounts plugin for the Reaction API
JavaScript
2
star
74

api-plugin-job-queue

Job Queue plugin for the Reaction API
JavaScript
2
star
75

reaction-error

Reaction error messaging
JavaScript
2
star
76

api-plugin-payments-stripe-sca

Stripe payments using the Payments Intents API
JavaScript
2
star
77

reaction-questions

Ask us questions about Reaction
1
star
78

api-plugin-navigation

Navigation plugin for the Reaction API
JavaScript
1
star
79

kube-helm

A lightweight Docker image with various CLI tooling for working with Kubernetes.
Shell
1
star
80

api-plugin-payments

Payments plugin for the Reaction API
JavaScript
1
star
81

api-plugin-shipments-flat-rate

Shipping Rates plugin for the Reaction API
JavaScript
1
star
82

babel-remove-es-create-require

JavaScript
1
star
83

admin-plugin-products

JavaScript
1
star
84

example-payments-plugin

An example payments plugin for Reaction Commerce
JavaScript
1
star
85

api-plugin-translations

Translations plugin for the Reaction API
JavaScript
1
star
86

api-plugin-address-validation-test

Address Validation Test plugin for the Reaction API
JavaScript
1
star
87

api-plugin-surcharges

Surcharges plugin for the Reaction API
JavaScript
1
star
88

api-plugin-orders

Orders plugin for the Reaction API
JavaScript
1
star
89

api-plugin-authorization-simple

Simple Authorization plugin for the Reaction API
JavaScript
1
star
90

api-plugin-carts

Carts plugin for the Reaction API
JavaScript
1
star
91

db-version-check

Data version checker function compatible with @reactioncommerce/migrator
JavaScript
1
star
92

api-plugin-discounts-codes

Discount Codes plugin for the Reaction API
JavaScript
1
star
93

admin-plugin-example

Example Reaction Admin plugin
JavaScript
1
star
94

api-plugin-address-validation

Address Validation plugin for the Reaction API
JavaScript
1
star
95

api-plugin-shipments

Shipments plugin for the Reaction API
JavaScript
1
star
96

api-plugin-taxes-flat-rate

Tax Rates plugin for the Reaction API
JavaScript
1
star
97

api-plugin-discounts

Discounts plugin for the Reaction API
JavaScript
1
star
98

api-plugin-settings

Settings plugin for the Reaction API
JavaScript
1
star
99

api-plugin-simple-schema

Simple Schema plugin for the Reaction API
JavaScript
1
star
100

api-plugin-system-information

System Information plugin for the Reaction API
JavaScript
1
star