Introduction
Crafter Commerce will be a new extension to Crafter 2. It will be an online commerce engine that facilitates guided shopping experiences within an extensive product catalog with rich metadata. It will also interface with billing engines, payment gateways, CRM and analytics platforms. Crafter Commerce will be build around four main pillars, as shown below:

Features
Here is an overview of features that Crafter Commerce will support.
Account managent
- Customer profiles
- Opt-in/opt-out
- Address cleansing & validation
Pricing management
- Promotion codes
- Royalty/referer codes
- Quantity discount calculations
- Promotion models (i.e. Buy one, get one free)
Order management
- Quotes
- Create (taking into consideration shipping and tax)
- Confirm
- Update
- Orders
- History
- Status
- Cancelations
- Returns
List Management
- Payment types
- Credit card types
- Person titles
- Shipping methods
- States
Security
- Authentication
- Authorization
Implementation
Crafter Commerce is implemented as a Server and a Client component, which communicate with each other over HTTP through JSON or XML messages. The Server component is build as a Java web application with Spring, Mongo, Hibernate Validator, SolrJ as dependencies. The Client component is build as a Java library that can be embedded in any Java (web) application. It uses Spring REST support to interact with the Server over HTTP and perform marshalling and unmarshalling.

Entity Relationships

Mongo Schema Design
collections:
- accounts
- products
- promotions
- product-prices
- orders
- payments
- order-line-items
- order-delivery
- payment-gateways
- shipping-methods
- locations
- addresses
- attributes
atomic operations:
In Mongo, atomic operations can be performed only on a single BSON document.
Needed when:
- Adding a product to a shopping cart (if we manage inventory, so updating a product's available quantity should be atomic).
- ...
indexes:
Identify the fields to index / query on
- id (all collections)
- key-name(s) (coll-name)
- key-name(s) (coll-name)
sharding:
Not applicable at this time
Promotions
- Percentage off per item
- Percentage off all
- Fixed amount off per item
- Fixed amount off for all
- Buy X, get one or more items at a discount
- Free gift with purchase
- Free shipping
- Discounted shipping for an order using a selected ship mode
- Discounted shipping for all items using a selected ship mode
- Discounted shipping per item using a selected ship mode
Open Questions
- What persistence store to use?
- How to maintain a Crafter Commerce transaction?
- What do do with abandoned shopping carts?
- Analytics integration?
- What user information can we store without having to be PCI compliant?
Download and build it
Prerequisites
The following is a list of prerequisites that Crafter Commerce depends on in order to build and run:
- Java 1.5
- Maven 2
- An SVN client
- Apache Solr 3.6.0 (not needed for build)
- Mongo DB 2
- A decent servlet container such as Jetty, Tomcat or JBoss
Technically Mongo and Solr are not required for building, but Mongo is required for testing as an extension to the build. We're using the Maven Failsafe plugin to run integration tests, for which at least Mongo is assumed to be running at the time of building. For integration tests specifically, Mongo is expected to be run on default port 27017 with no authentication required.
Prerequisites: Mongo and Solr
Mongo
Mongo can be downloaded here: http://www.mongodb.org/downloads. At the time of writing, the latest version was 2.0.5. There are versions for OS X, Linux, Windows and Solaris.
Once you have Mongo installed, start it as follows:
mongod --dbpath=/path/to/mongo/data/db
While it's starting, it'll log to the console the default port on which it will be listening:
[initandlisten] waiting for connections on port 27017
Solr
Apache Solr can be downloaded here: http://lucene.apache.org/solr/downloads.html. The latest version at this moment is 3.6, which is the exact dependency for Crafter Commerce, although older versions may work as well.
Download the binary distribution from one of the Apache mirrors, for example: {{ apache-solr-3.6.0.tgz}}. Then, unpack it and copy the reference schema from the Crafter Commerce source into the Solr example directory:
cd /your/path/to/apache-solr-3.5.0/example/conf mv schema.xml to schema.xml.ORIG cp /your/path/to/crafter-commerce/crafter-commerce-itest/solr/conf/schema.xml .
Lastly, startup Solr with embedded Jetty as follows:
cd /your/path/to/apache-solr-3.5.0/example java -jar start.jar
Jetty will report to the console on which port it is listening for HTTP requests:
INFO::Started SocketConnector@0.0.0.0:8983
To double-check that Solr is indeed running on that port, fire up a browser, and try the following URL:
Download the Crafter Commerce source code
Use your SVN client to checkout a copy of the source code. From the command line it would look like this:
svn co [https://svn.rivetlogic.com/repos/crafter-community/commerce/trunk crafter-commerce]
Make sure that Solr isn't started on that port while running the integration tests.