Current section

Files

Jump to
ash_arcadic README.md
Raw

README.md

<!--
SPDX-FileCopyrightText: 2026 BaseLabs Holdings LLC

SPDX-License-Identifier: MIT
-->

# AshArcadic

[![CI](https://github.com/baselabs/ash_arcadic/actions/workflows/ci.yml/badge.svg)](https://github.com/baselabs/ash_arcadic/actions/workflows/ci.yml)
[![Hex version](https://img.shields.io/hexpm/v/ash_arcadic.svg)](https://hex.pm/packages/ash_arcadic)
[![HexDocs](https://img.shields.io/badge/docs-HexDocs-purple)](https://hexdocs.pm/ash_arcadic)
[![REUSE status](https://api.reuse.software/badge/github.com/baselabs/ash_arcadic)](https://api.reuse.software/info/github.com/baselabs/ash_arcadic)
[![License: MIT](https://img.shields.io/hexpm/l/ash_arcadic.svg)](LICENSE)

AshArcadic is the [Ash Framework](https://hexdocs.pm/ash) data layer for
[ArcadeDB](https://arcadedb.com). Define Ash resources backed by an ArcadeDB
graph and use Ash actions to read and write them.

- Use Ash actions for graph records, including bulk writes and upserts.
- Load related records through graph edges and run ranked searches through read actions.
- Scope graph operations by tenant and enforce storage rules for sensitive attributes.
- Mirror PostgreSQL changes with the optional CDC sink, which commits its checkpoint
  with the corresponding graph writes.

## Installation

Add this dependency to your Ash application and run `mix deps.get`.

```elixir
{:ash_arcadic, "~> 3.0"}
```

## Example

Set `config :ash, default_string_length_count: :codepoints` if your application
has no string-length rule. Register `MyApp.Graph` in the application's
`:ash_domains` config. Use an existing ArcadeDB database. Set
`ARCADEDB_URL`, `ARCADEDB_DATABASE`, `ARCADEDB_USERNAME`, and `ARCADEDB_PASSWORD`
in the application's environment.

```elixir
defmodule MyApp.GraphClient do
  @behaviour AshArcadic.Client

  @impl true
  def conn do
    Arcadic.connect(
      System.fetch_env!("ARCADEDB_URL"),
      System.fetch_env!("ARCADEDB_DATABASE"),
      auth: {System.fetch_env!("ARCADEDB_USERNAME"), System.fetch_env!("ARCADEDB_PASSWORD")}
    )
  end
end

defmodule MyApp.Document do
  use Ash.Resource, domain: MyApp.Graph, data_layer: AshArcadic.DataLayer

  arcade do
    client MyApp.GraphClient
    label :Document
  end

  attributes do
    uuid_primary_key :id
    attribute :title, :string, allow_nil?: false
  end

  actions do
    default_accept [:title]
    defaults [:create, :read]
  end
end

defmodule MyApp.Graph do
  use Ash.Domain

  resources do
    resource MyApp.Document
  end
end
```

```elixir
Ash.create!(MyApp.Document, %{title: "Field notes"})
Ash.read!(MyApp.Document)
```

## Tutorials

- [Tour AshArcadic in Livebook](documentation/tutorials/tour.livemd)

## Topics

- [Resources and connections](documentation/topics/resources/resources.md)
- [Multitenancy and sensitive data](documentation/topics/resources/multitenancy.md)
- [Relationships and traversal](documentation/topics/resources/relationships.md)
- [Reads and expressions](documentation/topics/queries/reads.md)
- [Writes and transactions](documentation/topics/queries/writes.md)
- [Ranked search](documentation/topics/queries/ranked-search.md)
- [PostgreSQL change data capture](documentation/topics/replication/cdc.md)

## How-to

- [Troubleshoot an operation](documentation/how-to/troubleshooting.md)
- [Tune storage and indexing](documentation/how-to/performance.md)
- [Upgrade AshArcadic](documentation/how-to/upgrading.md)
- [Verify release archives](documentation/how-to/verify-release.md)

## Reference

- [Data layer DSL](documentation/dsls/DSL-AshArcadic.DataLayer.md)
- [CDC resource DSL](documentation/dsls/DSL-AshArcadic.Replicant.md)
- [Telemetry events](documentation/topics/operations/telemetry.md)
- [Usage rules](usage-rules.md)

## Compatibility

See [Compatibility](documentation/topics/about-ash-arcadic/compatibility.md) for supported toolchains, database versions, and dependency requirements.

## License

[MIT](LICENSE).