Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: deployment guide, with supporting config and integrations. #1836

Merged
merged 62 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5a3e5dc
docs: add sync service configuration docs.
thruflo Oct 11, 2024
b4b6f73
docs: move integrations up a level.
thruflo Oct 11, 2024
e25c6fd
docs: flesh out deployment guide.
thruflo Oct 11, 2024
719307f
docs: add caching section to HTTP API page.
thruflo Oct 21, 2024
aae1860
docs: reduce default value for `DB_POOL_SIZE`.
thruflo Oct 21, 2024
3f88eff
docs: add nginx syntax highlighting to theme.
thruflo Oct 21, 2024
8c807a8
docs: add missing images.
thruflo Oct 21, 2024
b89a925
docs: flesh out the deployment guide
thruflo Oct 21, 2024
92c6c35
website: update post-sign-up CTAs.
thruflo Oct 21, 2024
de2e3a4
docs: structure the new integrations section.
thruflo Oct 21, 2024
1e0f4f1
docs: LiveStore integration page.
thruflo Oct 21, 2024
d055b09
docs: MobX integration page.
thruflo Oct 21, 2024
2aeba0d
docs: MobX integration page.
thruflo Oct 21, 2024
2163d03
docs: copy tweaks to LiveStore integration page.
thruflo Oct 21, 2024
920a86f
docs: copy tweaks to MobX integration page.
thruflo Oct 21, 2024
faddc03
docs: stub Next.js integration page.
thruflo Oct 21, 2024
18a8ecf
docs: update the Elixir Client api docs page.
thruflo Oct 21, 2024
89bc6b6
docs: Phoenix integration page.
thruflo Oct 21, 2024
40e064c
docs: add help wanted to Phoenix integration page.
thruflo Oct 22, 2024
1f0713c
docs: update the Typescript client docs.
thruflo Oct 22, 2024
e4391f4
docs: flesh out the React integration page.
thruflo Oct 22, 2024
dc70fe2
docs: refactor HelpWanted component.
thruflo Oct 22, 2024
c0082b3
docs: redis integration page.
thruflo Oct 22, 2024
f232507
docs: TanStack integration page.
thruflo Oct 22, 2024
8dff3d9
docs: fix .env file syntax highlighting.
thruflo Oct 22, 2024
7347e2f
docs: fix missing link.
thruflo Oct 22, 2024
c4f5a30
docs: AWS integration page.
thruflo Oct 23, 2024
bb7269a
docs: Cloudflare integration page.
thruflo Oct 23, 2024
0186633
docs: Cloudflare copy tweak.
thruflo Oct 23, 2024
3287e3a
docs: Digital Ocean integration page.
thruflo Oct 23, 2024
b2bfe52
docs: Expo integration page.
thruflo Oct 23, 2024
b3ee788
docs: Fly.io integration page.
thruflo Oct 23, 2024
0781c44
docs: GCP integration page.
thruflo Oct 23, 2024
0918e50
docs: add dbuser note to Digital Ocean integration page.
thruflo Oct 23, 2024
df0fdf9
docs: typos and copy tweaks.
thruflo Oct 23, 2024
78eeb42
docs: Neon integration page.
thruflo Oct 24, 2024
635b85a
docs: tweak Neon to Render link.
thruflo Oct 24, 2024
863db7d
docs: Netlify integration page.
thruflo Oct 24, 2024
105aec3
docs: fix links on Netlify page.
thruflo Oct 24, 2024
b2ae870
docs: add Supabase integration page.
thruflo Oct 24, 2024
53b383a
docs: integration doc tweaks.
thruflo Oct 24, 2024
de8d922
docs: add Render integration page.
thruflo Oct 24, 2024
27e054b
docs: copy tweaks for Render integration page.
thruflo Oct 25, 2024
05aa9c9
docs: tweaks for Digital Ocean integration page.
thruflo Oct 25, 2024
5e66294
docs: Crunchy integration page.
thruflo Oct 25, 2024
4954a14
docs: add `Need context?` tip to deployment integrations.
thruflo Oct 25, 2024
46f2fef
docs: api config, fix env var description formatting.
thruflo Oct 31, 2024
ae164e6
docs: address deployment page review comments.
thruflo Oct 31, 2024
40aaf91
docs: address cloudflare page review comments.
thruflo Oct 31, 2024
2be91e6
docs: remove the word Normative.
thruflo Oct 31, 2024
a163be8
docs: version 14+.
thruflo Oct 31, 2024
7443a0f
docs: GCP IPv6 warning.
thruflo Oct 31, 2024
29965d9
docs: explain why Supabase needs direct access URL.
thruflo Oct 31, 2024
a7547a3
docs: add `LOG_OTP_REPORTS` env var.
thruflo Nov 4, 2024
15c1614
Fix deployment guide
KyleAMathews Nov 5, 2024
fd74971
Update config page for ENVIRONMENT_
KyleAMathews Nov 5, 2024
37ec044
update render.md
KyleAMathews Nov 5, 2024
a6f2bfc
docs: fix code paths.
thruflo Nov 5, 2024
c27b42e
docs: fix shape options to use seperate `table`.
thruflo Nov 5, 2024
d3848c0
docs: add integration header images.
thruflo Nov 5, 2024
49e5e5f
docs: address review comments.
thruflo Nov 5, 2024
0bc678c
docs: fix rebase artefact.
thruflo Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions website/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default defineConfig({
'css',
'javascript',
'jsx',
'nginx',
'shellscript',
'sql',
'tsx',
Expand Down Expand Up @@ -147,8 +148,8 @@ export default defineConfig({
items: [
{ text: 'Auth', link: '/docs/guides/auth' },
{ text: 'Shapes', link: '/docs/guides/shapes' },
{ text: 'Deployment', link: '/docs/guides/deployment' },
{ text: 'Installation', link: '/docs/guides/installation' },
{ text: 'Deployment', link: '/docs/guides/deployment' },
{ text: 'Troubleshooting', link: '/docs/guides/troubleshooting' },
{ text: 'Writing your own client', link: '/docs/guides/writing-your-own-client' },
]
Expand All @@ -166,21 +167,46 @@ export default defineConfig({
],
collapsed: false
},
{ text: 'Config', link: '/docs/api/config' }
]
},
{
text: 'Integrations',
collapsed: false,
items: [
{
text: 'Integrations',
text: 'Frameworks',
items: [
// { text: 'MobX', link: '/docs/api/integrations/mobx' },
{ text: 'React', link: '/docs/api/integrations/react' },
// { text: 'Redis', link: '/docs/api/integrations/redis' },
// { text: 'TanStack', link: '/docs/api/integrations/tanstack' },
{ text: 'LiveStore', link: '/docs/integrations/livestore' },
{ text: 'MobX', link: '/docs/integrations/mobx' },
{ text: 'Next.js', link: '/docs/integrations/next' },
{ text: 'Phoenix', link: '/docs/integrations/phoenix' },
{ text: 'React', link: '/docs/integrations/react' },
{ text: 'Redis', link: '/docs/integrations/redis' },
{ text: 'TanStack', link: '/docs/integrations/tanstack' },
],
collapsed: false
},
{
text: 'Platforms',
items: [
{ text: 'AWS', link: '/docs/integrations/aws' },
{ text: 'Cloudflare', link: '/docs/integrations/cloudflare' },
{ text: 'Crunchy', link: '/docs/integrations/crunchy' },
{ text: 'Digital Ocean', link: '/docs/integrations/digital-ocean' },
{ text: 'Expo', link: '/docs/integrations/expo' },
{ text: 'Fly.io', link: '/docs/integrations/fly' },
{ text: 'GCP', link: '/docs/integrations/gcp' },
{ text: 'Neon', link: '/docs/integrations/neon' },
{ text: 'Netlify', link: '/docs/integrations/netlify' },
{ text: 'Render', link: '/docs/integrations/render' },
{ text: 'Supabase', link: '/docs/integrations/supabase' }
]
}
]
},
{
text: 'Reference',
collapsed: true,
collapsed: false,
items: [
{ text: 'Alternatives', link: '/docs/reference/alternatives' },
{ text: 'Benchmarks', link: '/docs/reference/benchmarks' },
Expand Down
34 changes: 28 additions & 6 deletions website/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
--ddn-color: #D0BCFF;
--pglite-color: #F6F95C;

--vp-code-font-size: 0.925em;
--vp-code-bg: var(--vp-c-bg-elv);
--vp-code-color: #9ECBFF;
--vp-code-font-size: 0.875em;
--vp-font-family-base: OpenSauceOne, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--vp-font-family-mono: SourceCodePro, ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
Expand Down Expand Up @@ -421,22 +423,24 @@ a.no-visual:hover {
text-align: center;
font-weight: 600;
white-space: nowrap;
transition: color 0.25s, border-color 0.25s, background-color 0.25s;
transition: color 0.25s, border-color 0.25s, background-color 0.25s !important;
}
.VPButton.brand {
background-color: var(--vp-button-brand-bg);
border-color: var(--vp-button-brand-border);
color: var(--vp-button-brand-text);
color: var(--vp-button-brand-text) !important;
}
.VPButton.brand:hover {
background-color: var(--vp-button-brand-hover-bg);
border-color: var(--vp-button-brand-hover-border);
color: var(--vp-button-brand-hover-text);
color: var(--vp-button-brand-hover-text) !important;
opacity: 1 !important;
}
.VPButton.brand:active {
background-color: var(--vp-button-brand-active-bg);
border-color: var(--vp-button-brand-active-border);
color: var(--vp-button-brand-active-text);
color: var(--vp-button-brand-active-text) !important;
opacity: 1 !important;
}

.VPButton.electric,
Expand All @@ -451,6 +455,16 @@ a.no-visual:hover {
border-color: var(--pglite-color);
color: var(--vp-c-bg);
}
.VPButton.small {
border-radius: 16px;
padding: 0 16px;
line-height: 34px;
font-size: 13.5px;
}
.VPButton.vspace {
margin-top: 6px;
margin-bottom: 6px;
}

.img-row {
display: grid;
Expand Down Expand Up @@ -560,7 +574,10 @@ iframe {
.vp-doc .custom-block {
margin: 24px 0;
}

.custom-block {
border-radius: 12px;
padding: 19px 21px 11px;
}
.custom-block-no-title {
margin-bottom: 10px !important;
}
Expand All @@ -576,6 +593,11 @@ iframe {
padding: 24px 0 !important;
}

pre {
max-width: 100%;
overflow-x: scroll;
}

ul.benefits {
color: var(--vp-c-text-1) !important;

Expand Down
6 changes: 3 additions & 3 deletions website/blog/posts/2024-07-17-electric-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Electric Next was a clean rebuild of the Electric sync engine that now forms the

We created a new repo and started by porting the absolute minimum code necessary from the [previous repo](https://github.com/electric-sql/electric-old). Once we were confident that Electric Next was the way forward, we froze the old system and moved the new code into our main repo at [https://github.com/electric-sql/electric](https://github.com/electric-sql/electric).

The new approach provides an [HTTP API](/docs/api/http) for syncing [Shapes](/docs/guides/shapes) of data from Postgres. This can be used directly or via [client libraries](/docs/api/clients/typescript) and [integrations](/docs/api/integrations/react). It's also simple to write your own client in any language.
The new approach provides an [HTTP API](/docs/api/http) for syncing [Shapes](/docs/guides/shapes) of data from Postgres. This can be used directly or via [client libraries](/docs/api/clients/typescript) and [integrations](/docs/integrations/react). It's also simple to write your own client in any language.

## Why build a new system?

Expand Down Expand Up @@ -237,7 +237,7 @@ You can sync data into:

- apps, replacing data fetching with data sync
- development environments, for example syncing data into [an embedded PGlite](/product/pglite)
- edge workers and services, for example maintaining a low-latency [edge data cache](/docs/api/integrations/redis)
- edge workers and services, for example maintaining a low-latency [edge data cache](/docs/integrations/redis)
- local AI systems running RAG, as per the example below

<figure>
Expand Down Expand Up @@ -273,7 +273,7 @@ At the time of writing this document, we are early in the development of Electri
However, even just with the first release of Electric Next you can already sync partial subsets of data from a Postgres database into a wide variety of clients and environments, for example:

- syncing data into local apps using the [TypeScript](/docs/api/clients/typescript) and [Elixir](/docs/api/clients/elixir) clients
- replacing hot-path data fetching and database queries in apps using [React](/docs/api/integrations/react), [MobX](/docs/api/integrations/react) and [TanStack](/docs/api/integrations/tanstack)
- replacing hot-path data fetching and database queries in apps using [React](/docs/integrations/react), [MobX](/docs/integrations/react) and [TanStack](/docs/integrations/tanstack)
- maintain live caches with automatic invalidation, as per [our Redis example](https://github.com/electric-sql/electric/blob/main/examples/redis-sync/src/index.ts)

### Roadmap
Expand Down
47 changes: 37 additions & 10 deletions website/docs/api/clients/elixir.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,51 @@
outline: deep
---

# Elixir Client
# Elixir client

The Elixir client is being developed in [electric-sql/electric-next/pull/38](https://github.com/electric-sql/electric-next/pull/38). At the moment it provides a GenStage producer that can be used to stream a Shape as per:
Electric provides an [Elixir client](#how-to-use) that wraps the [HTTP API](/docs/api/http) into a higher-level stream interface and a [Phoenix integration](#phoenix-integration) that adds sync to your Phoenix application.

## How to use

The [`Electric.Client`](https://hex.pm/packages/electric_client) library allows you to stream [Shapes](/docs/guides/shapes) into your Elixir application. It's published to Hex as the [`electric_client`](https://hex.pm/packages/electric_client) package.

### Stream

The client exposes a [`stream/3`](https://hexdocs.pm/electric_client/Electric.Client.html#stream/3) that streams a [Shape Log](/docs/api/http#shape-log) into an [`Enumerable`](https://hexdocs.pm/elixir/Enumerable.html):

```elixir
opts = [
base_url: "http://...",
shape_definition: %Electric.Client.ShapeDefinition{
table: "..."
}
]
Mix.install([:electric_client])

{:ok, pid, stream} = Electric.Client.ShapeStream.stream(opts)
{:ok, client} = Electric.Client.new(base_url: "http://localhost:3000")

stream = Electric.Client.stream(client, "my_table", where: "something = true")

stream
|> Stream.each(&IO.inspect/1)
|> Stream.run()
```

See the [shape_stream_test.exs](https://github.com/electric-sql/electric-next/blob/thruflo/elixir-client/elixir_client/test/electric/client/shape_stream_test.exs) for more details.
You can materialise the shape stream into a variety of data structures. For example by matching on insert, update and delete operations and applying them to a Map or an Ecto struct. (See the [redis-sync](https://github.com/electric-sql/electric/blob/main/examples/redis-sync/src/index.ts) example and Typescript [Shape class](https://github.com/electric-sql/electric/blob/main/packages/typescript-client/src/shape.ts) for reference).

### Ecto queries

The `stream/3` function also supports deriving the shape definition from an [`Ecto.Query`](https://hexdocs.pm/ecto/Ecto.Query.html):

```elixir
import Ecto.Query, only: [from: 2]

query = from(t in MyTable, where: t.something == true)

stream = Electric.Client.stream(client, query)
```

See the documentation at [hexdocs.pm/electric_client](https://hexdocs.pm/electric_client) for more details.

## Phoenix integration

Electric also provides an [`Electric.Phoenix`](https://hex.pm/packages/electric_phoenix) integration allows you to:

- sync data into a [front-end app](/docs/integrations/phoenix#front-end-sync) from a Postgres-backed Phoenix application; and
- add real-time streaming from Postgres into Phoenix LiveView via [Phoenix.Streams](/docs/integrations/phoenix#liveview-sync)

See the [Phoenix framework integration page](/docs/integrations/phoenix) for more details.
Loading