Categories
Success Stories

Scale ERPNext Custom Development On Kubernetes

Extend and Scale ERPNext custom development on Kubernetes and Docker with Microservices!

This would be our journey in implementing ERPNext for an enterprise dealing with the bulk manufacturing and distribution of serialized electronic products. The following indicate how we deployed our software stack on bare metal servers with brief system architecture.

Core Business problem?

The client had been using a legacy system to manage their distribution business. Initially, it worked just fine for them, but after it accumulated data from many years it became really impossible to sustain on the current system.

Our client have operations such as purchase, sales, warranty, stock and return transactions. These all are mission-critical and need bulk serial and ledger entries, almost multiple millions of serial transactions every day.

The process became so slow that every day after office hours, staff and management had to lock the system and make manual entries of serials.  These serials were slowly added to the system overnight and sold the next day, making it a mess to run the business operations.

Stepping Stones-

Initially, the client looked around for various ERP solutions and then came across ERPNext for managing their business. After using ERPNext as a staging instance they found that almost 60% of their requirements directly fit into vanilla ERPNext.

Being extendable to any customizations on the metadata level really attracted them to choose ERPNext as they had a perspective of achieving all the remaining 40% and any future requirements and customization using doctype customization.

The ERPNext customization Experience

With being amazed by metadata customization they had a list that they wanted to achieve with doctype and ERPNext customizations.

  • Warranty module
  • Assign serials in bulk
  • Custom aggregated challan/receipts for all doctypes.
  • Order > Invoice > Receipt flow in a single tabular UI for
    • Sales
    • Purchase
    • Warranty
    • Stock
  • Schedulers on the customer credit limit.
  • Custom Item validations and control.
  • and more.

After the client spent over 2 years in initial self customization and giving up on working with 2 service providers in achieving a complete solution for their problems which eventually turned out to failure.
They failed to find something that would meet the requirements as well as the scale that they need the most. 

Going with an approach of a single system to solve everything and be scalable at the same time.

Scale ERPNext custom development On Kubernetes

With serial assignment from ERPNext as shown here, it is impossible to make entries for million serials, which is the backbone of requirements as well as a critical aspect of the business. We had to think about something that would solve it and make a seamless experience.

Custom Software Approach

We came across this problem and being a contributor to ERPNext and frappe framework from the very initial days of V4 we had a very decent understanding of ERPNext.

On deep analysis of requirements, we found this is not something that can be achieved with a monolith structure as it has a really high scale requirement.

We decided to go with a distributed system with a set of microservices to handle the logic for different modules.

All these modules can be small independent services for itself, these services will hold all the logic that is not available in vanilla ERPNext, with this we selected right stack,

These give you support for a wide variety of BI as well as reporting tools to analyze your business. It also help in making custom hardware or device integrations being open to the latest security updates.

For scaling ERPNext we managed to dockerize ERPNext and got it to run on Kubernetes!.

We have it opensource and are maintainers for the same you can check out ERPNext Docker and helm-charts ERPNext Kubernetes Helm Charts.

How will microservices integrate with ERPNext?

All these above microservices will communicate and send end results to ERPNext using ReST API, and Webhooks.

They will be registered as an OAuth 2.0 client and follow token-based authentication, hence they can communicate with ERPNext as well as any other services within the infrastructure.

For a web application, we are using OIDC authentication and for the mobile applications and PWA, we’re using Code grant.

Analyzing and understanding the business flow.

The client needed an easy way to assign a million serials to any of their Purchase, Sales, Stock, and Warranty transactions.

For that, we build a UI with a listing of all the above components in a way custom filters can be applied.

Scale ERPNext custom development On Kubernetes

 

Listing for invoices with custom relation and filters.

Coming to getting all flow related to a module together, let’s consider the Sales flow.

Scale ERPNext custom development On Kubernetes

 

Sales Flow

Now let’s get these documents to a UI which will make things easy to manage for a salesperson.

Now we have a sales invoice and all related documents to it under a single UI.

Assigning Serials-

With reference to their old system, there could be 3 ways of assigning items.

  • Singular (Keyboard or Barcode scanner).
  • Range (eg. X0001- X9999).
  • File (Excel or CSV).

The following can be achieved like this.

  • Range and File serial assignment.

Scale ERPNext custom development On Kubernetes

  • Singular/ Barcode serial assignment.

Scale ERPNext custom development On Kubernetes

Million serials and error handling?

Image this scenario where you submit 10 items with 1 million serials each, that’s huge data to be added to a single document. Even on the ERPNext side or database it’s not good to have such a huge set of data in terms of validation, error handling, or any terms.

So we will breakdown this big data of million serials in multiple smaller chunks so even if something fails it could be tracked and retried accordingly.

Here’s how we will do that, Consider our current document with 1 million serials.

Scale ERPNext custom development On Kubernetes

 

Batching of a document into sub-jobs

All documents with bulk serials are broken down into sub-documents and then they are queued in the background and synced to ERPNext one by one.

All the subdocuments are linked to the same parent document and same customer/supplier/account just serials and quantity are being batched it does not affect any ledger reports and it helps us in achieving granularity.

Event-driven architecture & modern stack.

With the help of modern tools, we can bind events to any functions helping us in track and trace as well as reports based on custom application as well as ERPNext.

As all logic is coming from microservices, we can have event propagation on any events and analyze as well as track any data point helping us in getting better control of the system and in-depth reports of the business.

Eg. Track and Trace of serials history.

Here we added an event on the serial entity being updated and were able to track the smallest movement of serials right between,

Sales → Purchase → Stock → Warranty

with this, we were able to track things like an internal movement of a serial was made such as when an employee received a serial for warranty and he transferred it to another person for fixing something making an internal transfer which was not recorded on the ledger, making more granular reports for the management.

Scale ERPNext custom development On Kubernetes

 

Here a serial and its occurred events.

Background Jobs and failure handling-

Scale ERPNext custom development On Kubernetes

With a list and track of all background jobs which could be reset/re-queued/synced if any of the serials fail or in case of any human errors, these background jobs can be handled here by the user as required.

Achievement with custom solution-

With the above approach, architecture, and tech stack we were able to achieve a cutting-edge scalable system. This opens an opportunity for the client to integrate with any modern software and hardware while simplifying and securing business requirements.

Valuable time and resources are saved.

The client is now able to generate and assign serials for millions of items within seconds.

Tracking these items in case of return/warranty is made easy with future proof being well tested to sustain performance for upcoming years and have exceptionally zero downtime.

Still struggling with Frappe applications and upgrades? Do check our seamless and reliable approach for complex ERPNext customizations and integrations

looking for similar scalable software product? Try connecting our expert with business case.