Giter Club home page Giter Club logo

go-dgraph-starter's Introduction

go-dgraph-starter

Table of Contents

  1. Introduction
    1. In Progress
    2. Tools
      1. Protocol Buffers
      2. gRPC
      3. GraphQL
      4. Dgraph
      5. Sqlboiler
      6. Meilisearch
    3. Patterns
      1. Cursor pagination
      2. Garden
      3. Change Data Capture

TOC generated with

docker run -v $PWD:/app -w /app --rm -it pbzweihander/markdown-toc README.md --min-depth 1 

Introduction

forthebadge

This is a Todo List app built with Dgraph-backed gRPC and GraphQL APIs, combined with a NextJS + Chakra-UI powered front-end.

In Progress

This project is still very much in progress.

https://github.com/kevinmichaelchen/go-dgraph-starter/projects/1

Tools

Protocol Buffers

Protocol buffers are a great choice for a language-neutral representation of your data models.

They are binary, lean, and fast to serialize when compared with JSON.

Their extensibility comes from the fact that you can add or remove fields in a way while maintaining backwards compatibilty.

Code generation makes it easy to generate your models in any language.

gRPC

gRPC is a lean transport system (typically paired with HTTP/2) meant to reduce latency and payload size.

HTTP/2 allows for long-lived connections (fewer handshakes).

Unlike REST, gRPC uses an HTTP POST method for all calls, and doesn't specify the resource in its URL, which means edge caching is impossible.

gRPC is also binary, so it's not as easy to debug than something human-readable, like GraphQL. But it is excellent for internal calls between microservices.

GraphQL

GraphQL is an ideal query language for APIs, especially when consumed by web clients. It's typically human-readable (JSON). Clients can specify exactly which fields they want. GraphiQL is an amazing tool for gaining insight into what an API offers.

It also can make you think about your data as a graph.

Dgraph

Dgraph is a popular open-source, fast, distributed graph database written in Golang. You get high throughput and low latency for deep joins and complex traversals. It offers a query language that is a superset of GraphQL.

Graph databases in general prioritize relationships between data points, rather than the data points themselves.

Performance: SQL performance suffers the more joins you ask it to do.

Flexibility / Complexity: Like NoSQL, the schema can be modified easily with time. Adding new relationships is as simple as adding a predicate. No need to create join tables. Ultimately, the graph model is more simpler / more intuitive.

Sqlboiler

It's not currently used in this project, but it's worth mentioning Sqlboiler since I believe it is by far the best SQL ORM for Golang due its "data-first" approach: it auto-generates Go code based on your existing schema and as a result you get extreme type safety.

For services that aren't expected to have a whole lot of data relationships, SQL is still an excellent choice, and sqlboiler is an ideal ORM for keeping your persistence layer code strongly typed.

Meilisearch

We use MeiliSearch as our "open source, blazingly fast and hyper relevant search-engine."

Per their site, MeiliSearch is effective and accessible:

Efficient search engines are often only accessible to companies with the financial means and resources necessary to develop a search solution adapted to their needs. The majority of other companies that do not have the means or do not realize that the lack of relevance of a search greatly impacts the pleasure of navigation on their application, end up with poor solutions that are more frustrating than effective, for both the developer and the user.

Patterns

Cursor pagination

Garden

The problem: developers will not bother with running CI tests and integration tests locally; instead they'll push to their GitHub PR and let the CI system take care of it.

Not only are they deprived of a production-like system on their local machines, but the feedback loop is too slow: having CircleCI run all the end-to-end tests takes too long.

Garden fixes all of this and breaks down the barrier between dev, testing, and CI.

For shops with hundreds or thousands of microservices, I can see the argument that it's excessive (or even impossible) to run the whole system on your local machine. That said, maybe there's a term for a subset of services that are related, and maybe it's worth running those on Garden.

Change Data Capture

In a distributed system, when events occur in one service, they need to eventually be broadcast to other services. Too often, I've seen an event get emitted inside a database transaction, regardless of whether that transaction succeeds or fails. The transactional outbox pattern offers a way to keep data across services in sync.

go-dgraph-starter's People

Contributors

kevinmichaelchen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

go-dgraph-starter's Issues

Check out Buf

Buf is a better way to work with Protocol Buffers. I'm interested in linting and breaking change detection.

Meilisearch

MeiliSearch is an "open source, blazingly fast and hyper relevant search-engine."

Per their site, MeiliSearch is effective and accessible:

Efficient search engines are often only accessible to companies with the financial means and resources necessary to develop a search solution adapted to their needs. The majority of other companies that do not have the means or do not realize that the lack of relevance of a search greatly impacts the pleasure of navigation on their application, end up with poor solutions that are more frustrating than effective, for both the developer and the user.

We use the official Go SDK.

  • Add MeiliSearch to docker-compose file. See #14.
  • Update the search index when a Todo is created. See #14.
  • Update the search index when a Todo is updated
  • Update the search index when a Todo is deleted
  • Add GraphQL query, gRPC endpoint, and service layer function to support searching for Todos.
  • Use the Transactional Outbox pattern rather than updating the search index after the database transaction commits.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.