Skip to content

Commit

Permalink
docs: optimize readme
Browse files Browse the repository at this point in the history
  • Loading branch information
justlorain committed Jul 1, 2024
1 parent 1191c93 commit 3da50eb
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 2,869 deletions.
Empty file removed DEPLOY.md
Empty file.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ FROM alpine

WORKDIR /src
COPY --from=build /app/openalysis /app/openalysis
COPY default.yaml /src/default.yaml

ENTRYPOINT ["/app/openalysis"]
59 changes: 59 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
![OPENALYSIS](./images/OPENALYSIS.png)

OPENALYSIS 是一款对 GitHub 开源社区的数据进行可视化和分析的工具。

[![Go Report Card](https://goreportcard.com/badge/github.com/B1NARY-GR0UP/openalysis)](https://goreportcard.com/report/github.com/B1NARY-GR0UP/openalysis)

## 概览

OPENALYSIS 只做了三件事:

1. 设置定时任务通过 GitHub API ([REST API](https://docs.github.com/en/rest?apiVersion=2022-11-28)[GraphQL API](https://docs.github.com/en/graphql)) 获取配置的组织或者仓库的数据;
2. 将获取的数据整理并存储在 [MySQL](https://www.mysql.com/) 数据库中;
3. 通过 [Grafana](https://grafana.com/grafana/) 查询数据库并将数据可视化为图表等形式;

OPENALYSIS 提供了:

- 一系列动态的 Grafana Dashboard 来对配置的组织,仓库,贡献者等不同维度的数据进行可视化和分析;
- 一个命令行工具来快速启动和重启定时任务;
- 一系列 API 来配置和使用这个工具;

OPENALYSIS 可以让您对您所管理的或所在的开源社区的整体数据有一个概览,我们希望 OPENALYSIS 可以帮助您更好的对开源社区进行建设和发展。

## 部署



## 使用



## Dashboard Effect Display

![example-1](./images/example-1.png)

![example-2](./images/example-2.png)

![example-3](./images/example-3.png)

![example-3](./images/example-4.png)

## 博客

- [如何对开源社区的数据进行可视化分析](https://juejin.cn/post/7359882185362948135)

## 致谢

Sincere appreciation to the [CloudWeGo](https://github.com/cloudwego) community, without whose help this project would not have been possible.

## 许可证

OPENALYSIS is distributed under the [Apache License 2.0](./LICENSE). The licenses of third party dependencies of OPENALYSIS are explained [here](./licenses).

## 生态

<p align="center">
<img src="https://github.com/justlorain/justlorain/blob/main/images/BINARY-WEB-ECO.png" alt="BINARY-WEB-ECO"/>
<br/><br/>
OPENALYSIS is a Subproject of the <a href="https://github.com/B1NARY-GR0UP">BINARY WEB ECOLOGY</a>
</p>
199 changes: 34 additions & 165 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,195 +1,64 @@
# OPENALYSIS

[![Go Report Card](https://goreportcard.com/badge/github.com/B1NARY-GR0UP/openalysis)](https://goreportcard.com/report/github.com/B1NARY-GR0UP/openalysis)

> You Can (Not) Observe
![OPENALYSIS](./images/OPENALYSIS.png)

Open Analysis Service

## Install

- Install CMD Tool

```shell
go install github.com/B1NARY-GR0UP/openalysis@latest
```

- Get Library

```shell
go get -u github.com/B1NARY-GR0UP/openalysis
```

- Do not have a Go environment? Check the [Quick Start](#quick-start) section.

## Usage (CMD Tool)

- **[Start](#start---start-openalysis-service)**: Start OPENALYSIS service
- **[Restart](#restart---restart-openalysis-service)**: Restart OPENALYSIS service

```shell
Usage:
openalysis [command]

Available Commands:
help Help about any command
restart restart openalysis service
start start openalysis service

Flags:
-h, --help help for openalysis
-v, --version version for openalysis
```

**NOTE:**

**1. All configurations are based on the configuration file, and if flags are set, they will override the configurations in the configuration file.**

**2. If the configuration file path is not specified, the project's default configuration file will be used.**

### Start - Start OPENALYSIS service

- **Usage**
OPENALYSIS is a tool for visualizing and analyzing data from the GitHub open-source community.

```shell
openalysis start [flags] [path2config]
```

- **Flags**
[![Go Report Card](https://goreportcard.com/badge/github.com/B1NARY-GR0UP/openalysis)](https://goreportcard.com/report/github.com/B1NARY-GR0UP/openalysis)

| Short | Long | Description |
|-------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -t | --token | [Your GitHub Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) |
| -c | --cron | Your Cron Spec |
| -r | --retry | Retry Times |
| -h | --help | Help for Start |
## Overview

- **Example**
OPENALYSIS only does three things:

```shell
openalysis start -c "@hourly" -r "5" config.yaml
```
1. Sets up scheduled tasks to retrieve data from configured organizations or repositories via the GitHub API ([REST API](https://docs.github.com/en/rest?apiVersion=2022-11-28) and [GraphQL API](https://docs.github.com/en/graphql)).
2. Organizes and stores the retrieved data in a [MySQL](https://www.mysql.com/) database.
3. Queries the database and visualizes the data in charts and other forms through [Grafana](https://grafana.com/grafana/).

### Restart - Restart OPENALYSIS service
OPENALYSIS provides:

- **Usage**
- A series of dynamic Grafana dashboards for visualizing and analyzing data from various dimensions, such as organizations, repositories, contributors, etc.
- A command-line tool to quickly start and restart scheduled tasks.
- A series of APIs to configure and use this tool.

```shell
openalysis restart [flags] [path2config]
```
OPENALYSIS gives you an overview of the overall data for the open-source community you manage or belong to. We hope OPENALYSIS can help you better build and develop your open-source community.

- **Flags**
## Usage

| Short | Long | Description |
|-------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -t | --token | [Your GitHub Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) |
| -c | --cron | Your Cron Spec |
| -r | --retry | Retry Times |
| -h | --help | Help for Restart |
The operation of OPENALYSIS depends on MySQL and Grafana services. The following documents will help you configure the necessary dependencies and run OPENALYSIS through the command line tool or API.

- **Example**
- [How to deploy?](./docs/how-to-deploy.md)
- [How to prepare config file?](./docs/how-to-prepare-config-file.md)
- [How to use CMD tool?](./docs/how-to-use-cmd-tool.md)
- [How to use API?](./docs/how-to-use-api.md)

```shell
openalysis restart -t "example-github-token"
```
## Grafana Dashboard Templates

### Sample Configuration File
OPENALYSIS offers four dimensions of Grafana Dashboards:

- **groups**
- [Group](./template/OPENALYSIS-GROUP-TMPL.json)
- [Org](./template/OPENALYSIS-ORG-TMPL.json)
- [Repo](./template/OPENALYSIS-REPO-TMPL.json)
- [Contributor](./template/OPENALYSIS-CONTRIBUTOR-TMPL.json)

Configure the organization or repository you want to analyze on a group basis.

You can set up multiple groups, where each group can contain multiple organizations or repositories.

- **datasource**

The configuration for MySQL, will be used as a datasource for Grafana.

- **backend**

The backend configuration for the service includes settings for `cron`, GitHub `token`, and `retry` attempts.

- **cleaner**

The configuration for unifying contributor's location and company information.

```yaml
groups:
- name: "cloudwego"
orgs:
- "cloudwego"
- "kitex-contrib"
- "hertz-contrib"
- "volo-rs"
repos:
- "bytedance/sonic"
- "bytedance/monoio"
datasource:
mysql:
host: "mysql"
port: "3306"
user: "openalysis"
password: "openalysis"
database: "openalysis?charset=utf8&parseTime=True&loc=Local"
backend:
cron: "@daily"
token: "your-github-token"
retry: 3
# "`Before` => `After`"
cleaner:
- "`@CloudWeGo` => `CloudWeGo`"
- "`@cloudwego` => `CloudWeGo`"
```
## Quick Start
### Step 1: Create GitHub Token
Create a [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).
### Step 2: Start Service
- Use Docker-Compose
Config the command in the `openalysis` service.

```shell
docker-compose up --build
```

- Build from Dockerfile

Start your MySQL and Grafana.

```shell
docker build -t openalysis .
```
Each dashboard provides various forms of visual analysis for the corresponding dimension's data.

```shell
docker run -it -v path2config.yaml:/src openalysis start path2config.yaml
```
### Group Template

### Step 3: Config Grafana
![group-tmpl](./images/tmpl-group-example.png)

1. Visit `127.0.0.1:3000` on browser
2. Add MySQL Datasource
3. Import template in `template` folder
### Organization Template

## Dashboard Effect Display
![org-tmpl](./images/tmpl-org-example.png)

![example-1](./images/example-1.png)
### Repository Template

![example-2](./images/example-2.png)
![repo-tmpl](./images/tmpl-repo-example.png)

![example-3](./images/example-3.png)
### Contributor Template

![example-3](./images/example-4.png)
![contributor-tmpl](./images/tmpl-contributor-example.png)

## Blogs

- [How to Visualize and Analyze Data in Open Source Communities](https://dev.to/justlorain/how-to-visualize-and-analyze-data-in-open-source-communities-1l35) | [中文](https://juejin.cn/post/7359882185362948135)
- [How to Visualize and Analyze Data in Open Source Communities](https://dev.to/justlorain/how-to-visualize-and-analyze-data-in-open-source-communities-1l35)

## Acknowledgement

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:

openalysis:
build: .
command: ["start", "-c", "@daily", "-t", "your-github-token", "-r", "3"]
command: ["start", "-c", "@daily", "-t", "your-github-token", "-r", "3", "path2config.yaml"]
depends_on:
- mysql
- grafana
File renamed without changes.
32 changes: 32 additions & 0 deletions docs/how-to-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# How to deploy?

## Step 1: Create GitHub Token

Create a [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).

## Step 2: Prepare Your Configuration File

Check [How to prepare config file?](./how-to-prepare-config-file.md) for detail.

## Step 3: Prepare MySQL

Use [init.sql](../storage/sql/init.sql) to init tables.

## Step 4: Prepare Grafana

1. Add OPENALYSIS MySQL Datasource

![add-mysql-datasource](../images/ttl-add-mysql-datasource.png)

2. Import template in [template](../template) folder

![import-dashboard-tmpl](../images/ttl-import-dashboard-tmpl.png)

## Step 5: Start OPENALYSIS

- Use command-line tool to start, check [How to use CMD tool?](../docs/how-to-use-cmd-tool.md) for detail.
- Use API to start, check [How to use API?](../docs/how-to-use-api.md) for detail.

## Step 6: Visit Your Dashboard

Happy OPENALYSIS!
Loading

0 comments on commit 3da50eb

Please sign in to comment.