Drupal powered POS interface shown in tablet

ZKungFu is the largest directly operated Chinese food chain in China, using steam to prepare healthier food for their customers. The chain serves customers through 600 franchise locations in over 43 cities, four online 3rd party food ordering sites, and the Chinese social network WeChat.

In 2015, ZKungFu’s revenue reached 5 billion RMB (750 million USD). Operating at that scale requires advanced software for supply chain and inventory management, daily store operations, and corporate accounting. At that time the company used proprietary software for these tasks that simply wasn’t up to the challenge of delivering increasing integrability, flexibility, and scalability at a reasonable cost. Therefore, ZKungFu began that year to rebuild all of their software in house with open source technologies, including Drupal.

Why Drupal was chosen: 

Based on our broad experience with Drupal, we chose it because we knew it to be both flexible and scalable, well-suited to our approach of iterative product development and decoupled architecture. Building software for a business of this size was both extremely challenging and rewarding, especially as we achieved a successful migration from the old proprietary platform to the new Drupal based platform in less than one year!

Describe the project (goals, requirements and outcome): 

From the description above, you can see that our goal was a total transformation of ZKungFu's software platform from a struggling proprietary system into a Drupal based platform that could work at their scale.

We met our goals at a very rapid pace, and in this case study we share three lessons based on our development success:

Lesson One: Deploy Drupal based micro-services

Drupal is a comprehensive business application platform and is extensible enough to incorporate any feature you might need in a single site. However, to achieve our goals for reliability and scalability, we decided to use multiple Drupal sites to create a network of micro-service providers to support the entire business.

Compared to one big Drupal site with all the features, dividing functionalities into many smaller Drupal sites allowed our development team to work faster, because each micro-service provider needs to know less of the entire architecture to make progress. Additionally, these smaller sites are much easier to scale than one big site under high traffic.

On the other hand, thanks to Drupal, each micro-service provider can use a common set of web services, so our front-end developers don’t have the overhead they would normally encounter developing for applications with distributed data structures.


Visualizing the Drupal based micro-services powering ZKungFu online.

Specifically, we created three Drupal Commerce sites:

  • One site handles product information and branch management, including pricing rules and variations for duration, location, availability and other business conditions.
  • Another site handles payment, receiving 50% of the company's revenue (i.e. hundreds of millions of dollars annually!) from QR-Code oriented Alipay and WeChat Pay. This payment instance of Drupal Commerce also supports Cash, Credit Cards, and other smaller types of payment methods.
  • The third handles order information, tracking the changes from the moment an order is created online or from our POS machines (yes, we built their hardware and software, too!) to run through the food preparation pipeline, to payment, to delivery, to analytics, to business control, to reporting and accounting, and to supply chain planning.

Moreover, besides the Drupal sites we built for Content and Commerce strategies, we also used Drupal to build Marketing, CRM, and ERP capabilities to support customer acquisition, loyalty programs, resources planning, and forecasting. In summary, at the core of this project, we built a swarm of Drupal sites offering micro-services.

Lesson Two: Offline-First and Reliability second

The bloodline of this type of business is its steady flow of orders and payments. This data needs to be precisely managed and monitored at device level, store level, and cloud level. Therefore, we built the POS software with redundancy at these 3 levels, making offline support a mandatory requirement at the device and store levels.


The menu and shopping cart in the self-service POS application.

Assuming stable connectivity is still a luxury in the field of operation. In the system we built, devices like the cash register POS, self-service POS machine, and kitchen control panels can still create or handle orders when they lose their Internet connection.

After the internet connection is restored, multi-level synchronization takes place naturally and quietly in the background. We used CouchDB, PouchDB, Raspberry Pi, Node.js and Electron to build the data infrastructure that guarantees critical order and payment data will always reach Drupal as soon as possible.

Lesson Three: Software Development Process & Style in China

When it comes to engineering style, the Chinese still have a lot to do to catch up to the global best practices on strategic planning and rigorous thinking. However, two traits tend to set a Chinese development team apart: they usually create products targeting a large customer base, and they have a large pool of fresh and young talent. These two traits offer the company’s leadership a new direction to innovate product development - lightning fast product iteration driven by empirical evidence.

Throughout this project, we have been releasing new versions of various parts of the product on a daily basis for months. We were able to rotate groups of customers, support staff, and our developers around the clock to achieve continuous product innovation 24/7. Additionally, thanks to Drupal, which offers a powerful framework with well-known best practices, we could streamline talent on-boarding, training, and retention processes by encouraging the adoption of Drupal’s best practices.

Closing Thoughts

In conclusion, we have empowered a large restaurant chain to run its core business on open source and Drupal. We have really raised the bar with this project by building it to support an immense scale - over one billion dollars in transactions per year.

Special thanks to Heikwan Zheng (SparkPad) and Ryan Szrama for contribution to this case study and to Bojan Zivanovic and Matt Glaman for feedback during the writing process.

You can view the Chinese translation of this case study here (此案例学习中文翻译) .

Organizations involved: 
Modules/Themes/Distributions
Key modules/theme/distribution used: 
Why these modules/theme/distribution were chosen: 

Drupal Commerce paired with JSON API provided us with the strong foundation we needed to build an enterprise scale transaction server for ZKungFu.

WeChat Pay and Alipay support is essential to doing business in China as they are our market leaders for digital payment.

Community contributions: 
  • Commerce WeChat Pay
  • Commerce Alipay (D8 port)
  • Points (Userpoints D8 port)
  • Many patches contribution to Drupal 8 core, Drupal Commerce 2.x, JSONAPI and a few other modules.
Project team: 

Heikwan Zheng, CTO of Sparkpad
Yueqing Zhang, CEO of Sparkpad
Mengjie Wang, CIO of ZKungFu
Ken Lin, Project Manager
Michael Shen, Architect
Ben Zhao, Product Manager

A swarm of Drupal micro-services
Self-service POS machine: menu and cart
Self-service POS machine: Complete order with Alipay QR-Code
POS tablet in store

Comments

Peter Majmesku’s picture

Thanks for the case study. The site isn't online yet at http://www.zkungfu.cn/, right?

chrlvclaudiu’s picture

Works OK on my side :)

rszrama’s picture

Yep, up for me still, too! Just takes a while for the bytes to travel the world. ^_^

Peter Majmesku’s picture

Looks quite old and not mobile ready, though.

rszrama’s picture

This project was not to rebuild the company's homepage - it was to use Drupal and other open source software to create their entire infrastructure and point of sale systems. I don't believe the website itself even uses Drupal.

Peter Majmesku’s picture

That explains a lot! :) May that address will be one of the next projects. Is there any public url of this project? I guess not, but I better ask by chance. :)

dravenk’s picture

The above link is just our customer's website. The article describes the system we build for our customers.

imrancluster’s picture

I created this type of online application using Drupal 8 a year ago. But I don't know marketing. That's why I didn't get any good output from that. I just sold only one copy for a business. That was not for a restaurant. It was only for account purposes.

http://joipos.com/

dapseen’s picture

Love the software.. Any demo?

mobiro’s picture

What version of Drupal core and Commerce module do you use for this project guys?
Looks stable version of Commerce is not available for D8 yet, but JSON API is not available for D7.

rszrama’s picture

Drupal Commerce 2.0 is in its release candidate phase for Drupal 8 (post-beta, last step before full release), with the bulk of our work focused on usability improvements and non-breaking API improvements. We've also maintained an upgrade path since the first beta as of DrupalCon Dublin 2016. Given a whirl! Hundreds of sites in production.

smokinggoat’s picture

Hi! I've had repeated requests over the years for a Drupal-based POS system - which runs into the issues you mention (needing offline-first reliability). I've love to know if your POS code is (going to be?) available, or if it is too closely integrated with you hardware to be of use elsewhere?
Regards,
Greg (Commerce Guys Europe architecture & sales)

skyredwang’s picture

The POS code for this project is very specific and closed source. However, in the past, we have built two solutions for offline-first POS machine leveraging Drupal Commerce.

1. Android Native Apps, using Sync Adapter, see https://developer.android.com/training/sync-adapters/creating-sync-adapt...
2. Progressive Web Apps, using PouchDB and CouchDB, which is the method we used in this project, see https://pouchdb.com/

I hope this would help.

Abbass’s picture

Thanks for this post.

I own a store and trying to build a POS using commerce POS. I too am located somewhere with very unreliable internet, can you tell me more how you built your POS to sync in the background with the cloud database when internet is back? I know some PHP, SQL and a python programmer per trade.

thanks!