{"id":21170054,"url":"https://github.com/covenantsql/data-sharing-demo","last_synced_at":"2025-07-09T19:32:20.749Z","repository":{"id":39523825,"uuid":"189353100","full_name":"CovenantSQL/data-sharing-demo","owner":"CovenantSQL","description":"Data sharing demo built on CovenantSQL","archived":false,"fork":false,"pushed_at":"2023-01-03T23:44:15.000Z","size":6280,"stargazers_count":14,"open_issues_count":35,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T10:20:17.772Z","etag":null,"topics":["blockchain","covenantsql","data-sharing"],"latest_commit_sha":null,"homepage":"https://covenantsql.github.io/data-sharing-demo/","language":"JavaScript","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/CovenantSQL.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-05-30T05:46:15.000Z","updated_at":"2023-03-17T03:17:15.000Z","dependencies_parsed_at":"2023-02-01T14:02:20.788Z","dependency_job_id":null,"html_url":"https://github.com/CovenantSQL/data-sharing-demo","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/CovenantSQL%2Fdata-sharing-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CovenantSQL%2Fdata-sharing-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CovenantSQL%2Fdata-sharing-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CovenantSQL%2Fdata-sharing-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CovenantSQL","download_url":"https://codeload.github.com/CovenantSQL/data-sharing-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225587778,"owners_count":17492632,"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":["blockchain","covenantsql","data-sharing"],"created_at":"2024-11-20T15:55:51.421Z","updated_at":"2024-11-20T15:55:52.132Z","avatar_url":"https://github.com/CovenantSQL.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Sharing Demo\nData Sharing Demo (DSD)是一个基于 [CovenantSQL（CQL）](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md)构建的数据共享平台的演示。\n\n演示的场景是一个基于：药监局、制药厂、物流公司、医院的多方场景。通过将 CQL DB Miner 节点部署在这几个角色的服务器中，并通过区块链的方式保证数据库的一致性，可以搭建出一个类似于 Hyperledger Fabric 联盟链系统。但 CQL 提供传统的 SQL 使开发更为低成本，各方面的性能也更出色。详细的对比可以参见[【这里】]([https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md#%E9%A1%B9%E7%9B%AE%E5%AF%B9%E6%AF%94](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md#项目对比))\n\n对于制药厂，只需要通过简单把 ERP 系统中生产情况的数据，例如：序列号、批号、生产日期，通过 SQL 写入到 CQL 中即可，对于数据的添加和修改都是基于 Admin 在系统中设定的权限来保证的，例如：\n\n```yaml\nGrants:\n  Policies:\n    - User: factory_r_group\n      Field: b77422b.cargos.id\n      Action: read\n    - User: factory_r_group\n      Field: b77422b.cargos.serial\n      Action: read\n    - User: factory_w_group\n      Field: b77422b.cargos.id\n      Action: write\n    - User: factory_w_group\n      Field: b77422b.cargos.serial\n      Action: write\n      ## 省略很多行\n  UserGroups:\n    admin_group:\n      - admin\n    factory_r_group:\n      - factory\n      - carrier\n      - hospital\n    factory_w_group:\n      - factory\n    read_group:\n      - readonly\n```\n\n在 Demo 中，每个用户只能看到有 Read 权限的数据列，只能修改有 Write 权限的列。\n\n同时，所有对于数据的修改操作都是在区块链浏览器上有据可查的：\n\n![image-20190620204019328](docs/row-chain.png)\n\n点击每条记录可以跳转到 SQLChain Explorer 上查看区块链上的详情：\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/chain.png\" width=\"500\"\u003e\n\u003c/p\u003e\n\n### 游览\n\n目前可以通过以下 4 组账号进行平台试用，Admin 账号暂不开放:\n\n```bash\n factory: AUZzFq4X  # 制药厂\n carrier: a0c48c12  # 物流公司\n hospital: DCa861a1 # 医院\n readonly: jhAWQTnh # 药监局\n```\n\n\n\n### 文件上传\n\n在修改和增加数据条目的时候可以上传图片作为附件，后端支持本地文件系统和 S3，上传后的文件我们会在 CQL 数据库中记录文件的 URI 和 MD5。\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/attach.png\" width=\"300\"\u003e\n\u003c/p\u003e\n\n\n\n### 安全性\n\nCQL Miner 本身支持在数据库引擎的层面进行落盘加密，也就是所有在磁盘上的数据都经过 AES-128 进行加密。\n\n对安全有更高要求的客户可以选用 CQL `端到端加密` 的方案对数据进行加解密，在 demo 中我们使用的是 JavaScript 在浏览器端进行加解密：\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/e2e.png\" width=\"300\"\u003e\n\u003c/p\u003e\n\n\n\n### 数据同步演示\n\n这里展示的是这个 Demo 背后的数据库实例是怎么进行强一致性的数据同步的，在 Demo 中进行任何数据的修改都会触发动画（本人学了一周前端，水平太菜，不能触发的话请刷新几下页面）：\n\n![image-20190620205009638](docs/consensus.png)\n\n### 架构图\n\n![](docs/data-sharing-demo.png)\n\n### 原理\n\nCQL 是 CovenantLabs 开发的`分布式` `拜占庭容错` `关系型` 数据库，拥有基于 RBAC 的库、表、行、列级别的权限限制的功能。我们可以基于 CQL 用传统的 SQL 技术快速的开发一个 `联盟链` 系统，用于实现基于区块链技术的可信多方数据共享。\n\n#### 接口\n\nCQL 测试网已经发布，[尝试一下](https://developers.covenantsql.io/docs/quickstart).\n\n\n- [Golang](client/)\n- [Java](https://github.com/CovenantSQL/cql-java-driver)\n- [NodeJS](https://github.com/CovenantSQL/node-covenantsql)\n- [Python](https://github.com/CovenantSQL/cql-python-driver)\n- [Microsoft Excel (来自社区)](https://github.com/melancholiaforever/CQL_Excel)\n- Coding for more……\n\n关注我们或[![follow on Twitter](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social\u0026label=Follow%20%40CovenantLabs)](https://twitter.com/intent/follow?screen_name=CovenantLabs) 保持更新\n\n## 联系我们\n\n- [博客](https://medium.com/@covenant_labs)\n- [YouTube](https://www.youtube.com/channel/UCe9P_TMiexSHW2GGV5qBmZw)\n- [邮箱地址](mailto:webmaster@covenantsql.io)\n- [论坛](https://demo.covenantsql.io/forum/)\n- \u003ca href=\"https://twitter.com/intent/follow?screen_name=CovenantLabs\"\u003e\n          \u003cimg src=\"https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social\u0026label=Follow%20%40CovenantLabs\"\n              alt=\"follow on Twitter\"\u003e\u003c/a\u003e\n- [![Join the chat at https://gitter.im/CovenantSQL/CovenantSQL](https://badges.gitter.im/CovenantSQL/CovenantSQL.svg)](https://gitter.im/CovenantSQL/CovenantSQL?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n- 添加微信: `CovenantSQL` 加入交流群\n    \u003cp align=\"left\"\u003e\n        \u003cimg src=\"https://github.com/CovenantSQL/CovenantSQL/raw/develop/logo/wechat.jpeg\" height=\"100\"\u003e\n    \u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcovenantsql%2Fdata-sharing-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcovenantsql%2Fdata-sharing-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcovenantsql%2Fdata-sharing-demo/lists"}