Learning Bot Admin — Language Learning Platform
Admin web app and API for managing a language-learning Telegram bot. Multi-language support, AI-assisted content generation, and comprehensive word/user management.
Learning Bot Admin
An admin web app + API for inspecting and managing data for a language-learning Telegram bot.
What the product is
- Admin web app + Admin API for a language-learning Telegram bot (bot itself is a separate repo)
- Supports per-language database configuration (stored in Supabase) and per-language MongoDB data (words, bot users, sessions)
- Provides word editing (definitions, translations, examples, grammar, audio), user dictionary management, and AI-assisted content/audio regeneration
- Production-leaning CRUD flows: login, language DB selection, listings, edits
- AI regeneration runs synchronously and relies on external services (OpenAI, GCS)
Core user flows
- Admin login → token stored in localStorage → select a language database → navigate admin area
- Manage language databases — list/create/update/delete, activate/deactivate
- Browse Mongo collections (botusers, words, sessions) with search, sort, pagination, and word-specific filters
- View/edit a word entry — update fields manually, edit grammar JSON, or regenerate definition/translations/examples/audio with AI; save changes
- Batch AI regeneration for multiple words: preview changes, optionally apply word normalization, promote generated audio, or cancel
- View bot user details and progress — open user dictionary; edit repetition parameters or delete/mark entries as new
- Update per-language settings (currently Google Cloud Storage bucket name)
System architecture
Frontend
- React SPA (Vite + Tailwind) under
/adminroutes - React Router, Redux for auth and language DB list
- Auth uses localStorage for JWT; axios interceptor injects
Authorization: Bearer
Backend
- Express API at
/api/admin, protected by JWT auth - Routing:
/api/admin/loginreturns JWT;/select-languageissues a new JWT withselectedLanguageDbId - JWT middleware attaches
req.adminUserfor protected routes
Data & integrations
- Supabase for
admin_usersandlanguage_dbsconfiguration - MongoDB per language for words, botusers, sessions
- OpenAI for text and TTS regeneration
- Google Cloud Storage for audio files
Environment wiring
- Vite dev proxy and Nginx in production route
/api/adminto the admin server
Key services
| Service | Responsibility |
|---------|----------------|
| admin-auth-service | Supabase lookup + bcrypt, JWT generation |
| language-db-service | CRUD for language DBs; closes Mongo connections on URI changes |
| mongo-admin-service | List/get documents (whitelisted collections), word read/update |
| user-dictionary-service | Query/update per-user vocabulary entries and join with words |
| ai-regenerate-service | OpenAI regeneration, audio preview/apply/cancel |
| ai-batch-regenerate-service | Batch processing with preview workflow |
| audio-storage-service | GCS uploads, temp paths, promotion, deletion |
Learning & repetition logic
- User vocabulary entries live under
botusers.vocabularyand reference words by ObjectId - Each entry stores:
repetition,easeFactor,interval, andnextRepetition - Status derived in Mongo aggregation:
newifnextRepetitionis nulldueifnextRepetition <= nowscheduledotherwise
Admin actions:
- Update repetition fields and
nextRepetition - Mark as new by setting
nextRepetitionto null - Delete vocabulary entries
Note: The actual spaced-repetition algorithm that updates these fields lives in the bot repo.
Scalability & extensibility
- Multi-language support modeled as a Supabase-backed registry of language DBs
- Selected DB is embedded in JWT and used to resolve Mongo URI per request
- Mongo connections are pooled and cached with explicit cleanup on DB changes and shutdown
- AI regeneration is scoped (definition/translations/examples/audio/all) with strict JSON responses and language-specific prompts
- Batch mode includes preview/apply/cancel workflows
- Audio regeneration uses temp files in GCS with validated paths, then promotes to stable final paths for safe preview and rollback
- Admin endpoints restrict Mongo access to a whitelist of collections to limit exposure
DevOps & operations
Docker
- Server container (Node 20, TypeScript build)
- App container (Vite build served by Nginx)
docker-compose.ymlfor prod anddocker-compose.dev.ymlwith live mounts and health checks
Environment variables
ADMIN_JWT_SECRET, Supabase URL and service role key- OpenAI key, GCS bucket and credentials
VITE_API_HOSTfor local proxy target
Testing
- Frontend component tests with Vitest/RTL
- No server test suite in this repo (yet)
Technical highlights
- Multi-language architecture with dynamic Mongo connection resolution per request
- AI-assisted content pipeline with preview/apply/cancel workflow
- Secure audio handling with temp → final path promotion
- JWT-based auth with language context embedded in token
- Production-ready Docker setup with separate server and app containers
Limitations & future improvements
| Area | Current State | Planned | |------|---------------|---------| | AI regeneration | Synchronous in request handlers | Background queue with retry policy | | Auth | JWT + localStorage, single role | RBAC, refresh tokens | | Error handling | Inconsistent, console-based logging | Structured logs, consistent responses | | Testing | Frontend tests only | Server-side test suite | | Schema validation | Minimal, relies on Mongo flexibility | Zod/Joi validation layer |
Tech stack
Frontend: React, Vite, Tailwind CSS, Redux, React Router, Axios Backend: Node.js, Express, TypeScript Database: MongoDB, Supabase (PostgreSQL) AI: OpenAI API (GPT-4, TTS) Storage: Google Cloud Storage DevOps: Docker, Nginx, GitHub Actions
Interested in working together?
I'm available for consulting and development projects.