Before deploying the backend, you must ensure that the required dependencies are installed. The following libraries and tools are necessary:
- FastAPI
- Install with:
pip install "fastapi[all]"
- Install with:
- MySQL Python Connector
- Install with:
pip install mysql-connector-python
- Install with:
- Web3.py
- Install with:
pip install web3
- Install with:
- py-solc-x
- Install with:
pip install py-solc-x
- Install with:
Before deploying the frontend, you must ensure that Node.JS version 18.17.1 is installed on your machine.
- Open a command prompt or terminal.
- Navigate to the "asset-sphere" application folder (exported from the zipped submission).
- Run the following commands within the folder:
- Install module dependencies:
npm install
- Install frontend dependencies:
npm install @mui/material @emotion/react @emotion/styled react-router-dom axios cors
- Install module dependencies:
For the database, you need to have MySQL Server 8.1 installed on your local device. Ensure that a MySQL database instance is running on localhost and valid credentials are available for this instance.
Before making calls to smart contracts, you should have Ganache v2.7.1 installed on your device.
In the folder \asset-sphere\backend, you will find a file called "createdb.sql". Execute the SQL statements in this file by either loading it in your GUI of choice or copying and pasting it into a logged-in MySQL console. You'll know it's successful if a database called "assetsphere" appears when querying the local SQL server for databases.
Copy the private key from the address at index 0 to your clipboard.
In the folder \asset-sphere\backend, locate the file "constants.py". Paste the private key you copied from Ganache into the variable indicated by comments.
If necessary, update the database credentials in "constants.py" to ensure that FastAPI can establish connections to the database. Save the file.
In your custom Conda environment, navigate to \asset-sphere\backend and execute the command: C:...\asset-sphere\backend> uvicorn api:app
In a command prompt, execute the command: C:...\asset-sphere> npm start
TIP: Ensure that neither of these command windows is stuck due to an inadvertent click, which might stop the console window from refreshing.
To add initial data for demonstration purposes:
- Open the page: http://127.0.0.1:8000/createdemodata
- If the page returns "success," you're ready to proceed.
Enjoy exploring the application!
- User[0]: [email protected], Password123 – Currently owns three assets
- User[1]: [email protected], Password123 – Currently owns no assets
This application is designed as a single-page application. Certain functions and API calls are set to run once on app render due to the absence of a server for hosting. Therefore, do not hit the 'refresh' button or F5 after the application starts. Individual pages within the application will be re-rendered with new data upon loading. To refresh a page, navigate in and out using the navbar.
If something goes wrong during application startup or testing, you may need to follow these steps to clear temporary data and redeploy:
- Stop the Uvicorn/NPM command windows.
- Drop and recreate the database (see Step 1).
- Delete all files in "asset-sphere\src\localdata."
- If a new Ganache session was started, ensure the private key in "constants.py" is up to date (Step 3).
- Follow steps 4 - 6 to initiate a new load.