From 840499154d42b50084599725d71a154912903ebc Mon Sep 17 00:00:00 2001 From: Redume Date: Thu, 24 Oct 2024 19:27:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D1=82=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 3 +- .github/workflows/documentation.yml | 29 +++++++++++ docs/config/coinapi-keys.md | 5 ++ docs/getting-started/contributing.md | 66 ++++++++++++++++++++++++ docs/getting-started/docker.md | 76 ++++++++++++++++++++++++++++ docs/getting-started/manual.md | 72 ++++++++++++++++++++++++++ docs/index.md | 11 ++++ docs/settings.json | 14 +++++ mkdocs.yml | 50 ++++++++++++++++++ 9 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/documentation.yml create mode 100644 docs/config/coinapi-keys.md create mode 100644 docs/getting-started/contributing.md create mode 100644 docs/getting-started/docker.md create mode 100644 docs/getting-started/manual.md create mode 100644 docs/index.md create mode 100644 docs/settings.json create mode 100644 mkdocs.yml diff --git a/.dockerignore b/.dockerignore index 40b878d..55f99ce 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules/ +docs/ \ No newline at end of file diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..2cd9840 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,29 @@ +name: Deploy docs +on: + push: + branches: + - master + - main +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install mkdocs-material + - run: mkdocs gh-deploy --force \ No newline at end of file diff --git a/docs/config/coinapi-keys.md b/docs/config/coinapi-keys.md new file mode 100644 index 0000000..2a19f4c --- /dev/null +++ b/docs/config/coinapi-keys.md @@ -0,0 +1,5 @@ +- Go to [coinapi.io](https://www.coinapi.io/get-free-api-key?product_id=market-data-api) website +- Enter any name and your current email, where the api keys will be sent +- In the `What products are you interested in?` section, you can click from one to four items. I recommend clicking all four, because this affects the number of API keys +- Check the email you specified. If there is no letter, then check your spam. You should receive as many keys as you specified in the `What products are you interested in?` +- Keys can be specified in the config `currency.coinapiKeys` \ No newline at end of file diff --git a/docs/getting-started/contributing.md b/docs/getting-started/contributing.md new file mode 100644 index 0000000..0586be7 --- /dev/null +++ b/docs/getting-started/contributing.md @@ -0,0 +1,66 @@ +If you have any questions, you can write to the [mail](mailto:redddume@gmail.com) or [Telegram](https://t.me/Redddume) + +### Fork and clone your repository +1. Fork the repository ([click here to fork now](https://github.com/Redume/Kekkai/fork)) +2. Clone your forked code +```bash +git clone https://github.com//Kekkai.git +``` +3. Create new branch +```bash +git branch +``` +4. Switch to new branch +```bash +git checkout +``` +5. Push your commits +6. Submit a new Pull Request + +### Testing + + +### Code Style +[`Pylint`][pylint], [`mypy`][mypy], [`eslint`][eslint] and [`prettier`][prettier] are used as code syntax checks + +#### Checking the Node.JS code + +To check the code, you must first download the necessary libraries, which are located at the root of the project +```bash +npm install +``` + +`eslint` and `prettier` is used to check and automatically correct the Node.JS code +```bash +npm eslint . +``` + +#### Checking the Python code +To check code, you need to install libraries `mypy` and `pylint` + +```bash +python3 -m pip install -U mypy +``` + +and install `pylint` +```bash +pip install pylint +``` +Start check the code + +for `pylint`: +```bash +pylint /chart/ +``` + +and for `mypy`: +```bash +mypy /chart/ +``` + + + +[pylint]: https://github.com/pylint-dev/pylint +[mypy]: https://github.com/python/mypy +[eslint]: https://github.com/eslint/eslint +[prettier]: https://github.com/prettier/prettier \ No newline at end of file diff --git a/docs/getting-started/docker.md b/docs/getting-started/docker.md new file mode 100644 index 0000000..5b649ed --- /dev/null +++ b/docs/getting-started/docker.md @@ -0,0 +1,76 @@ +Docker Compose is the recommended method to run Kekkai in production. Below are the steps to deploy Kekkai with Docker Compose. + +Kekkai requires Docker Compose version 2.x. + +### Steps 1 - Preparing files +```shell +git clone https://github.com/Redume/Kekkai.git +``` + +```shell +cd Kekkai +``` + + +### Steps 2 - Change config files +??? note "Nginx Configuration" + In `nginx.conf`, you need to specify your domain or ipv4 address + ``` + ... + listen 443 ssl; + server_name localhost; # Your domain + ... + ``` + + To set up SSL + ```bash + mkdir CertSLL + ``` + + After that, copy the SSL certificates to the `CertSSL` folder, if the names are different, + then change either the name of the certificates or in `nginx.conf` + + ``` + ssl_certificate /etc/nginx/ssl/fullchain.pem; + ssl_certificate_key /etc/nginx/ssl/privkey.pem; + ``` + +??? note "The main config is `config_sample.yaml` for Kekkai" + ```yaml + database: + user: 'DATABASE_USERNAME' + password: 'DATABASE_PASSWORD' + host: 'DATABASE_HOST' + name: 'DATABASE_NAME' + port: 5432 + ... + ``` + + Fill in the data in the `database` item, as well as in the `.env` config + + +??? note "`.env-sample` config for PostgreSQL" + ```.env + # Connection secret for postgres. You should change it to a random password + # Please use only the characters `A-Za-z0-9`, without special characters or spaces + + POSTGRES_PASSWORD=my_password + + # If you do not know what you are doing, then you should not edit the values below + ################################################################################### + POSTGRES_DB=kekkai + DB_HOST=postgres + POSTGRES_USER=postgres + ``` + + - Populate custom database information if necessary. + - Consider changing `DB_PASSWORD` to a custom value. Postgres is not publically exposed, so this password is only used for - local authentication. To avoid issues with Docker parsing this value, it is best to use only the characters `A-Za-z0-9`. + +!!! note + After editing, rename the config files by removing `sample` in the name + + +### Steps 3 - Start the containers +```shell title='Start the containers using docker compose command' +docker compose -f "docker-compose.yaml" up -d --build +``` \ No newline at end of file diff --git a/docs/getting-started/manual.md b/docs/getting-started/manual.md new file mode 100644 index 0000000..c2536ac --- /dev/null +++ b/docs/getting-started/manual.md @@ -0,0 +1,72 @@ +For full use, you need to install `Node.JS v20`, `PostgreSQL v15`, `Python v13.3`, `Nginx` + +### Steps 1 - Preparing files + +```shell +git clone https://github.com/Redume/Kekkai.git +``` + +```shell +cd Kekkai +``` + +### Steps 2 - Change config files + +??? note "Nginx Configuration" + In `nginx.conf`, you need to specify your domain or ipv4 address + ```nginx + ... + listen 443 ssl; + server_name localhost; # Your domain + ... + ``` + +??? note "The main config is `config_sample.yaml` for Kekkai" + ```yaml + database: + user: 'DATABASE_USERNAME' + password: 'DATABASE_PASSWORD' + host: 'DATABASE_HOST' + name: 'DATABASE_NAME' + port: 5432 + ... + ``` + + Fill in the data in the `database` item, as well as in the `.env` config + +### Steps 3 - Install libs + +Install library. In `/shared/logger`, `/shared/config`, `/shared/database`, `/collect-currency`,` /server`, +the required node.JS libraries In each of the directories, you need to write this command + +```shell +npm install +``` + +and install python libs +```shell +pip install -r requirements.txt +``` + +Start the nginx service +```shell +sudo systemctl start nginx.service +``` + +### Steps 4 - Launch Services + +Launch each of the services +There are all three services `MainService`, `Collect-currency`, `Chart` + +- `MainService` is an API for getting the exchange rate +```shell +cd server & node . +``` +- `Collect-Currency` is a service for collecting and save the rate in a database +```shell +cd collect-currency/src/ && node . +``` +- `ChartService` is a service for creating currency rate charts +```shell +python3 main.py +``` \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..01a2a27 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,11 @@ +## What is Kekkai? +Kekkai — The first free Open-Source Tool for Saving Historical Currency data + +It is a simple tool for collecting historical currency data from open sources, with the ability to create currency exchange rate charts. Cryptocurrencies and fiat currency are supported + +## Why Kekkai? + +- Free & Open-Source +- The ability to create graphs +- Decentralized data collection and use. You are not dependent on any particular server +- Plausible support. Anonymous data collection with the ability to disable it. Available only to server owners diff --git a/docs/settings.json b/docs/settings.json new file mode 100644 index 0000000..4a08eef --- /dev/null +++ b/docs/settings.json @@ -0,0 +1,14 @@ +{ + "yaml.schemas": { + "https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml" + }, + "yaml.customTags": [ + "!ENV scalar", + "!ENV sequence", + "!relative scalar", + "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg", + "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji", + "tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format", + "tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping" + ] + } \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..1a20eee --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,50 @@ +site_name: Kekkai +site_url: https://kekkai-docs.redume.su +site_author: Redume +site_description: The first free Open-Source Tool for Saving Historical Currency data + +repo_name: Redume/Kekkai +repo_url: https://github.com/Redume/Kekkai +edit_uri: '' + +copyright: Copyright © 2024 Redume + +nav: + - Getting started: + - Docker [Recommended]: getting-started/docker.md + - Manual: getting-started/manual.md + - Contributing: getting-started/contributing.md + - Config: + - How to create API keys for coinapi: config/coinapi-keys.md +theme: + language: en + name: material + palette: + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/brightness-4 + name: Switch to system preference + + features: + - content.code.copy + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.superfences + - admonition + - pymdownx.details + - pymdownx.superfences \ No newline at end of file