📦 navidrome / insight-charts

📄 README.md · 96 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96# insight‑charts

## Overview

`insight‑charts` processes insight records from
[Navidrome](https://www.navidrome.org) and generates
[Vega-Lite](https://vega.github.io/vega-lite/) charts.

### Charts implemented so far

- **Operating system distribution**
- **Number of instances over time**
- **File systems used for music files**
- **File systems used for data files**
- **Player types/clients used**

## Requirements

- [Deno](https://deno.land/) runtime
- SQLite database with Navidrome insights data

## Installation

```bash
git clone https://github.com/yourusername/insight-charts.git
cd insight-charts
```

### Using Deno tasks (recommended)

```bash
# development; auto‑reloads on file change
deno task dev

# produce a standalone native binary in ./insight‑charts
deno task build
```

## Configuration

### Environment variables

| Variable             | Purpose                                                                      | Example                            |
| -------------------- | ---------------------------------------------------------------------------- | ---------------------------------- |
| `INSIGHT_DB_PATH`    | Path to the SQLite database. **Required** if `--db-path` flag is not passed. | `INSIGHT_DB_PATH=./db/insights.db` |
| `INSIGHT_OUTPUT_DIR` | Folder where chart JSON files will be written.                               | `INSIGHT_OUTPUT_DIR=./charts`      |
| `INSIGHT_VERBOSE`    | Enable timestamped log lines (`1`, `true`, `yes`).                           | `INSIGHT_VERBOSE=1`                |

A sample file (`.env.example`) is provided; copy it to `.env` and adjust:

```bash
cp .env.example .env
# ...edit as needed...
```

## Usage

### Using only environment variables

```bash
INSIGHT_DB_PATH=./db/insights.db \
INSIGHT_OUTPUT_DIR=./charts \
deno run -ERW main.ts
```

### Compiled binary

After `deno task build`:

```bash
./insight-charts -d ./db/insights.db -o ./charts -v
```

### Options

| Flag                      | Description                           | Default |
| ------------------------- | ------------------------------------- | ------- |
| `-d, --db-path <path>`    | Path to the SQLite database           | —       |
| `-o, --output-dir <path>` | Output directory for chart JSON files | `.`     |
| `-v, --verbose`           | Prepend date & time to log messages   | off     |
| `--help`                  | Show built‑in help                    | —       |

### View the visualisations

```bash
deno task serve
```

## Docker

### Build

```bash
docker build -t insight-charts .
```