Flow App Backend
June 7, 2023 ยท View on GitHub
If you didn't read the frontend documentation, please do so before continuing. Through the documentation, we will use the arbitrary variable <ecosystem_name> to refer to the blockchain ecosystem you are working on. For example, if you are working on Compound, you can use 'compound' as the ecosystem name. Just know that, this variable needs to be consistent throughout the documentation (also in the backend documentation).
Configuration
- Create a text file named
<ecosystem_name>.txtthat includes the list of projects you want to add to the firebase database. For example, if you are working on Compound, you can create a file namedcompound.txtand add the following projects to the file:
<ecosystem_name.txt> needs to include line by line project names. For example,
compound-finance/compound-eureka compound-finance/compound-components compound-finance/compound-config
-
Download Google Cloud Firebase Admin SDK from Firebase project settings, and rename to
<ecosystem_name>-admin-sdk.json. Go to 'https://console.firebase.google.com/project/[FIREBASE_PROJECT_NAME]/settings/serviceaccounts/adminsdk', and click 'Generate new private key' button. -
Create a file named
.envin the root directory and add the following variables to the file:
ECOSYSTEM_NAME # <ecosystem_name> that you use through the documentation. For example, 'compound'.
FIREBASE_PROJECT_ID # Firebase project ID.
GITHUB_BEARER_KEY # GitHub API key.
ADMIN_SDK_PATH # Path to the Google Cloud Admin SDK file that you have downloaded before.
PROJECT_LIST # Path to the project list file that you have created before.
Install dependencies
pip3 install -r requirements.txt
The backend consists of two scripts: seed.py and main.py. seed.py is used to feed the database with projects and main.py is used to update the project info in the database. For example, if you want to integrate a new project to the database, you need to run seed.py first and then main.py. If you want to update the project info in the database, you only need to run main.py.
Seed the database
Seeding the database is a one-time process. You only need to run this script when you want to integrate a new project to the database. In the root directory, run the following command:
python3 seed.py --ecosystem <ecosystem_name>
This script reads from the <ecosystem_name>.txt file and adds the these projects to the database.
<ecosystem_name> indicates the ecosystem you want to update for example 'compound'.
Update the database
In the root directory, run the following command:
python3 .
This script updates the database with the latest project info. Just make sure that you have set the .env variables correctly.
Test the app
In the root directory, run the following command:
pytest tests.py