{"id":20569500,"url":"https://github.com/apache/incubator-resilientdb-graphql","last_synced_at":"2025-04-14T16:36:14.448Z","repository":{"id":67286632,"uuid":"592700171","full_name":"apache/incubator-resilientdb-graphql","owner":"apache","description":"Global-Scale Sustainable Blockchain Fabric","archived":false,"fork":false,"pushed_at":"2025-03-28T19:11:20.000Z","size":2379,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-10T11:58:57.319Z","etag":null,"topics":["blockchain","blockchain-platform","crypto","distributed-database","distributed-ledger","key-value-database","smart-contracts","solidity","utxo"],"latest_commit_sha":null,"homepage":"","language":"Python","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/apache.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-24T10:42:49.000Z","updated_at":"2025-03-28T19:11:24.000Z","dependencies_parsed_at":"2023-12-04T05:25:07.221Z","dependency_job_id":"7a2997fd-1319-481c-acd3-59fc5054c6fb","html_url":"https://github.com/apache/incubator-resilientdb-graphql","commit_stats":null,"previous_names":["resilientapp/nexresgraphql","resilientapp/resilientdb-graphql","apache/incubator-resilientdb-graphql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fincubator-resilientdb-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fincubator-resilientdb-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fincubator-resilientdb-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fincubator-resilientdb-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/incubator-resilientdb-graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248662202,"owners_count":21141528,"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","blockchain-platform","crypto","distributed-database","distributed-ledger","key-value-database","smart-contracts","solidity","utxo"],"created_at":"2024-11-16T05:06:47.420Z","updated_at":"2025-04-14T16:36:14.414Z","avatar_url":"https://github.com/apache.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResilientDB GraphQL\nResilientDB GraphQL Server\n\n# Get Prepared \n\n(If you're using this for the first time, the steps below would be useful)\n\nInstall **Ubuntu 20.04** on your local machine.\n\nOnce installed, go to File Explorer -\u003e Linux -\u003e Ubuntu 20.04.\n\nClone this repository.\n\nInstall python3 (version - 3.9+) and ensure pip is installed using the command.\n\n    sudo apt-get install python3-pip\n\nAlso make sure to install the venv module which creates a virtual Python environment that helps encapsulate the project's dependencies and prevents possible conflicts with the global Python environment. The command is:\n\n    sudo apt-get install -y python3.10-venv\n\nCreate a virtual environment:\n\n    python3 -m venv venv\n\nStart a virtual environment:\n\n    source venv/bin/activate\n\nGo back from the virtual environment when you no longer need it:\n\n    deactivate\n\n# Using the SDK \n\nTo use the SDK, you need to start a KV service first, which you can refer to the [resilientdb](https://github.com/resilientdb/resilientdb) repository and the [blog](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html). \n\nThen you should start the crow http service, which may take a few minutes at the first time.\n\n    bazel build service/http_server:crow_service_main\n\n    bazel-bin/service/http_server/crow_service_main service/tools/config/interface/service.config service/http_server/server_config.config\n\nAfter starting the crow service, you can optionally test it by using the **curl** command to send HTTP requests.\n\n    curl -X POST -d '{\"id\":\"key1\",\"value\":\"value1\"}' 127.0.0.1:18000/v1/transactions/commit\n\n    curl 127.0.0.1:18000/v1/transactions/key1\n\nThe expected output of the two commands above are: `id: key1` and `{\"id\":\"key1\",\"value\":\"value1\"}`, respectively.\n\nStart your virtual environment.\n\n    source venv/bin/activate\n\nRun the requirements.txt command to install the SDK related dependencies.\n\n    pip3 install -r requirements.txt\n\nTry the test script.\n\n    python3 test_sdk.py\n\nYou have successfully run the script if you see the output: `The retrieved txn is successfully validated`\n\n# GraphQL\n\n\u003c!-- 7. (Temporary resolve) Copy app.py to the nexres_sdk folder to ensure execution --\u003e\n\n(Optional) If there is an error while running any command relating to NexRes, this command below may help:\n\n    sudo apt-get install python3.10-distutils\n\nNote: If there is an error with the pip version, use the command:\n\n    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10\n\nOpen a venv in the Ubuntu server and run the command: \n\n    source venv/bin/activate\n\n    sudo apt-get install cloud-init\n\nInstall the remaining dependencies in venv\n\n    python3 -m pip install strawberry-graphql\n\n    python3 -m pip install flask_cors\n\n**BUG FIX**: in the case requirements.txt doesn't work, and the `cloud-init` version is not found, edit the file to be:\n```C\naiohttp==3.8.3\naiohttp-cors==0.7.0\naiosignal==1.3.1\nanyio==3.6.2\nariadne==0.17.0\nasync-timeout==4.0.2\nattrs==22.2.0\nbase58==2.1.0\ncertifi==2022.12.7\ncffi==1.15.1\ncharset-normalizer==2.1.1\nclick==8.1.3\ncommonmark==0.9.1\ncryptoconditions==0.8.1\ncryptography==3.4.7\nFlask==2.2.2\nFlask-Cors==3.0.10\nfrozenlist==1.3.3\ngraphql-core==3.2.3\nh11==0.14.0\nidna==3.4\nimportlib-metadata==5.2.0\nitsdangerous==2.1.2\nJinja2==3.1.2\nlibcst==0.4.9\nMarkupSafe==2.1.1\nmultidict==6.0.4\nmypy-extensions==0.4.3\npyasn1==0.4.8\npycparser==2.21\nPygments==2.14.0\nPyNaCl==1.4.0\npysha3==1.0.2\npython-dateutil==2.8.2\npython-multipart==0.0.5\npython-rapidjson==1.8\nPyYAML==6.0\nrequests==2.28.1\nrich==13.0.1\nsix==1.16.0\nsniffio==1.3.0\nstarlette==0.23.1\nstrawberry-graphql==0.152.0\ntyping-inspect==0.8.0\ntyping_extensions==4.4.0\nurllib3==1.26.13\nuvicorn==0.20.0\nWerkzeug==2.2.2\nyarl==1.8.2\nzipp==3.11.0\n```\n\n- You may get an error that says `Running setup.py install for \u003cdependency\u003e did not run successfully.`\n- First, try `pip3 install wheel` or `pip install wheel`\n- Next, install all missing dependencies manually\n    - **NOTE** as long as you still have dependencies to install, you will get an error message, but this is okay!\n    - From the stack trace, identify the module, then use `pip install \u003cdependency\u003e`\n    - keep generating errors by running `python3 app.py` every time, and resolve each missing dependency\n- Ex:\n```C\nTraceback (most recent call last):\nFile \"/home/user/repos/NexresGraphQL/app.py\", line 1, in \u003cmodule\u003e\nfrom resdb_driver import Resdb\nFile \"/home/user/repos/NexresGraphQL/resdb_driver/__init__.py\", line 1, in \u003cmodule\u003e\nfrom .driver import Resdb\nFile \"/home/user/repos/NexresGraphQL/resdb_driver/driver.py\", line 4, in \u003cmodule\u003e\nfrom .offchain import prepare_transaction, fulfill_transaction\nFile \"/home/user/repos/NexresGraphQL/resdb_driver/offchain.py\", line 8, in \u003cmodule\u003e\nfrom .transaction import Input, Transaction, TransactionLink, _fulfillment_from_details\nFile \"/home/user/repos/NexresGraphQL/resdb_driver/transaction.py\", line 14, in \u003cmodule\u003e\nimport base58\nModuleNotFoundError: No module named 'base58'\n```\n- In the last line, you can run `pip install base58`\n- Keep running `python3 app.py` until you get to the broken dependency (ex: pysha3, sha3), then try running `sudo apt-get install python3.10-dev`\n- Hopefully, all your dependencies should be installed, and running `python3 app.py` will run the server!\n\nStart the app using:\n\n    python3 app.py\n\nThis would be hosted on your local server to test the React App/Frontend.\nAlso, this would give info on the console about the POST command, which are used to create an account. This consists of 3 stages: publicKey. AES encrypted private key and decrypted privateKey\n\nNote: To run Ubuntu virtual instance, open Command Prompt, then type `ubuntu2004` to open an instance\n\n# Serve GraphQL Using Nginx\n\nInstall the Nginx web server package:\n\n    sudo apt-get install nginx -y\n\nOnce the Nginx is installed, start and enable the Nginx service using the following command:\n\n    systemctl start nginx\n    systemctl enable nginx\n\nActivate your virtual environment and install Gunicorn and Flask:\n\n    source venv/bin/activate\n    pip install wheel\n    pip install gunicorn flask\n\nVerify whether Gunicorn can serve the application correctly using the command below:\n\n    gunicorn --bind 0.0.0.0:5000 wsgi:app\n\nIf everything is fine, you should get the following output:\n\n    [2023-10-06 22:28:11 +0000] [24074] [INFO] Starting gunicorn 21.2.0\n    [2023-10-06 22:28:11 +0000] [24074] [INFO] Listening at: http://0.0.0.0:5000 (24074)\n    [2023-10-06 22:28:11 +0000] [24074] [INFO] Using worker: sync\n    [2023-10-06 22:28:11 +0000] [24075] [INFO] Booting worker with pid: 24075\n\nPress CTRL+C to stop the application. And deactivate the virtual environment.\n\n    deactivate\n\nNext, you will need to create a systemd unit file for the Flask application:\n\n    sudo vim /etc/systemd/system/flask.service\n\nAdd the following lines:\n\n    [Unit]\n    Description=Gunicorn instance to serve Flask\n    After=network.target\n    [Service]\n    User=root\n    Group=www-data\n    WorkingDirectory=\\{Your Absolute Path to this Folder\\}\n    Environment=\"PATH=\\{Your Absolute Path to this Folder\\}/venv/bin\"\n    ExecStart=\\{Your Absolute Path to this Folder\\}/venv/bin/gunicorn --bind 0.0.0.0:8000 wsgi:app\n    [Install]\n    WantedBy=multi-user.target\n\nNext, reload the systemd daemon with the following command:\n\n    sudo systemctl daemon-reload\n\nNext, start the flask service and enable it to start at system reboot:\n\n    sudo systemctl start flask\n    sudo systemctl enable flask\n\nNext, verify the status of the flask with the following command:\n\n    sudo systemctl status flask\n\nOutput:\n\n    ● flask.service - Gunicorn instance to serve Flask\n     Loaded: loaded (/etc/systemd/system/flask.service; enabled; vendor preset: enabled)\n     Active: active (running) since Fri 2023-10-06 22:20:00 UTC; 14min ago\n    Main PID: 23745 (gunicorn)\n      Tasks: 2 (limit: 38067)\n     Memory: 40.6M\n     CGroup: /system.slice/flask.service\n             ├─23745 /home/ubuntu/ResilientDB-GraphQL/venv/bin/python3 /home/ubuntu/ResilientDB-GraphQL/venv/b\u003e\n             └─23747 /home/ubuntu/ResilientDB-GraphQL/venv/bin/python3 /home/ubuntu/ResilientDB-GraphQL/venv/b\u003e\n\n\nNext, you will need to configure Nginx as a reverse proxy to serve the Flask application through port 80. To do so, create an Nginx virtual host configuration file:\n\n    sudo vim /etc/nginx/conf.d/flask.conf\n\nAdd the following lines:\n\n    server {\n        listen 80;\n        server_name {The public IP address of your machine};\n        location / {\n            proxy_pass http://127.0.0.1:8000;\n            proxy_set_header Host $host;\n            proxy_set_header X-Real-IP $remote_addr;\n        }\n    }\n\nSave and close the file then verify the Nginx for any syntax error:\n\n    sudo nginx -t\n\nYou should see the following output:\n\n    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok\n    nginx: configuration file /etc/nginx/nginx.conf test is successful\n\nFinally, restart the Nginx service to apply the changes:\n\n    sudo systemctl restart nginx\n\nThen, test with:\n\n    {The public IP address of your machine}/graphql","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fincubator-resilientdb-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fincubator-resilientdb-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fincubator-resilientdb-graphql/lists"}