gitmyhub

electric

TypeScript ★ 10k updated 9h ago

The agent platform built on sync.

Electric is a sync engine that streams live data from a PostgreSQL database to clients in real time over HTTP, so web apps and AI agents can work with a local copy of data that stays automatically up to date as the database changes.

TypeScriptPostgreSQLHTTPReactDockersetup: moderatecomplexity 3/5

Electric is a sync engine for PostgreSQL databases. Its job is to copy data out of a Postgres database and deliver it to clients in real time, keeping everything up to date as the database changes.

The problem it addresses is that modern applications, particularly those built for speed and offline use, often need their own local copy of data rather than fetching everything from a server on each request. Setting up that kind of sync from scratch is complex: you have to decide what data each client should receive, handle changes as they happen, and do all of this without overloading the database or the network. Electric handles these concerns so application developers do not have to.

The core of Electric is an HTTP-based sync protocol. Clients request a stream of data using a simple HTTP call, and Electric pushes updates as they occur. Because it uses standard HTTP, the delivery layer can be placed behind a CDN for large-scale distribution. Developers who prefer not to work directly with the HTTP protocol can use client libraries for TypeScript or React hooks like useShape, which subscribe to a subset of a table and update automatically when data changes.

The subset of data a client receives is defined using a concept called Shapes. Rather than syncing an entire table to every client, you define a Shape that filters to the rows relevant to that client, which keeps data transfer manageable.

Electric is positioned for both web applications and AI agent systems that need to operate on live database data. It connects to Postgres via a standard database URL and requires logical replication to be enabled on the database. The project is licensed under Apache 2.0 and provides a Docker Compose setup for local development.

Where it fits