This project is the result of searching for an Open Source solution that would fulfill the following requirements: You can read my post on headless eCommerce on Medium.
- Headless
- High performance and scalable
- A clean, modular system that is configurable
- Open Source to crowdsource the best ideas from the community
Features
- Accounts
- Carts
- Catalogs
- Products / Variants / Options
- Fulfillment
- Orders
- Payments / Refunds
- Coupons
- Slugs
- Tags / Categories
Current System Support
The current project is a work in progress as the main end points (APIs) have been created and the system works in production for a specific set of services.
The current implementation supports an eCommerce workflow that consists of:
- Customer Registration
- Custom Login
- Adding/Removing Products from Shopping Cart
- Checkout workflow:
- Address verification via UPS API
- Lookup UPS Shipping Rates based on Address
- Credit Card Payments via Elavon Payment Gateway
- Order Verification and Notifications
- Order Refunds
- Email Notifications for Registration, Password Reset, and Orders
- Product Catalog
Future System Support The work that is being done is to modularize the services further that they are configurable from an administrative console that will allow the following:
- Support for additional Payment Gateways
- Support for various Shipping fulfilment systems
- Support for Shipping Rates from various carriers
- Support for Tax/Nexus calculation for additional states
This project uses the serverless-webpack plugin, Babel, serverless-offline, and Mocha.
This configuration supports:
-
ES7 syntax in your handler functions
- Use
importandexport
- Use
-
Package your functions using Webpack
-
Run API Gateway locally
- Use
serverless offline start
- Use
-
Support for unit tests
- Run
npm testto run your tests
- Run
-
Sourcemaps for proper error messages
- Error message show the correct line numbers
- Works in production with CloudWatch
-
Automatic support for multiple handler files
- No need to add a new entry to your
webpack.config.js
- No need to add a new entry to your
-
Add environment variables for your stages
To run unit tests on your local
npm testTo run a function on your local
serverless invoke local --function helloTo simulate API Gateway locally using serverless-offline
serverless offline startRun your tests
export CONFIG_API_URL=XXX
npm run testWe use Jest to run our tests. You can read more about setting up your tests here.
Deploy your project
serverless deployDeploy a single function
serverless deploy function --function helloTo add another function as a new file to your project, simply add the new file and add the reference to serverless.yml. The webpack.config.js automatically handles functions in different files.
To add environment variables to your project
- Rename
env.exampletoenv.yml. - Add environment variables for the various stages to
env.yml. - Make sure to not commit your
env.yml.