DEV Community

Richa Singh
Richa Singh

Posted on

How to Build Middleware for ERP Integration Services with Node.js and AWS

ERP integrations often fail at the boundaries between systems rather than inside the ERP itself. An e-commerce platform may send an order twice, a warehouse API may respond slowly, or an ERP may reject a record because its field format differs from the source system. Direct point-to-point connections make these failures difficult to isolate and recover from.

This is where ERP Integration Services benefit from a dedicated middleware layer. Instead of connecting every application directly to every ERP module, middleware can validate requests, transform payloads, manage retries, and provide an observable processing path.

For teams evaluating ERP integration architecture and implementation options, the key question is not simply how to connect two APIs. It is how to keep data consistent when one of those APIs becomes slow, unavailable, or changes its contract.

Context and Setup

A practical middleware architecture places an integration service between business applications and the ERP.

A typical flow looks like this:

E-commerce / CRM
       |
       v
   API Gateway
       |
       v
 Node.js Middleware
   |       |       |
   |       |       +--> Validation
   |       +----------> Transformation
   +------------------> Idempotency
       |
       v
    SQS Queue
       |
       v
 Integration Worker
       |
       v
      ERP
Enter fullscreen mode Exit fullscreen mode

The middleware becomes responsible for integration concerns while the ERP remains responsible for enterprise business rules.

Node.js fits this pattern well for I/O-heavy workloads because its event-driven architecture is designed around non-blocking operations and HTTP workloads.

For AWS-based deployments, Lambda can also reduce infrastructure management. AWS recommends initializing reusable SDK clients and database connections outside the Lambda handler because execution environments may be reused across invocations.

Designing ERP Integration Services Middleware

The most effective approach is to separate ingestion, transformation, and delivery instead of placing the entire workflow inside one API handler.

Step 1: Define a Canonical Integration Contract

Start by defining an internal representation for business objects such as customers, orders, invoices, and inventory.

For example:

{
  "eventId": "ord_83921",
  "type": "ORDER_CREATED",
  "source": "commerce",
  "payload": {
    "customerId": "C1024",
    "orderNumber": "ORD-10045",
    "currency": "USD",
    "total": 249.90
  }
}
Enter fullscreen mode Exit fullscreen mode

The eventId is important because downstream systems may receive the same event more than once.

Instead of allowing every source system to understand the ERP schema, the middleware maps source-specific fields into the canonical model.

This reduces coupling and makes adding another sales channel or ERP adapter easier.

Step 2: Add Idempotency Before Processing

A retry is useful only when repeating an operation does not create duplicate business records.

A simplified Node.js example is:

const processedEvents = new Set();

async function processOrder(event) {
  // Why: prevents duplicate processing after network retries.
  if (processedEvents.has(event.eventId)) {
    return { status: "duplicate" };
  }

  processedEvents.add(event.eventId);

  // Why: transformation stays separate from transport logic.
  const erpOrder = mapOrderToERP(event.payload);

  await sendToERP(erpOrder);

  return { status: "processed" };
}
Enter fullscreen mode Exit fullscreen mode

For production workloads, the idempotency record should live in durable storage such as DynamoDB or PostgreSQL rather than an in-memory Set.

The processing sequence should be:

  1. Validate the event.
  2. Check the idempotency key.
  3. Persist the processing state.
  4. Transform the payload.
  5. Call the ERP.
  6. Record the outcome.
  7. Acknowledge the message.

This approach also makes replay and incident investigation easier.

Step 3: Move Slow ERP Calls Behind a Queue

Do not make users wait for an ERP operation when the business workflow does not require an immediate response.

A better pattern is:

Client
  |
  v
API
  |
  +--> Store Event
  |
  +--> SQS
          |
          v
      Worker
          |
          v
         ERP
Enter fullscreen mode Exit fullscreen mode

The API can acknowledge the accepted event while an asynchronous worker handles the ERP request.

Retries should distinguish between transient and permanent failures. A timeout or HTTP 503 can normally be retried with exponential backoff, while a validation error should generally move directly to a dead-letter queue.

AWS documents SQS, CloudWatch, and DLQ-based patterns for handling distributed processing and operational visibility, and AWS also recommends monitoring Lambda duration and memory usage when tuning function configuration.

Real-World Application

In one of our ERP Integration Services projects at Oodles, we built middleware for a manufacturing client that needed financial and transactional data moved from QuickBooks Online to ERPNext. The architecture included secure authentication, extraction, transformation, field mapping, validation, and controlled loading into ERPNext. Oodles' public project documentation describes the middleware and ETL approach used for the integration.

The important architectural decision was to keep the middleware responsible for data movement and transformation rather than embedding every mapping rule inside the ERP.

We have also implemented ERP integrations where APIs are used to connect Odoo with operational systems. For example, an Oodles project integrated Odoo with ShipHero to synchronize orders and automate delivery and pickup cost handling using Python and Odoo APIs.

For additional engineering context, Oodles documents ERP, API, cloud, and integration work across multiple enterprise platforms.

One useful benchmark for serverless middleware comes directly from AWS Lambda's documentation: Lambda invocation reports expose duration in milliseconds, including examples such as a 12.34 ms function duration. AWS recommends measuring actual duration and memory usage rather than assuming a particular configuration will be optimal.

That distinction matters: middleware performance should be measured from the complete workflow, including queue delay, transformation time, network latency, ERP response time, retries, and database operations.

Conclusion: Key Takeaways

  • ERP Integration Services should isolate ERP-specific logic behind adapters and transformation layers.
  • Idempotency should be designed before retry mechanisms are introduced.
  • Queue-based processing is preferable when ERP operations are slow or temporarily unavailable.
  • Canonical data contracts reduce coupling between ERP and external applications.
  • Performance should be measured across the complete integration workflow, not only the middleware API.

If you are designing an ERP middleware layer and want to discuss API boundaries, event processing, idempotency, or deployment architecture, share your architecture or technical question in the comments. You can also reach out through our ERP Integration Services contact page.

FAQ

1. What is middleware in ERP integration?

Middleware is an intermediate software layer that connects an ERP Integration Services with external applications. It can validate requests, transform data, authenticate services, manage retries, enforce idempotency, route messages, and record integration outcomes without requiring every connected system to understand the ERP's internal API.

2. Why use ERP Integration Services instead of direct API connections?

ERP Integration Services can introduce a controlled integration layer when several systems must communicate with an ERP. Instead of maintaining many point-to-point connections, teams can centralize transformation, authentication, error handling, monitoring, and retry policies within middleware.

3. Should ERP integrations use synchronous or asynchronous processing?

Use synchronous processing when the caller needs an immediate ERP Integration Services response, such as checking an inventory quantity. Use asynchronous processing for operations such as bulk imports, invoice synchronization, notifications, and workflows that can tolerate delayed completion.

4. How does idempotency prevent duplicate ERP records?

Idempotency assigns each business event a unique identifier and stores its processing state. If the same event arrives again after a timeout or retry, the middleware recognizes the identifier and avoids executing the same business operation twice.

5. Is Node.js suitable for ERP middleware?

Node.js is suitable for ERP Integration Services when workloads involve substantial HTTP, database, queue, and API communication. Its event-driven, non-blocking model is designed for I/O-heavy services, while CPU-intensive transformation workloads may require worker processes or separate compute services.

Top comments (0)