About this project

## Project Overview `bsz` (Busuanzi) is a self‑hosted visitor statistics system that is compatible with the Busuanzi statistics API. The backend is written in Rust and compiles to a single binary file with no external library dependencies, greatly reducing operational overhead. The frontend uses bun workspaces and provides a separate landing page and an optional admin dashboard, which can be deployed independently. ## Main Features - **Single binary, zero dependencies**: The backend requires only one executable file and can be run on a VPS, Docker container, or as a system service. - **Busuanzi API compatibility**: Sites currently using the Busuanzi script only need to change the statistics endpoint URL to migrate. - **Fully decoupled front‑ and back‑end**: The backend offers a JSON API, the landing page is a pure static site, and the admin is a SPA; all three can be deployed separately or together. - **Optional admin dashboard**: Setting `ADMIN_TOKEN` enables the Admin API; if not configured, the admin routes are absent, improving security. - **Lightweight frontend**: The landing page consists of static assets that can be hosted on GitHub Pages, Cloudflare Pages, etc.; the admin uses a Vite + React (or similar) single‑page application. - **Easy local debugging**: Provided `cargo run` and `bun run dev:*` scripts allow quick startup for development and demos. ## Architecture . ├── backend/ # Rust backend, provides /api/* statistics endpoints and optional /api/admin/* management endpoints └── frontend/ # bun workspaces └── packages/ ├── shared/ # UI components, theme, Tailwind presets ├── landing/ # Landing page (apex), pure static └── admin/ # Admin dashboard SPA (dash), optional deployment - **backend**: Built with `actix-web` (or similar). By default only the statistics routes are mounted. If the environment variable `ADMIN_TOKEN` is non‑empty, additional admin routes are mounted. - **landing**: Contains only static HTML, CSS, and JS, displaying visitor counts, documentation links, and a link to the admin dashboard. - **admin**: After login, users can view real‑time visitor data, historical statistics, IP blacklists, etc. All requests are authenticated through the backend Admin API. ## Quick Start (5‑minute setup) # 1. Start the backend (Terminal 1) cd backend && ADMIN_TOKEN=test-token cargo run # 2. Start the Landing page (Terminal 2) cd frontend && bun install bun run dev:landing # visit http://localhost:12702 # 3. Start the Admin dashboard (Terminal 3) bun run dev:admin # visit http://localhost:12705 ## Deployment Guide ### Backend Deployment - **Binary**: `cargo build --release` produces `target/release/bsz`. Copy it to the server and set `ADMIN_TOKEN` (optional), `PORT`, and other environment variables. - **systemd**: A sample unit file is provided for automatic start on boot and log management. - **nginx reverse proxy**: Forward `/api/` paths to the backend; static assets can be served via a CDN. ### Landing Deployment bun run build:landing # output is in frontend/packages/landing/dist/ # Upload the dist/ directory to GitHub Pages, Cloudflare Pages, or any static hosting service. ### Admin Deployment VITE_API_BASE_URL=https://api.example.com \ bun run build:admin # output is in frontend/packages/admin/dist/ # Deploy to a static hosting platform; when accessing, provide the backend URL and ADMIN_TOKEN to bind. ## Configuration - `ADMIN_TOKEN`: When non‑empty, the backend mounts `/api/admin/*`. The admin frontend uses the same token for authentication. - `VITE_API_BASE_URL`: Injected at build time into the admin frontend to specify the backend API base URL. - Other environment variables (e.g., `PORT`, `RATE_LIMIT`) have default values defined in `backend/.env`. ## License The project is released under the MIT License, allowing free use, modification, and distribution. --- For more detailed documentation, refer to the `backend/README.md`, `frontend/packages/landing/README.md`, and `frontend/packages/admin/README.md` files in the repository.