Morphir Framework

repository·main·Indexed 41 days ago

https://github.com/finos/morphir

A framework and toolset designed to digitize and standardize business logic as data, making it portable, machine-readable, and translatable across programming languages and platforms. It features a Hub-and-Spoke architecture with a core daemon for workspace management, build orchestration, and a polyglot ecosystem of backends (TypeScript, Spark/Scala, Go) that consume an Intermediate Representation (IR) via JSON-RPC 2.0.

Tokens
387K
Snippets
1.1K
Records
1.8K
Agent score
53%

What's inside Morphir

  1. Overview of Morphir Specifications

    main

    Morphir provides formal specifications for its configuration formats, Intermediate Representation (IR), and tool distribution. These specifications serve as the authoritative reference for:

    • Implementers: Building tools that generate, consume, or transform Morphir formats.
    • Developers: Working with Morphir configuration and IR across different platforms.
    • Tooling: Validating configuration and processing Morphir IR JSON files.
    • LLMs: Providing context for AI tools working with Morphir.
  2. Overview of Morphir

    main
    Morphir is a library of tools designed to capture business logic as data. It provides a framework for digitizing business logic so it can be shared, stored, translated, and visualized across different languages and platforms. By defining a standard format for business logic, Morphir enables portability, reduces technical debt by ensuring standards are introduced at the input stage, and ensures correctness through its toolchain.
  3. Overview of Morphir Reference Documentation

    main

    The Morphir reference documentation provides technical details for backends, APIs, and tools. It is organized into three primary areas:

    • Backends: Platform-specific code generation (e.g., Scala, Spark, TypeScript, Spring Boot, Relational).
    • JSON Schema: Documentation for JSON Schema generation, configuration, mappings, and codecs.
    • CLI Reference: Documentation for the Morphir command-line interface, including incremental builds and documentation merging.

    Use the following guide to find what you need:

    • Specific Backend: Look in backends/.
    • JSON/Schema Work: Look in json-schema/.
    • CLI Usage: Look in cli/.
  4. Overview of Morphir v4 Design Themes

    main

    Morphir v4 is organized into three primary architectural themes that define its core functionality:

    1. IR v4 (Intermediate Representation): Defines the data model, including types, values, modules, packages, distributions, naming conventions, and serialization formats.
    2. Document Tree Protocol: Specifies the layout for the Document Tree IR and the JSON-RPC 2.0 API used for communication.
    3. Morphir Daemon: A long-running service managing the workspace lifecycle, project management, dependency resolution, incremental builds, file watching, and package publishing via JSON-RPC.

    Additionally, the Extensions (MEP architecture) allows for adding frontends, backends, validators, and transforms using Process and WASM runtimes.

  5. Overview of the Morphir Playground

    main

    The Morphir Playground is an interactive environment designed to allow users to compile source code to Morphir IR and generate artifacts without interacting with the local filesystem.

    Workflow:

    1. Pick a Frontend: Select a language/frontend from the catalog.
    2. Write Source: Type source code in the editor.
    3. Compile: The code is compiled to Morphir IR.
    4. Inspect: Use Insight and XRay views to inspect the resulting IR.
    5. Generate: Pick a target and generate artifacts (returned as downloads).

    The Playground is driven by the same ExtensionRegistry used by the CLI, ensuring that if the CLI can compile a language, the Playground can too. It supports both built-in providers (running in-process) and installed extensions (driven via the Morphir Extension Protocol (MEP)).

  6. Overview of the Morphir Daemon

    main

    The Morphir Daemon is a long-running service designed to manage the development lifecycle of Morphir projects. It provides several core capabilities:

    • Workspace Management: Enables multi-project development where projects can share dependencies.
    • Build Orchestration: Coordinates builds across multiple projects in the correct dependency order.
    • File Watching: Automatically triggers recompilation when source files are modified.
    • IDE Integration: Provides support for the Language Server Protocol (LSP).
    • Package Publishing: Handles packing and publishing packages to registries.
  7. What is Morphir?

    main

    Morphir is a multi-language system designed to capture an application's domain model and business logic in a technology-agnostic data format. By treating business knowledge as data rather than opaque code, Morphir allows you to:

    • Translate it: Move between different languages and platforms as technology evolves.
    • Visualize it: Convert complex logic into understandable explanations for business users.
    • Share it: Distribute consistent interpretations of logic across different departments or organizations.
    • Store it: Retrieve and explain historical versions of business logic.

    The core philosophy is that data and rules reign supreme, while the specific programming language or platform is treated as an implementation detail.

  8. Explore Morphir use cases and domain applications

    main

    Morphir is designed for domains requiring high precision, auditability, and portability of business logic. While documentation is currently focused on Regulatory Technology (RegTech), the platform is applicable to several other sectors:

    Regulatory Technology (RegTech)

    Morphir helps capture business rules exactly as specified in regulations, providing:

    • Precision: Exact capture of regulatory specifications.
    • Auditability: Ability to visualize and explain logic to regulators.
    • Portability: Running the same rules across different systems.
    • Versioning: Retrieving historical versions of regulations.

    Other Applicable Domains

    • Financial Services: Trade processing, risk calculations, and pricing models.
    • Insurance: Policy rules, claims processing, and underwriting.
    • Healthcare: Clinical decision support and compliance rules.
    • Supply Chain: Inventory management and allocation logic.

    For concrete implementations, refer to the examples directory for code samples across these domains.

  9. Key changes in Morphir IR v4

    main

    Morphir IR Version 4 introduces several architectural changes:

    • Removal of Generic Parameters: Types and Values no longer use a generic attribute parameter a. They now use specific TypeAttributes and ValueAttributes structures.
    • Explicit Attributes: Attributes now explicitly include source location, constraints (for types), and inferred types (for values).
    • First-class Module Configuration: Added support for module.json files containing full module definitions.
    • Incomplete Definitions: Introduced IncompleteTypeDefinition and IncompleteBody to support best-effort compilation.
    • Native and External Bodies: Platform builtins (NativeBody) and FFI bindings (ExternalBody) are now treated as value definition bodies rather than expressions.
  10. Morphir IR Schema Version 1 Overview

    main
    Version 1 of the Morphir Intermediate Representation (IR) is the original format. It is characterized by the use of lowercase tags for all constructs, including distribution types, access control, type tags, value expressions, pattern tags, and literal tags. This differs from later versions which may use different capitalization or structures.
  11. Understand the Morphir IR Schema Version 3

    main

    Morphir IR Schema Version 3 is the current standard for the Morphir Intermediate Representation (IR). It is characterized by a consistent use of capitalized tags for all constructs (e.g., "Library", "Public", "Variable", "Apply").

    Version 3 follows the formatVersion contract. The integer 3 is an alias for exactly 3.0.0. While 3.0.0 is a valid baseline string, later releases (like 3.1.0) require strict three-component release strings. Canonical writers should emit the integer 3 for version 3.0.0 and use the full string for any version with a non-zero minor or patch component.

  12. Understand Morphir Go backend requirements and scope

    main

    The finos/morphir-go project is a backend for the Morphir ecosystem designed to generate Go code from Morphir IR.

    Note: This backend is maintained in its own repository (finos/morphir-go) and is not part of the main finos/morphir umbrella repository.

    Project Scope

    • Goal: Convert Morphir IR into Go modules or workspaces that align with the Morphir IR specification.
    • MVP Focus: Generation (IR $\rightarrow$ Go), module/workspace scaffolding, and basic pipeline integration (make/gen/build).
    • Non-Goals (MVP): The backend does not provide a full runtime/execution framework, comprehensive packaging policies, or automatic code formatting/linting (these should be handled by downstream Go tools).