Skip to main content

Outline

This module introduces the concept of hybrid Opal tools, where multiple SDKs are combined to deliver solutions that a single technology cannot efficiently achieve.

By the end of this module, you will be able to:

  • Explain the concept of hybrid tools and when combining multiple SDKs is appropriate.
  • Identify use cases where different technologies (JavaScript/TypeScript, Python, C#) can work together effectively.
  • Apply suitable communication patterns to ensure secure and reliable data exchange between hybrid tools.

Hybrid Tools Explained

Ideally, each tool should be clearly defined for a specific task, using the atomic approach. However, in the dynamic landscape of modern digital experience platforms, it is sometimes needed for a single solution to require capabilities best provided by different technologies. This leads to the concept of hybrid tools, where multiple Optimizely Opal tools, potentially built with different SDKs, collaborate to achieve a goal. This approach allows developers to leverage the unique strengths of each language and framework, and should be used with caution. Let's take a look at some potential scenario where you might use the hybrid approach.

Architectural Scenarios for Hybrid Tools

JavaScript/TypeScript Frontend with Python Backend: Consider a scenario where an Opal tool needs to provide a sophisticated content recommendation engine. The user interface for configuring and viewing these recommendations might be a rich, interactive application built with JavaScript/TypeScript, seamlessly embedded within the Optimizely platform. However, the core recommendation logic, which involves complex data processing, machine learning model inference, and potentially large dataset manipulation, is often best handled by a Python service due to Python's robust data science ecosystem and specialized libraries. In this hybrid architecture, the JavaScript/TypeScript frontend Opal tool would make secure HTTP API calls (e.g., using fetch or axios) to a separate Python-based Opal tool service. The Python service would then execute the computationally intensive recommendation algorithms, process the data, and return the results to the JavaScript tool for display and user interaction. This clear separation of concerns effectively decouples the user interface from the heavy computational workload, enhancing both responsiveness and scalability.

C# Backend with JS/Python for Specific Tasks: Another common pattern involves a core C# Opal tool service responsible for managing critical business data, such as product catalogs, and syncing this information across various enterprise systems. While the C# service efficiently handles the primary data orchestration and business logic, there might be specific, highly specialized tasks that are more efficiently or conveniently implemented using other languages. For example, generating a complex, interactive data visualization might be significantly easier and faster to develop using a JavaScript charting library, or performing advanced image processing (e.g., object recognition, intelligent cropping) might leverage a specific Python library that offers superior capabilities or ease of use. In such cases, the C# tool would invoke these specialized Opal tools (whether built with JavaScript/TypeScript or Python) via their respective tool execution endpoints. It would pass the necessary data as parameters, and upon completion, receive the processed results back. This delegation allows the C# service to remain focused on its core responsibilities while offloading niche tasks to the most suitable technology.

Communication Patterns Between Hybrid Tools

Effective communication is the backbone of any distributed system, including hybrid Opal tools. Several patterns can facilitate this interaction:

Internal HTTP APIs: This is the most common and straightforward method for inter-tool communication. Each Opal tool exposes its functionalities via well-defined HTTP endpoints (e.g., /tools/my_tool_name). Other tools can then make standard HTTP requests (GET, POST, PUT, DELETE) to these endpoints. This approach requires careful design of request/response contracts (e.g., JSON payloads) and robust error handling to ensure reliable data exchange. It's synchronous by nature, meaning the calling tool waits for a response.

Shared Databases/Storage: While less common for direct, real-time communication between tools, shared data stores (such as a relational database, NoSQL database, or object storage like AWS S3) can be used for persistent state management or for transferring large datasets between tools. For instance, one tool might process a large file and store the results in a shared database, and another tool could then query that database to retrieve the processed data. This approach requires careful consideration of data consistency, concurrency control, and robust access control mechanisms to prevent data corruption or unauthorized access.