Skip to content

Commit

Permalink
Merge branch 'CarmineOptions:master' into enhancement/analyze-users
Browse files Browse the repository at this point in the history
  • Loading branch information
tosoham authored Nov 30, 2024
2 parents 89d1f1c + 8764daf commit b4406f5
Show file tree
Hide file tree
Showing 91 changed files with 8,264 additions and 2,634 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI Workflow

on: [push, pull_request]
on: [push]


jobs:
run_tests:
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/dashboard_app_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: DashBoard App CI Workflow

on: [push]

jobs:
run_tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: data_handler
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies for Dashboard App
working-directory: ./apps/dashboard_app
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
poetry lock --no-update
poetry install
- name: Prepare Environment File
working-directory: ./apps/dashboard_app
run: |
cp .env.dev .env
- name: Run Tests for Dashboard_App
working-directory: ./apps/dashboard_app
run: poetry run pytest
67 changes: 67 additions & 0 deletions .github/workflows/wep_app_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Web App CI Workflow

on: [push]

jobs:
run_tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5433:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies for Web_App
working-directory: ./apps/web_app
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
poetry lock --no-update
poetry install
- name: Prepare Environment File
working-directory: ./apps/web_app
run: |
cp .env.dev .env
sed -i 's/DB_HOST=db/DB_HOST=127.0.0.1/' .env
sed -i 's/DB_PORT=5432/DB_PORT=5433/' .env
- name: Wait for Database to be Ready
run: |
for i in {1..30}; do
pg_isready -h 127.0.0.1 -p 5433 -U postgres && break || sleep 2;
done
- name: Create Test Database
run: |
PGPASSWORD=postgres psql -h 127.0.0.1 -p 5433 -U postgres -c "CREATE DATABASE web_app;"
- name: Run Tests for Web_App
working-directory: ./apps/web_app
run: poetry run pytest --junitxml=results.xml

- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ./apps/web_app/results.xml
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Contributor Guidelines

1. Task Claiming
- Comment: 'I would like to take this task, I love 🍍' including the estimated delivery timeline (start and completion dates) and a brief summary of relevant skills (required for complex tasks). Make sure, that you start with comment which is provided with secret phrase, otherwise your application will be ignored.
- Comment: 'I would like to take this task, I love orange' including the estimated delivery timeline (start and completion dates) and a brief summary of relevant skills (required for complex tasks). Make sure, that you start with comment which is provided with secret phrase, otherwise your application will be ignored.
- Join the contributors' Telegram group for updates and discussions.
2. Task Assignment
- Easy tasks: Assigned on a first-come, first-served basis. No further assignment is required.
- Medium and Complex tasks: Prospective assignees must outline their approach to the task. Assignments will be based on these proposals to ensure optimal match and prioritization. The higher the complexity of the task, the more detailed description of the approach is needed.
4. Initial Commit Requirement
- If no commits are made or the assignee is unreachable within `12` hours post-assignment, we reserve the right to reassign the task.
- If no commits are made or the assignee is unreachable within `10` hours post-assignment, we reserve the right to reassign the task.
- We also reserve the right to reassign tasks if it becomes clear they cannot be completed by the hackathon's end.
5. Submission Guidelines
- Submit a pull request (PR) from the forked repository.
- Ensure to rebase on the current master branch before creating the PR.

6. Resolve issue in your PR
- after review, you have 12 hours to fix it, exception, if you have a lot you can push just partially if you have `medium` or `complex` task
- If you couldn't do that, you will be unassign.
### Communication

* For questions, contact us via this GitHub (response might be slower) or Telegram ( https://t.me/derisk_dev for a faster response).
80 changes: 70 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,99 @@

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:
- `data_handler`
- `web_app`
- `legacy_app`
- `dashboard_app`
- `shared` - Common code shared between the components
- [`data_handler`](./apps/data_handler/README.md) - Data processing and analysis component
- [`web_app`](./apps/web_app/README.md) - Main web application interface
- [`legacy_app`](./apps/legacy_app/README.md) - Legacy application functionality
- [`dashboard_app`](./apps/dashboard_app/README.md) - Analytics dashboard
- [`shared`](./apps/shared/README.md) - Common code shared between the components

## Quick Start Guide

### Prerequisites
- Docker installed on your machine (v19.03+ recommended).
- Docker Compose installed (v2.0+ recommended).

### Data Handler

The data handler component processes and manages data for the DeRisk platform.

#### Local Development

## Data Handler
1. To set up this project run next command for local development in `derisk-research` directory:

2. Environment Configuration:
```bash
cp apps/data_handler/.env.example apps/data_handler/.env.dev
```
3. Start the Services:

```bash
docker-compose -f devops/dev/docker-compose.data-handler.yaml up --build
```
2. To run test cases for this project run next command in `derisk-research` directory:
4. Stop the Services:
```bash
docker-compose -f devops/dev/docker-compose.data-handler.yaml down
```

5. To run test cases for this project run next command in `derisk-research` directory:
```bash
make test_data_handler
```

For detailed documentation, see the [Data Handler](./apps/data_handler/README.md)



## Legacy app

The legacy app provides essential functionality for data visualization and analysis through a Streamlit interface.

#### Local Development

1. To set up this project run next command for local development in `derisk-research` directory:
```
```bash
make setup
```

2. To run streamlit app run next command in `derisk-research` directory:
```
```bash
make app
```

3. Start Jupyter notebook (optional):
```bash
make notebook
```
For detailed documentation, see [`legacy_app`](./apps/legacy_app/README.md)

## Web app (Notification app)
1. To set up this project run next command for local development in `derisk-research` directory:
To set up this project run next command for local development in `derisk-research` directory:

1. Environment Configuration:
```bash
cp apps/web_app/.env.example apps/web_app/.env.dev
```

2. Start the Services:
```bash
docker-compose -f devops/dev/docker-compose.notification-app.yaml up --build
```

3. Stop the Services:
```bash
docker-compose -f devops/dev/docker-compose.notification-app.yaml down
```

## Dashboard App

Interactive dashboard application for visualizing and analyzing DeRisk data.

### Key Features
- Interactive data visualization
- Protocol statistics monitoring
- Loan portfolio analysis
- Real-time data updates
For detailed documentation, see the [Dashboard App](./apps/dashboard_app/README.md)

## Shared package (Common code shared between the components)
1. How to run test cases for shared package, run next command in root folder:
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard_app/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# PostgreSQL
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=data_handler
DB_HOST=db
DB_PORT=5432
75 changes: 75 additions & 0 deletions apps/dashboard_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# DeRisk Dashboard App

Interactive dashboard application for visualizing and analyzing DeRisk data.


## Prerequisites

- Python 3.11+
- Poetry
- Docker

## Setup

### Local Development

1. Install dependencies:
```bash
./setup.sh
```

2. Run the dashboard:
```bash
poetry run python dashboard.py
```

### Docker Setup

1. Build the image:


2. Run the container:

3. stop container:

## Key Features

- Interactive data visualization
- Protocol statistics monitoring
- Loan portfolio analysis
- Real-time data updates

### Adding New Charts

1. Create chart module in `charts/`
2. Implement chart logic using main.py templates
3. Register in dashboard.py

### Data Integration

Use `data_connector.py` to add new data sources:

```python
from data_connector import DataConnector

connector = DataConnector()
data = connector.get_data()
```

## Testing

```bash
poetry run pytest
```

## Contributing

1. Fork the [repository](https://github.com/CarmineOptions/derisk-research)
2. Create feature branch
3. Submit pull request

Read [contribution guide](CONTRIBUTING.md)

## License

[License details](LICENSE.txt)
6 changes: 5 additions & 1 deletion apps/dashboard_app/charts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class Dashboard:
# "Nostra Mainnet",
]

def __init__(self):
def __init__(self, zklend_state):
"""
Initialize the dashboard.
:param zklend_state: ZkLendState
"""
# Set the page configuration
st.set_page_config(
layout="wide",
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard_app/charts/main_chart_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
get_custom_data,
get_prices,
get_underlying_address,
save_dataframe,
)
from shared.amms import SwapAmm
from shared.state import State
Expand Down
Loading

0 comments on commit b4406f5

Please sign in to comment.