# Best Practices for ONEWEB Integration

Integration is a critical element of building **large‑scale and enterprise‑grade applications**.\
To ensure scalability, maintainability, and reliability, it is important to follow best practices when designing and implementing integrations using ONEWEB.

The following guidelines help teams design clean, reusable, and production‑ready integrations.

***

### Choose the Right Integration Tool

ONEWEB provides multiple integration tools, each designed for specific use cases.

* Use **Process Designer** only when:
  * Integration is part of a **business workflow**
  * The flow is **long‑running or state‑driven**
  * Human interaction, approvals, or orchestration across systems is required
* Use **Microflow** when:
  * Integration is **service‑oriented**
  * The interaction is short‑lived or stateless
  * The integration is invoked from UI components, APIs, or other services

Selecting the correct tool avoids unnecessary complexity and improves performance.

***

#### Use Microflow for Component and Service Integration

Microflow should be the default choice for:

* Integrating with external APIs
* Connecting UI components to backend services
* Data lookup, transformation, or validation
* Reusable backend logic

Microflows act as lightweight integration services and are easier to scale and maintain than workflow‑based solutions when no business state is involved.

***

#### Apply the Single Responsibility Principle

Each Microflow should be designed with **a single, clear responsibility**.

Best practices include:

* One Microflow per integration responsibility
* Avoid combining unrelated logic in a single Microflow
* Keep integration logic focused and predictable

This approach improves:

* Readability
* Maintainability
* Testability

***

#### Reuse Logic with Sub‑Flows

To avoid duplication:

* Use **sub‑flows** for shared integration logic
* Extract reusable logic into common Microflows
* Invoke these sub‑flows from multiple parent Microflows or Processes

Reusable sub‑flows reduce errors and simplify long‑term maintenance.

***

#### Define Names and Business Objects Early

During the design phase:

* Define **Microflow names** clearly based on business intent
* Design **Business Objects** (input and output models) upfront
* Ensure naming conventions are consistent across integrations

Early definition avoids rework and ensures that integration interfaces remain stable as the application evolves.

***

#### Use Environment Variables for Configuration

Always externalize environment‑specific values such as:

* Service endpoints
* Credentials
* Database connections
* File paths

Using **environment variables** ensures that:

* The same integration logic can be deployed across environments
* No configuration changes are required during deployment
* Test and production environments remain isolated

This practice is essential for safe and automated deployments.

***

#### Manage Java Dependencies Properly

When using **Java Tasks** in Microflow or Process Designer:

* Separate **dependency JAR files** from the main Java node JAR
* Upload shared dependency JARs independently to the server
* Allow administrators to manage and version common utility libraries

This approach:

* Prevents dependency conflicts
* Improves version control
* Simplifies maintenance when multiple integrations share utilities

***

### Summary

Following these best practices ensures that ONEWEB integrations are:

* Clean and modular
* Easy to maintain and extend
* Scalable across environments
* Aligned with enterprise deployment standards

By choosing the right integration tool, designing reusable Microflows, externalizing configuration, and managing dependencies carefully, teams can build **robust and future‑proof integrations** using ONEWEB.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/building-apps/integrations/best-practices-for-oneweb-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
