Telegram bot + FastAPI backend for recommending classic poems in English and Russian, checking memorization, and managing the poem catalog through a built-in admin panel.
This version deliberately does not use OpenAI API, neural networks, or any other AI service.
- recommendation logic is rule-based
- memorization check is based on token overlap
- text messages are processed automatically
- audio messages are accepted and recorded in learner history, but not transcribed automatically
- an admin panel is included for adding, formatting, editing, and activating poems
This still satisfies the coursework requirement to accept both text and audio messages, while keeping the implementation deterministic and fully reproducible.
- Backend: FastAPI + SQLModel + SQLite
- Frontend: Telegram Bot (
python-telegram-bot) - Admin panel: server-rendered FastAPI pages + Basic Auth
- Deployment: Docker + Docker Compose
- Elicit user preferences by chat
- Store user history and learner profile
- Recommend a poem by language, difficulty, and theme
- Check memorization from text recall
- Record recommendation outcomes
- Track audio submissions in learner history
- Manage poem catalog from
/admin/
The Telegram bot supports both free text and inline-button navigation.
- interactive menu via
/start - preference builder with buttons: language, difficulty, theme
- one-tap memory check prompt
- quick actions after each response (new recommendation, memory check, main menu)
- voice-message shortcut flow with guidance
- interface language switcher (RU/EN) in the main menu
- recommendation replies include a clearer "what to do next" step-by-step block
Open:
http://localhost:8000/admin/
Credentials are configured in .env:
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123The admin panel supports:
- adding new poems
- editing existing poems
- deleting poems
- formatting poem text (line cleanup)
- auto-detecting the first line
- enabling/disabling poems for recommendation
- viewing recent audio submissions
python -m venv venvLinux / macOS:
source venv/bin/activateWindows CMD:
venv\Scripts\activate.batpip install -r requirements.txtcp .env.example .envSet at least:
TELEGRAM_BOT_TOKEN=your_telegram_token
BACKEND_PUBLIC_URL=http://localhost:8000
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123For local run (without Docker), BACKEND_PUBLIC_URL must stay on localhost or 127.0.0.1.
python -m uvicorn app.main:app --reloadpython -m bot.main- Health:
http://127.0.0.1:8000/health - Admin panel:
http://127.0.0.1:8000/admin/ - Swagger:
http://127.0.0.1:8000/docs
cp .env.example .envIn Docker mode, docker-compose.yml overrides bot backend URL to http://backend:8000 automatically.
docker compose up -d --builddocker-compose.yml mounts source folders into containers:
./app -> /app/app./bot -> /app/bot
After changing Python code, rebuild is usually not needed. Restart only the changed service:
docker compose restart backend
docker compose restart botdocker compose logs -f backend
docker compose logs -f botPOST /api/chatPOST /api/audio-messageThe audio endpoint stores Telegram audio metadata in the database and returns a message asking the user to provide the poem lines as text.
If the instructor asks why voice is not transcribed automatically, the answer is simple:
The project intentionally avoids external AI APIs and neural networks. Audio messages are still accepted by the system and recorded in the learner profile, while memorization assessment is performed deterministically on text input.
See LICENSE.