How 0xh4ku/babel-discord-translator works
Babel is a self-hosted Discord translator with Guild and Pocket install profiles. Users invoke text translation or Babel Lens from Discord; the app applies language and profile policy, translates through configured providers, accounts for usage, and returns a private result. Operators configure the service and inspect health, metrics, and usage through the dashboard. The README documents queueing, caching, glossaries, and Lens quotas, but their implementation is not present in the sampled excerpts; those connections are shown only at a documented capability level.
Main entry points: lens.ts Babel Lens · translate.ts Text Translation · dashboard.ts Dashboard Routes · commands.ts Command Routing
Components 22
Discord Apps
- Guild Profile
src/apps/app-profile.ts - Pocket Profile
src/apps/app-profile.ts - App Bootstrap
src/apps/bootstrap.ts - Command Routing
src/apps/commands.ts
Translation Core
- Text Translation
src/commands/translate.ts - Babel Lens
src/commands/lens.ts - Usage Accounting
src/modules/usage/usage.ts
Dashboard Operations
- Dashboard Routes
src/modules/dashboard/dashboard.ts - Dashboard UI
src/public/js/app.js - Dashboard Authentication
src/modules/dashboard/auth/dashboard-auth.ts - Session Repository
src/modules/dashboard/auth/session-repository.ts - Health And Metrics
src/modules/dashboard/health-dashboard.ts - Structured Logging
src/shared/structured-logger.ts
Configuration And State
- Runtime Configuration
src/modules/config/config-repository.ts - Shared Store
src/persistence/store.ts - SQLite Database
src/persistence/sqlite-database.ts
Provider Integrations
- Provider Selection
src/infra/provider-orchestrator.ts - Vertex AI Client
src/infra/vertex-ai-client.ts - OpenAI Client
src/infra/openai-client.ts - Cloud Vision OCR
src/infra/cloud-vision-client.ts
Other components
- Discord User
- External AI Services
Connections 28
- Discord User → Command Routing: invokes commands
- App Bootstrap → Guild Profile: selects profile
- App Bootstrap → Pocket Profile: selects profile
- App Bootstrap → Command Routing: registers handlers
- Command Routing → Text Translation: dispatches text
- Command Routing → Babel Lens: dispatches image
- Text Translation → Provider Selection: requests translation
- Babel Lens → Cloud Vision OCR: requests OCR
- Babel Lens → Provider Selection: requests translation
- Provider Selection → Vertex AI Client: selects provider
- Provider Selection → OpenAI Client: selects provider
- Vertex AI Client → External AI Services: sends request
- OpenAI Client → External AI Services: sends request
- Cloud Vision OCR → External AI Services: sends OCR request
- Text Translation → Usage Accounting: accounts usage
- Babel Lens → Usage Accounting: accounts usage
- Text Translation → Runtime Configuration: reads settings
- Babel Lens → Runtime Configuration: reads settings
- Runtime Configuration → Shared Store: reads and updates
- Shared Store → SQLite Database: persists state
- Dashboard UI → Dashboard Routes: calls API
- Dashboard Routes → Dashboard Authentication: checks access
- Dashboard Authentication → Session Repository: reads and writes sessions
- Dashboard Routes → Runtime Configuration: manages settings
- Dashboard Routes → Health And Metrics: serves operations data
- Usage Accounting → Shared Store: persists accounting
- Text Translation → Structured Logging: records events
- Babel Lens → Structured Logging: records events