About this project

## Overview Data Relish is an open‑source, self‑hosted web analytics system written in PHP with a MySQL backend. It focuses on simplicity: a single function call logs any event, and a dashboard visualises daily unique visitors, event breakdowns and top countries using Chart.js. The project is suitable for small‑to‑medium websites that need basic traffic insights without relying on third‑party services. ## Key Features - **Event logging** – One‑line PHP call `log_event("type", "target")` records visits and custom events. - **IP enrichment** – Parallel routine translates IP addresses to country codes, allowing geographic reporting. - **Dashboard** – Shows unique visitors per day, event distribution, and top countries in interactive charts. - **Self‑hosted** – Runs on any PHP‑compatible server with MySQL; no external SaaS dependencies. - **Password‑protected UI** – Simple password check (`?pass=...`) guards the dashboard. ## Installation & Setup 1. **Database** – Import `data-relish.sql` into MySQL to create the required table. 2. **Configuration** – Edit the database credentials at the top of `log_event.php` and `dashboard.php`. 3. **Instrumentation** – Include `log_event.php` in any page you wish to track and call `log_event("event type", "event target");`. 4. **Dashboard access** – Open `dashboard.php?pass=changeme` in a browser and change the default password in the file. 5. **Country data** – Click the *Enrich Country Data* button on the dashboard or run `update_countries.php` manually to populate geographic information. ## Project Structure - `data-relish.sql` – MySQL schema for the `events` table. - `log_event.php` – Contains the DB connection and the `log_event` function. - `dashboard.php` – Generates the analytics UI and renders charts via Chart.js. - `update_countries.php` – Script that resolves stored IPs to country codes. ## Usage Example ```php include('log_event.php'); log_event('page_view', '/home'); ``` After deploying the above snippet on any page, visits will appear in the dashboard under *Unique Visitors* and *Top Countries*. ## Live Demo The author runs Data Relish on a personal site; the dashboard is publicly reachable at: https://zerovst.com/admin/data/stats.php?pass=jabberwocky!20o2 ## Development Status The project is still under active development. Users are encouraged to test in non‑critical environments and contribute improvements via pull requests. ## License Data Relish is released under the MIT License, allowing free use, modification, and distribution. --- *Data Relish provides a straightforward, privacy‑friendly alternative to cloud analytics services, giving developers full control over their traffic data.*