How qianqiuzy/vr_douchong works
VR斗虫 is a Bilibili live-room leaderboard and statistics service, with monthly archiving. The main paths are room configuration and API management, live-room monitoring and websocket event ingestion, metrics persistence, and report queries. The README documents dynamic room add/delete endpoints and monthly rankings; the source index identifies additional runtime and reporting modules whose internals were not excerpted, so their detailed interactions are not inferred here.
Main entry points: api_app.py HTTP API · event_ingestion.py Event ingestion · bootstrap.py Application bootstrap · database.py MySQL database
Components 21
API and rooms
- HTTP API
app/api_app.py - Room configuration
app/room_config.py - Room lifecycle
app/room_lifecycle.py
Live collection
- Bilibili gateway
app/bilibili_gateway.py - Live monitoring
app/monitoring_jobs.py - Websocket client
app/blivedm/clients/ws_base.py - Message dispatch
app/blivedm/handlers.py - Event ingestion
app/event_ingestion.py
Metrics and storage
- Metrics runtime
app/metrics_runtime.py - Whale metrics
app/whale_metrics.py - Redis metrics
app/redis_metrics.py - Report models
app/models/aggregates.py - Session models
app/models/sessions.py - Persistence helpers
app/repositories/tables.py - MySQL database
app/database.py - Monthly archiving
app/archive_service.py
Runtime operations
- Runtime state
app/runtime_state.py - Application bootstrap
app/bootstrap.py - Runtime launcher
app/gift.py
Other components
- Operator
- Bilibili Live
Connections 27
- Operator → HTTP API: manages rooms
- HTTP API → Room configuration: updates rooms
app/api_app.py - HTTP API → Room lifecycle: controls rooms
app/api_app.py - HTTP API → MySQL database: queries reports
app/api_app.py - Operator → Runtime launcher: launches service
- Runtime launcher → Application bootstrap: starts runtime
app/gift.py - Application bootstrap → HTTP API: starts API
app/bootstrap.py - Application bootstrap → Live monitoring: starts jobs
app/bootstrap.py - Application bootstrap → Bilibili gateway: initializes gateway
app/bootstrap.py - Application bootstrap → Monthly archiving: runs archiving
app/bootstrap.py - Live monitoring → Bilibili gateway: fetches room data
app/monitoring_jobs.py - Live monitoring → Runtime state: uses runtime state
app/monitoring_jobs.py - Live monitoring → Event ingestion: starts ingestion
app/monitoring_jobs.py - Bilibili Live → Websocket client: sends live events
app/blivedm/clients/ws_base.py - Websocket client → Message dispatch: dispatches messages
app/blivedm/clients/ws_base.py - Message dispatch → Event ingestion: routes events
- Event ingestion → Runtime state: reads session state
app/event_ingestion.py - Event ingestion → Session models: updates sessions
app/event_ingestion.py - Event ingestion → Report models: updates monthly totals
app/event_ingestion.py - Event ingestion → Whale metrics: records metrics
app/event_ingestion.py - Metrics runtime → Redis metrics: uses metrics cache
app/metrics_runtime.py - Session models → MySQL database: persists records
app/models/sessions.py - Report models → MySQL database: persists aggregates
app/models/aggregates.py - Persistence helpers → MySQL database: uses engine
app/repositories/tables.py - Monthly archiving → MySQL database: copies archive data
app/archive_service.py - Monthly archiving → Persistence helpers: uses table helpers
app/archive_service.py - HTTP API → Whale metrics: reports metrics
app/api_app.py