`regina` is a **python**<!-- ![python-logo](/resources/img/logos/python.svg "snek make analytics go brr") --> program that generates ***analytics*** for a static webpage serverd with **nginx**.
`regina` is easy to deploy and privacy respecting:
- it collects the data from the nginx logs: no javascript/changes to your website required
- data is stored on your device in a **sqlite** database, nothing goes to any cloud
It parses the log and **stores** the important data in an *sqlite*<!-- ![sqlite-logo](/resources/img/logos/sqlite.svg) --> database.
It can then create an analytics html page that has lots of useful **plots** and **numbers**.
<!-- ## Capabilities -->
<!-- ### Statistics -->
<!-- `regina` can generate the following statistics: -->
<!--- visitor count history -->
<!--- request count history -->
<!-- - referrer ranking*(from which site people visit)* -->
<!-- - route ranking*(accessed files)* -->
<!--- browser ranking -->
<!-- - platform ranking*(operating systems)* -->
<!-- - city ranking*(where your site visitors are from)* -->
<!--- country ranking -->
<!--- mobile visitor percentage -->
<!--- detect if a visitor is likely to be human or a bot -->
<!-- All of those plots and numbers can be generated for the**last x days** (you can set*x* yourself) and for**all times**. -->
<!-- ### Visualization -->
<!-- `regina` can use the data above to generate a static analytics page in a single html file. -->
<!-- The visitor and ranking histories are included as plots. -->
<!-- You can view an example page [here](https://quintern.xyz/en/software/regina-example.html) -->
<!-- If that is not enough for you, you can write your own script and use data exported by regina or access the database directly. -->
Most defaults should be fine. The default configuration should also be documented well enough for you to know what do do.
It is strongly recommended to only use absolute paths.
Now you fill collect the data from the nginx log specified as `access_log` in the configuration into the database specified at the `database` location (or `~/.local/share/regina/my-server.com.db` if left blank):
```
regina --config ~/.config/regina/regina.cfg --collect
```
To visualize the data, run:
```
regina --config ~/.config/regina/regina.cfg --visualize
```
This will generate plots and statistics and replace all variables in `template_html` and output the result to `html_out_path`.
If `html_out_path` is in your webroot, you should now be able to access the generated site.
In our example, `/www` will look like this:
```
/www
|-- analytics
| |-- analytics.html
| |-- img
| |-- ranking_referer_total.svg
| |-- ranking_referer_last_x_days.svg
| ...
|-- resources
| |-- image.jpg
|-- index.html
```
### Automation
You will probably run `regina` once per day, after `nginx` has filled the daily access log. The easiest way to that is using a *cronjob*.