How soxft/busuanzi works
Busuanzi is a self-hosted visitor-statistics service. A website visitor’s browser runs the supplied counter script; the service identifies the visitor, derives site/page keys, updates or reads UV/PV counts in Redis, and returns counts to the client. The API also supports write-only and JSONP modes, while the server serves scripts and a status page. The README documents Pjax compatibility, migration support, and privacy-oriented hashing; source excerpts do not show all client-side or migration details, so those connections are documented at capability level rather than expanded into guessed internals.
Main entry points: route.go HTTP routes · main.go Service startup · count.go UV/PV operations · redisutil.go Redis client
Components 19
Web and clients
- Counter scripts
dist/busuanzi.ts - Pjax clients
dist/busuanzi.pjax.lite.ts - HTTP routes
process/webutil/route.go - Web server
process/webutil/webutil.go - Status page
app/controller/index.go - Health endpoint
app/controller/ping.go
Request handling
- Visitor identity
app/middleware/identity.go - Identity tokens
library/jwtutil/token.go - Count API
app/controller/api.go - CORS policy
app/middleware/cors.go
Counting domain
- UV/PV operations
core/count.go - Key expiration
core/expire.go - Privacy hashing
library/tool/hash.go
Runtime and storage
- Configuration
config/config.go - Service startup
main.go - Redis client
process/redisutil/redisutil.go - Redis data store
Other components
- Website visitor
- Original Busuanzi data
Connections 25
- Website visitor → Counter scripts: uses
README.md - Website visitor → Pjax clients: uses
README.md - Counter scripts → HTTP routes: requests counts
- Pjax clients → HTTP routes: requests counts
- Web server → HTTP routes: registers routes
process/webutil/webutil.go - HTTP routes → Count API: dispatches API
process/webutil/route.go - HTTP routes → Visitor identity: applies identity
process/webutil/route.go - HTTP routes → Status page: serves page
process/webutil/route.go - HTTP routes → Health endpoint: dispatches ping
process/webutil/route.go - HTTP routes → Counter scripts: serves script
process/webutil/route.go - Visitor identity → Identity tokens: checks and signs
app/middleware/identity.go - Visitor identity → Privacy hashing: derives identity
app/middleware/identity.go - Count API → UV/PV operations: counts or reads
app/controller/api.go - UV/PV operations → Privacy hashing: hashes keys
core/count.go - UV/PV operations → Redis client: reads and writes
core/count.go - UV/PV operations → Key expiration: schedules expiration
core/count.go - Key expiration → Redis client: expires keys
core/expire.go - Redis client → Redis data store: connects
process/redisutil/redisutil.go - Service startup → Configuration: initializes
main.go - Service startup → Redis client: initializes
main.go - Service startup → Key expiration: initializes
main.go - Service startup → Web server: starts
main.go - Web server → CORS policy: applies middleware
process/webutil/webutil.go - CORS policy → Configuration: reads version
app/middleware/cors.go - Original Busuanzi data → Redis data store: imports counts
README.md