dgraph Documentation

High-performance graph database for real-time use cases

21,771 stars Go Go 1 file Β· ~3,291 tokens #database#distributed#go#knowledge-graph
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy dgraph on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name dgraph --restart always dgraph-io/dgraph:latest

1. Project Overview & Quickstart (dgraph-io/dgraph)




Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It provides
ACID transactions, consistent replication, and linearizable reads. It's built from the ground up to
perform a rich set of queries. Being a native GraphQL database, it tightly controls how the data is
arranged on disk to optimize for query performance and throughput, reducing disk seeks and network
calls in a cluster.

Dgraph's goal is to provide Google production-level scale and throughput, with low enough latency to
serve real-time user queries over terabytes of structured data. Dgraph supports
GraphQL query syntax, and responds in JSON
and Protocol Buffers over
GRPC and HTTP. Dgraph is written using the Go Programming Language.

Status

Dgraph is at version v25 and is production-ready. Apart from the vast open source community,
it is being used in production at multiple Fortune 500 companies.

Supported Platforms

Dgraph officially supports the Linux/amd64 and Linux/arm64 architectures. In order to take advantage
of memory performance gains and other architecture-specific advancements in Linux, we dropped
official support for Mac and Windows in 2021, see
this blog post for more
information. You can still build and use Dgraph on other platforms (for live or bulk loading for
instance), but support for platforms other than Linux/amd64 and Linux/arm64 is not available.

Running Dgraph in a Docker environment is the recommended testing and deployment method.

Install with Docker

If you're using Docker, you can use the
official Dgraph image.

bash
docker pull dgraph/dgraph:latest

For more information on a variety Docker deployment methods including Docker Compose and Kubernetes,
see the docs.

Run a Quick Standalone Cluster

bash
docker run -it -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph dgraph/standalone:latest

Install from Source

If you want to install from source, install Go 1.27+ or later and the following dependencies:

Ubuntu

bash
sudo apt-get update
sudo apt-get install build-essential

Build and Install

Then clone the Dgraph repository and use make install to install the Dgraph binary in the
directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if
the GOPATH environment variable is not set.

bash
git clone https://github.com/dgraph-io/dgraph.git
cd dgraph
make setup
make install

Get Started

To get started with Dgraph, follow:

Is Dgraph the right choice for me?

  • Do you have more than 10 SQL tables connected via foreign keys?
  • Do you have sparse data, which doesn't elegantly fit into SQL tables?
  • Do you want a simple and flexible schema, which is readable and maintainable over time?
  • Do you care about speed and performance at scale?

If the answers to the above are YES, then Dgraph would be a great fit for your application. Dgraph
provides NoSQL like scalability while providing SQL like transactions and the ability to select,
filter, and aggregate data points. It combines that with distributed joins, traversals, and graph
operations, which makes it easy to build applications with it.

Dgraph compared to other graph DBs

Features Dgraph Neo4j Janus Graph
Architecture Sharded and Distributed Single server (+ replicas in enterprise) Layer on top of other distributed DBs
Replication Consistent None in community edition (only available in enterprise) Via underlying DB
Data movement for shard rebalancing Automatic Not applicable (all data lies on each server) Via underlying DB
Language GraphQL inspired Cypher Gremlin
Protocols Grpc / HTTP + JSON / RDF Bolt + Cypher Websocket / HTTP
Transactions Distributed ACID transactions Single server ACID transactions Not typically ACID
Full-Text Search Native support Native support Via External Indexing System
Regular Expressions Native support Native support Via External Indexing System
Geo Search Native support External support only Via External Indexing System
License Apache 2.0 GPL v3 Apache 2.0

Users

Developers

Please see Contributing to Dgraph
for guidelines on contributions.

Client Libraries

The Dgraph team maintains several
officially supported client libraries. There are also libraries
contributed by the community
unofficial client libraries.

Contact

2. Official Technical Reference & Guides (dgraph-io/dgraph-docs)

Dgraph Documentation

To read the official Dgraph documentation that is published from this repository,
please see https://docs.dgraph.io/.

Technology Stack

This documentation site is built with Docusaurus, a modern static website generator optimized for documentation.

Documentation Structure

The documentation is organized into four main sections, each managed by its own Docusaurus content plugin:

  1. Docs (/) - Core Dgraph database documentation including DQL, administration, installation, and design concepts
  2. GraphQL (/graphql) - GraphQL API documentation, schema, queries, mutations, and custom resolvers
  3. Ratel UI (/ratel) - Documentation for the Ratel web-based UI tool
  4. Tutorials (/learn) - Step-by-step tutorials and learning paths for different user types

Each section has its own sidebar navigation configured in:

  • sidebars.ts - Docs sidebar
  • sidebars-graphql.ts - GraphQL sidebar
  • sidebars-ratel.ts - Ratel sidebar
  • sidebars-learn.ts - Tutorials sidebar

Running Locally

Prerequisites

  • Node.js version 20.0 or higher
  • npm or yarn package manager

Setup and Run

  1. Navigate to the Docusaurus directory:

    bash
    cd docusaurus-docs
  2. Install dependencies:

    bash
    npm install
  3. Start the development server:

    bash
    npm start
  4. Open http://localhost:3000 in your browser.

The site will automatically reload when you make changes to the documentation files.

Build for Production

To build a production-ready static site:

bash
npm run build

The built site will be in the build/ directory. You can serve it locally with:

bash
npm run serve

Testing the current version

When testing locally you can set

text
includeCurrentVersion: true,

in the docs or graphql plugin in docusaurus.config.ts.

This will expose next in the version selector, so you can view the current (non versioned) documentation.

Versioning

Documentation is versioned for the docs and graphql sections. Versioned content lives in:

  • docs_versioned_docs/ and docs_versioned_sidebars/ (and docs_versions.json)
  • graphql_versioned_docs/ and graphql_versioned_sidebars/ (and graphql_versions.json)

The folders docs/ and docs-graphql/ are the β€œnext” (unreleased) content. They appear in the version dropdown as β€œnext” only when running the site locally with includeCurrentVersion: true in docusaurus.config.ts. When deployed, the site serves only versioned documentation (e.g. v25.4, v25.3, v25.2); the β€œnext” content is not shown on the live site.

Where to edit:

  • For the next release: Edit the page in docs/ or docs-graphql/. Those are the only places that represent the upcoming release.
  • For the current release (what’s live): Apply the same change in the corresponding versioned folder (e.g. docs_versioned_docs/version-v25.4/... or graphql_versioned_docs/version-v25.4/... for the latest). If a fix or clarification should be in the current release, duplicate the change there.

Note for reviewers: The β€œEdit this page” link always points to the β€œnext” page (docs/ or docs-graphql/). When reviewing PRs, check whether the change should also be ported back to the current version’s versioned folder.

To create a new version:

  1. Use the Docusaurus CLI:
    npm run docusaurus docs:version:docs <version>
    npm run docusaurus docs:version:graphql <version>
  2. This creates a new version snapshot of the current docs

Deployment

The documentation site is automatically deployed to CloudFlare:

  • Main branch (main) β†’ Deployed to production at https://docs.dgraph.io
  • Preview branches (preview/*) β†’ Deployed as preview deployments for review

The deployment process is handled automatically via CloudFlare Pages integration with GitHub.

Contribution Guidelines

As a contributor to Dgraph documentation, we ask that you do the following:

  • Label your PR for easy management: Your PR title should be in the following format: Topic (area): details. The topic is either "Docs", "Nav" (aka, navigation), or "Chore" (for build fixes, cherry-picks, etc). The area is the feature (i.e. "GraphQL"), area of the docs (i.e., "Deployment"), or "Other" (for typo fixes and other bugfix PRs). So, example PR names include:
    Docs(GraphQL): Document the @deprecated annotation

  • Technical writing style: As much as possible, please follow technical writing style conventions (More on this below).

  • (Dgraph core team only): Include the ID of any issues/tickets related to your PR in the description (i.e., "Fixes DGRAPH-12345" or "Per DGRAPH-54321").

Technical Writing Style

Please follow the Dgraph Documentation Style Guide for writing conventions, formatting, and best practices.

Note: Please don't let these style conventions stop you from creating a PR to share your contribution to Dgraph Docs! PR reviewers can help with style guide issues.

References

In Docusaurus, use standard Markdown links for internal references. For example, to reference a term in the glossary:

markdown
[UID](/dgraph-glossary#uid)

File Structure

text
docusaurus-docs/
β”œβ”€β”€ docs/              # Main documentation content
β”œβ”€β”€ docs-graphql/      # GraphQL documentation
β”œβ”€β”€ docs-ratel/        # Ratel UI documentation
β”œβ”€β”€ docs-learn/        # Tutorials and learning content
β”œβ”€β”€ docs_versioned_docs/    # Versioned documentation snapshots
β”œβ”€β”€ sidebars.ts        # Main docs sidebar configuration
β”œβ”€β”€ sidebars-graphql.ts     # GraphQL sidebar configuration
β”œβ”€β”€ sidebars-ratel.ts       # Ratel sidebar configuration
β”œβ”€β”€ sidebars-learn.ts       # Tutorials sidebar configuration
β”œβ”€β”€ docusaurus.config.ts    # Main Docusaurus configuration
└── src/               # Custom components and styles