About this project

SWA (Self-hosted Website Analytics) is a small web analytics server written in Rust that stores its data in SQLite. It is designed to be dropped onto a server and run with no external services: the user interface, the HTTP API and the tracking script are all embedded into one executable through rust-embed, and the database is a single file. Feature set as described by the project: - Single binary distribution that contains the dashboard, the API and the tracker. - SQLite storage in WAL mode, file based and zero configuration. - A two-port architecture: one port serves the public tracker API that receives events, a second port serves the authenticated dashboard. - Pageview tracking plus named call-to-action events, so logins, purchases, downloads or other conversions can be counted alongside visits. - Multi-domain support: several sites can be tracked from one instance and switched between in the dashboard. - Privacy-oriented behaviour: Do-Not-Track is respected, and visitor fingerprints rotate daily rather than relying on cookies. - The dashboard is protected by cookie-based sessions with argon2 password hashing. - The dashboard UI is dark themed and shows real-time statistics, selectable date ranges, Chart.js graphs and automatic refresh. The default ports are 3330 for the tracker API and 3331 for the dashboard UI, with the database defaulting to a local file; all three can be changed with command-line flags. A first-run user opens the dashboard port, registers an account, and then adds the tracking snippet to the sites they want to measure. The tracker is roughly one kilobyte and automatically records page path, referrer, browser, operating system and screen size. In addition to pageviews, the script exposes a global object with an action method taking a name and an optional free-form label, and those events appear in the dashboard's Actions section. The HTTP surface is split accordingly. The tracker port exposes endpoints for recording pageviews, recording named actions and serving the tracking script. The dashboard port exposes authenticated endpoints for overview totals (views, unique visitors, average views per day, total actions), daily pageview series, top pages, top referrers, browser and operating system breakdowns, action statistics, active visitors over the last five minutes, the list of tracked domains, settings retrieval and update, and a bulk deletion of all data for a domain. Registration, login and logout endpoints live on the same port but are public, with login setting a session cookie. The source is organised into a Rust side (entry point with CLI, two-server setup and CORS handling; SQLite schema and queries; request and response models; endpoint handlers; session middleware) and a front-end directory holding the tracker, the dashboard single-page app, the login and registration page, the chart and table logic, and the stylesheet. Deployment guidance covers a systemd unit with automatic restart, and an optional git push-to-deploy flow using a bare repository and a post-receive hook that checks out the code, builds a release binary and restarts the service; the README notes that Rust must be present on the server, or that a cross-compiled binary can be copied over for constrained machines. The project is released under the MIT licence.