How ndrvndr/ai-toxic-moderator works
AI Toxic Moderator is a dashboard and backend for moderating Indonesian YouTube Live Chat. A channel owner signs in, selects a broadcast, and starts monitoring; the API records a run that the worker polls, ingests chat for, and evaluates for blacklist and AI moderation. The worker may plan and execute guarded moderation actions, while the dashboard receives live updates and exposes controls, settings, and saved history. The graph keeps these product stages distinct. Several capabilities are documented but their implementation was not sampled, so those links cite the README rather than implying source inspection.
Main entry points: api-client.ts API client · automatic-ai-cycle.ts Moderation cycles · live-page.tsx Live controls · monitoring.service.ts Monitoring lifecycle
Components 28
Dashboard
- Login and session
apps/dashboard/features/auth/components/login-page.tsx - Live controls
apps/dashboard/features/live/components/live-page.tsx - Live chat
apps/dashboard/features/live/components/live-chat-panel.tsx - History reports
apps/dashboard/features/history/components/history-page.tsx - Moderation settings
apps/dashboard/features/moderation-settings/components/moderation-settings-page.tsx - API client
apps/dashboard/lib/api-client.ts
API
- OAuth and sessions
apps/api/src/auth/google.service.ts - Monitoring lifecycle
apps/api/src/monitoring/monitoring.service.ts - Chat endpoints
apps/api/src/chat/chat.module.ts - Live events and access
apps/api/src/live/live.gateway.ts - Saved sessions
apps/api/src/live/saved-sessions.controller.ts - Settings endpoints
apps/api/src/settings/ai-moderation-settings.service.ts - API database access
apps/api/src/database.module.ts
Worker
- Worker runtime
apps/worker/src/ingestion/worker-runtime.ts - Ingestion coordinator
apps/worker/src/ingestion/coordinator.ts - Polling and leases
apps/worker/src/ingestion/poll-cycle.ts - Batch persistence
apps/worker/src/ingestion/batch-writer.ts - Moderation cycles
apps/worker/src/ingestion/automatic-ai-cycle.ts - Action execution
apps/worker/src/ingestion/ban-executor.ts - AI inference and planning
apps/worker/src/ingestion/ai-shadow-runner.ts
Moderation
- Moderation rules
packages/moderation-core/src/rule-engine.ts - Action planning
packages/moderation-core/src/ai-action-planner.ts
Shared packages
- Shared contracts
packages/contracts/src/youtube-ingestion.ts - Persistence utilities
packages/persistence/src/live-events.ts
Other components
- Channel owner
- PostgreSQL
- YouTube services
- Google OAuth
Connections 28
- Channel owner → Login and session: signs in
- Login and session → API client: requests session
- API client → OAuth and sessions: authenticates
- OAuth and sessions → Google OAuth: authorizes
- Channel owner → Live controls: selects broadcast
- Live controls → API client: requests monitoring
- API client → Monitoring lifecycle: starts or stops
- Monitoring lifecycle → YouTube services: verifies ownership
- Monitoring lifecycle → PostgreSQL: records run
apps/api/src/monitoring/monitoring.service.ts - Worker runtime → Ingestion coordinator: ticks
apps/worker/src/ingestion/worker-runtime.ts - Ingestion coordinator → Polling and leases: coordinates polling
apps/worker/src/ingestion/coordinator.ts - Polling and leases → YouTube services: retrieves chat
- Ingestion coordinator → Batch persistence: persists batches
apps/worker/src/ingestion/coordinator.ts - Batch persistence → PostgreSQL: writes observations
- Moderation cycles → Moderation rules: checks messages
- Moderation cycles → AI inference and planning: evaluates AI
- AI inference and planning → Action planning: plans actions
- Moderation cycles → Action execution: dispatches actions
- Action execution → YouTube services: applies moderation
- Live controls → Live events and access: opens updates
- Live events and access → Live chat: streams events
- Live chat → Chat endpoints: requests decisions
- History reports → Saved sessions: loads saved history
- Moderation settings → Settings endpoints: saves settings
- Settings endpoints → PostgreSQL: stores revisions
- Saved sessions → PostgreSQL: reads sessions
- API database access → Persistence utilities: creates pool
apps/api/src/database.module.ts - Batch persistence → Shared contracts: uses ingestion types