This project consist of a monorepo with components required for the implementation of DeRisk on Starknet. There are several components in this repository, each with its own purpose and functionality. The main components are:
shared
Both projects data_handler
, dashboard_app
work with the same shared database,
which is contained in the shared folder. It also contains all shared modules.
data_handler
Data processing and analysis component: Collects data from DeFi, analyzes it, and saves it to the db. It contains Celery tasks to schedule data collection runs. Once the data is collected, it triggers an endpoint on the dashboard_app
dashboard_app
Works as a server for the frontend_dashboard
. Generates an analytics dashboard using Streamlit. Contains an API to handle the Telegram webhook and send bot messages.
Key Features:
- Interactive data visualization
- Protocol statistics monitoring
- Loan portfolio analysis
- Real-time data updates
frontend_dashboard
React client app. Uses API if the dashboard_app
Legacy apps contain code that has been migrated to the current apps, along with additional code. Explore them in case of a stack issue:
- Docker installed on your machine (v19.03+ recommended).
- Docker Compose installed (v2.0+ recommended).
-
To set up this project run next command for local development in
derisk-research
directory: -
Environment Configuration:
cp apps/data_handler/.env.dev apps/data_handler/.env
- Start the Services:
docker-compose -f devops/dev/docker-compose.data-handler.yaml up --build
- Stop the Services:
docker-compose -f devops/dev/docker-compose.data-handler.yaml down
- To run test cases for this project run next command in
derisk-research
directory:
make test_data_handler
For detailed documentation, see the Data Handler
-
To set up this project run next command for local development in
derisk-research
directory: -
Environment Configuration:
cp apps/dashboard_app/.env.dev apps/dashboard_app/.env
- Start the Services:
docker-compose -f devops/dev/docker-compose.dashboard-app.yaml up --build
- Stop the Services:
docker-compose -f devops/dev/docker-compose.dashboard-app.yaml down
cd apps/dashboard_app
poetry install
cp .env.dev .env
poetry run uvicorn app.main:app --reload --port 8000
Explore the API will be available at http://localhost:8000/docs.
Make sure dashboard_app
is running!
cd apps/frontend_dashboard
npm install
npm run dev
Navigate to http://localhost:5173 to access the subscription form.
The backend is configured with CORS to allow requests from http://localhost:5173, and the Vite dev server proxies /api
to the backend.
- How to run test cases for shared package, run next command in root folder:
make test_shared
-
Naviagte to frontend_dashboard directory:
cd apps/frontend_dashboard
-
Build the Docker Image:
docker build -t frontend_dashboard .
or on linux
sudo docker build -t frontend_dashboard .
-
Run the Docker Container::
docker run -p 5173:5173 frontend_dashboard
or on linux
sudo docker run -p 5173:5173 frontend_dashboard
-
Access the Application: Open your browser and navigate to
http://localhost:5173
.
In this project is using alembic for data migrations.
Navigate to the project folder and generate a new migration using the following command:
- Run:
docker compose -f devops/dev/docker-compose.db.yaml up --build
- Then:
cd apps/shared
alembic -c alembic.ini revision --autogenerate -m "your message"
- ? You may need to set up
.env
and install missing packages. Check the terminal, as pip-install missing packages
After generating new migration, you need to apply it:
alembic -c alembic.ini upgrade head
For downgrading migration:
alembic -c alembic.ini downgrade -1
Useful commands: Purge all celery tasks:
docker compose run --rm celery celery -A celery_conf purge
Purge all celery beat tasks:
docker compose run --rm celery_beat celery -A celery_conf purge
Go to bash
docker compose exec backend bash
#TODO review:
- Set up
.env.dev
intoderisk-research/apps/data_handler
- Go back to
derisk-research/apps
directory - Then run bash script to migrate:
bash data_handler/migrate.sh