{"id":21108485,"url":"https://github.com/zalopay-oss/zpd","last_synced_at":"2025-07-08T16:32:13.861Z","repository":{"id":40550869,"uuid":"224555243","full_name":"zalopay-oss/zpd","owner":"zalopay-oss","description":"A simple SQL-like database built on top of Key-Value storages","archived":false,"fork":false,"pushed_at":"2023-07-06T01:40:53.000Z","size":18822,"stargazers_count":22,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-07T18:14:02.265Z","etag":null,"topics":["golang","grpc","sql"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalopay-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-28T02:36:22.000Z","updated_at":"2023-11-21T02:13:01.000Z","dependencies_parsed_at":"2022-07-26T15:32:28.413Z","dependency_job_id":null,"html_url":"https://github.com/zalopay-oss/zpd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalopay-oss%2Fzpd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalopay-oss%2Fzpd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalopay-oss%2Fzpd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalopay-oss%2Fzpd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalopay-oss","download_url":"https://codeload.github.com/zalopay-oss/zpd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225449610,"owners_count":17476095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grpc","sql"],"created_at":"2024-11-20T00:47:02.084Z","updated_at":"2024-11-20T00:47:02.764Z","avatar_url":"https://github.com/zalopay-oss.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZPD\n\n![Build Status](https://img.shields.io/badge/build-passing-brightgreen)\n![Coverage Status](https://img.shields.io/badge/coverage-90%25-green)\n[![version](https://img.shields.io/badge/repo%20status-active-brightgreen)](https://github.com/zalopay-oss/zpd)\n[![version](https://img.shields.io/badge/contributors-2-blueviolet)](#tham-gia-phát-triển)\n[![version](https://img.shields.io/badge/open%20issues-0-red)](https://github.com/zalopay-oss/zpd/issues)\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./images/model_overview_zpd.png\" width=500\u003e\n\u003c/div\u003e\n\n- [ZPD](#zpd)\n  - [Overview](#overview)\n  - [Architecture](#architecture)\n  - [Requirement](#requirement)\n  - [Install](#install)\n  - [Build](#build)\n  - [Run](#run)\n  - [Test](#test)\n  - [Document](#document)\n  - [Contribution](#contribution)\n  - [Acknowledgments](#acknowledgments)\n  - [License](#license)\n\n## Overview\n\nZPD (or ZaloPay Database) is a probationary challenge performed at ZaloPay. It's an `experiment` to gain deep knowledge about handling simple SQL queries and how to glue them with a key-value storage.\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./images/flow-ZPD.png\"\u003e\n\u003c/div\u003e\n\nZPD is implemented using Golang as a gRPC service and built on top of following frameworks:\n\n- [Consul](https://www.consul.io/) for leader elections. \n\n- [TiKV](https://github.com/tikv/tikv) as the main key-value storage \n\n\n## Architecture\n\nThe architecture of the ZPD:\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./images/zpd_layer.png\" width=\"250\"\u003e\n\u003c/div\u003e\n\nIncluding layers:\n\n- Connection layer\n- Parser layer\n- Core layer:\n  - Executor\n  - Consul Agent\n  - Bridge API\n- Data access layer\n- Storage:\n  - TiKV client layer\n\nSee the architecture of ZPD [here](./docs/architecture.md).\n\n## Requirement\n- Golang version \u003e= 1.12\n- gRPC\n- Docker version \u003e= 17.06 and Docker Compose\n- Locust\n\n## Install\n- Install [Golang](https://golang.org/doc/install)\n- Install [gRPC](https://grpc.io/docs/quickstart/go/)\n- Install [Docker](https://docs.docker.com/get-started/)\n- Install [Locust](https://locust.io/)\n- Install TiKV and PD using [Docker Compose](https://tikv.org/docs/3.0/tasks/deploy/docker-compose/)\n- Install Consul bằng [Docker](https://hub.docker.com/_/consul).\n\n## Build\n\nClone this project:\n\n```sh\n# Clone\n$ git clone https://gitlab.zalopay.vn/zpx-core-team/tidb-internals.git\n```\n\n## Run\n\nZPD, PD, TiKV, Consul are all built with Docker compose. Just go to the docker-compose folder and run docker-compose up.\n\n```sh\n# go to the folder docker-compose\n$ cd ./tidb-layer/source/docker-compose\n\n# Run docker-compose\n$ docker-compose up\n```\n\n## Test\n\nMust run ZPD as the section above, then run tests of the APIs:\n\n```sh\n# go to cmd/client\n$ cd ./tidb-layer/source/cmd/client\n\n# run tests\n$ go test -run TestClientExecuteCreateDB \n```\n\n- You can write more tests into `client_test.go`  like the available format.\n\n## Document\n\nRead more document about ZPD:\n\n- [Specific description](./docs/specific-description.md)\n- [Sequence diagram](./docs/sequence-diagram.md)\n- [Architecture ZPD](./docs/architecture.md)\n- [Overview ZPD](docs/overview-ZPD.md)\n\nRead blogs:\n\n- [SQL Planning: Parser \u0026 Optimizer](https://medium.com/zalopay-engineering/sql-planning-parser-optimizer-ee118a9705ed)\n- [SWIM: Protocol of friends](https://medium.com/zalopay-engineering/https-medium-com-zalopay-engineering-swim-giao-thuc-cua-nhung-nguoi-ban-8df88e68d816)\n- [Building a SQL Database using key-value storage](https://medium.com/zalopay-engineering/xay-dung-sql-service-su-dung-tikv-5c5adb63c885)\n\n## Contribution\n\nThis project was built by [AJPham](https://github.com/phamtai97) and [Alex Nguyen](https://github.com/quocanh1897) under the guidance from [Anh Le (Andy)](https://github.com/anhldbk).\n\n## Acknowledgments\n\n- This project used open source:\n  - [xwb1989/sqlparser](https://github.com/xwb1989/sqlparser): a SQL parser.\n  - [Consul](https://github.com/hashicorp/consul): handle leader election.\n  - [PingCap](https://github.com/pingcap): support PD and TiKV parts.\n\n## License\n\nSee the [LICENSE](./LICENSE) file for license rights and limitations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalopay-oss%2Fzpd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalopay-oss%2Fzpd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalopay-oss%2Fzpd/lists"}