Membrane Documentation

website·Indexed 32 days ago

https://docs.membrane.io

A stateful serverless runtime for building applications, utilities, and internal tools with TypeScript. Features include a graph-based API, a custom JSX dashboard, a Web IDE, and the mctl CLI. The platform provides built-in support for durable programs, state management, HTTP endpoints, and integrations with third-party APIs and databases like PostgreSQL, MySQL, and Microsoft SQL Server.

Tokens
22.3K
Snippets
118
Records
211
Agent score
58%

What's inside Membrane

  1. Overview of Membrane features and capabilities

    Membrane is a TypeScript environment designed for rapidly building applications and internal tools. Its core differentiating features include:

    • Durable Programs: State is maintained in a state object, removing the need for external database storage and loading.
    • Unified Graph: Provides a standardized way to access external APIs without requiring specific SDKs or deep API documentation.
    • Write-Ahead Logging: All actions are recorded in semantically rich logs, ensuring observability and the ability to rerun actions.
    • Built-in Communication: Every program is automatically assigned a domain name and email address. Developers can export endpoint or email functions to create HTTP or email automations.
    • Scheduling: Built-in support for cronjobs to run functions on a schedule.
    • Developer Tooling: Includes visual state exploration tools, instant deployments, a built-in REPL, and SMS integration.
  2. Overview of Membrane platform capabilities

    Membrane is a TypeScript environment designed for building applications, utilities, and internal tools. It provides several built-in features that differentiate it from standard JS/TS environments:

    • Durable Programs: State is maintained in a state object, removing the need for external database storage and loading.
    • Unified Graph: Provides a standardized way to access external APIs without requiring specific SDKs or deep API documentation.
    • Semantic Observability: Uses a write-ahead log for all actions, allowing for rich logging and the ability to rerun actions.
    • Integrated Communication: Every program is assigned its own domain name and email address. Developers can export endpoint or email functions to handle HTTP requests and emails.
    • Scheduling: Built-in support for cronjobs to run functions on a schedule.
    • Developer Tooling: Includes visual state exploration tools, instant deployments, a built-in REPL, and SMS integration.
  3. Overview of Membrane Dashboard custom JSX

    The Membrane dashboard uses a custom JSX implementation for building user interfaces. It utilizes a flex layout system, meaning standard CSS Flexbox concepts apply to its styling and positioning.
  4. Overview of Membrane Dashboard JSX

    The Membrane dashboard uses a custom JSX implementation for UI layout. It utilizes a flex layout system, meaning standard CSS Flexbox mental models apply to its styling.
  5. Understand Membrane's durable runtime and state persistence

    Membrane programs run in a durable runtime that transparently persists the entire memory heap to disk. This eliminates the need for developers to manually persist data to a database or file. Key characteristics include:

    • No Timeouts: Programs can run indefinitely and are not killed due to execution time limits.
    • State Continuity: When code is updated, the new version continues execution using the existing state.
    • Efficient Resource Use: Idle programs consume no CPU or memory; Membrane lazily restores only the necessary parts of the heap upon activation (e.g., during an HTTP request) to ensure fast cold-starts.
  6. Understand Membrane Packages and Programs

    Code sharing in Membrane is handled via a package registry. Packages are published using the naming convention <username>/<program>. When a package is installed into a workspace, it is instantly deployed as a 'program', which can then be modified or republished by the user.
  7. Understand Membrane Actions

    Actions in Membrane are functions that can be invoked on a graph node. While field queries map to read operations (similar to GET requests), action invocations map to write operations or side effects (similar to POST, PUT, or DELETE requests).
  8. Understand Membrane schema components

    A program's schema defines the types of nodes exposed in its graph. Each type consists of 'members', which include:

    • Fields: Values that can be queried (can be scalars, lists, grefs, or other object types).
    • Actions: Functions with side effects that can be invoked on the node.
    • Events: Subscribable notifications that other programs can listen to.
  9. Understand architectural differences between Membrane and Node.js

    While Membrane programs use TypeScript/JavaScript, they differ from standard Node.js or browser environments in three primary ways:

    1. Durability: Programs are durable. Instead of external databases or files, use the state object for storage. Actions can run indefinitely (e.g., awaiting an email reply).
    2. Event-Sourcing: Programs use a write-ahead log to record all effects. Actions are only guaranteed to have occurred if they are present in these logs.
    3. Graph-Based Communication: All communication, including fetch requests, is implemented via graph nodes.
  10. Understand Membrane Actions

    Actions in Membrane are functions that can be invoked on a graph node. While field queries map to read operations (similar to GET requests), action invocations map to write operations or side effects (similar to POST, PUT, or DELETE requests).
  11. Use Brane AI assistant for Membrane development

    Brane is an AI assistant integrated into the Membrane sidebar that helps develop Membrane programs. It can retrieve information from programs, create or modify code, and assist in connecting programs. It is available at no additional cost during the beta period.
  12. Understand Membrane schema components

    A program's schema defines the types of nodes exposed in its graph. Each type consists of 'members' which fall into three categories:

    • Fields: Values that can be queried (can be scalars, lists, grefs, or other object types).
    • Actions: Functions with side effects that can be invoked on a node.
    • Events: Subscribable notifications that other programs can listen to.