Skip to content

ruslan-korneev/lingooru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lingooru

CI codecov

Python 3.13+ aiogram 3.x FastAPI Ruff uv mypy License: MIT

Telegram bot for language learning with spaced repetition, voice practice, and AI-powered feedback.

Features

Learning

  • Vocabulary Management - Add words manually or from curated word lists
  • Spaced Repetition (SM-2) - Anki-like algorithm for optimal memorization
  • Multi-language Support - English and Korean learning with Russian interface

Practice

  • Voice Pronunciation - Record voice messages, get AI feedback via OpenAI Whisper
  • Audio Playback - Listen to word pronunciations (gTTS with S3/MinIO caching)
  • Review Sessions - Track progress with quality ratings

Technical

  • aiogram 3.x - Modern async Telegram bot framework
  • FastAPI - REST API with async support
  • SQLAlchemy 2.0 - Async ORM with PostgreSQL
  • i18n - Localized interface (Russian, English, Korean)

Prerequisites

  • Python 3.13+
  • uv package manager
  • PostgreSQL 17+
  • Docker (for MinIO)

Quick Start

1. Setup Environment

# Clone and enter project
cd lingooru

# Create and activate virtual environment
uv venv && source .venv/bin/activate
uv sync --all-groups

2. Configure

# Copy example config
cp .env.example .env

# Edit with your credentials
$EDITOR .env

Required settings:

# Database
DB__HOST=localhost
DB__PORT=5432
DB__NAME=lingooru
DB__USERNAME=postgres
DB__PASSWORD=postgres

# Telegram
telegram__bot_token=YOUR_BOT_TOKEN

# OpenAI (for voice recognition)
openai__api_key=YOUR_OPENAI_KEY

# S3/MinIO (for audio caching)
S3__ENDPOINT_URL=http://localhost:9000
S3__ACCESS_KEY=minioadmin
S3__SECRET_KEY=minioadmin
S3__BUCKET_NAME=lingooru-audio

3. Start Services

# Start MinIO for audio storage
docker run -d \
  --name minio \
  -p 9000:9000 \
  -p 9001:9001 \
  -v ~/minio/data:/data \
  -e MINIO_ROOT_USER=minioadmin \
  -e MINIO_ROOT_PASSWORD=minioadmin \
  minio/minio server /data --console-address ":9001"

# Create bucket
docker exec minio mc alias set local http://localhost:9000 minioadmin minioadmin
docker exec minio mc mb local/lingooru-audio --ignore-existing
docker exec minio mc anonymous set download local/lingooru-audio

4. Run Migrations

uv run alembic upgrade head

5. Start Bot

# Run Telegram bot
make bot

# Or run API server
uv run uvicorn main:app --host 0.0.0.0 --port 8000

Bot Commands

The bot uses inline keyboards for navigation. Main features:

Button Description
πŸ“š Π£Ρ‡ΠΈΡ‚ΡŒ Learn new words
πŸ”„ ΠŸΠΎΠ²Ρ‚ΠΎΡ€ΡΡ‚ΡŒ Review due words (spaced repetition)
🎀 ΠŸΡ€ΠΎΠΈΠ·Π½ΠΎΡˆΠ΅Π½ΠΈΠ΅ Practice pronunciation with voice
πŸ“‹ МСню Main menu with stats

Learning Flow

  1. Add Words - From word lists or manually
  2. Learn - See word, translation, example; rate as Know/Hard/Forgot
  3. Review - Spaced repetition based on SM-2 algorithm
  4. Voice Practice - Record pronunciation, get AI feedback

Development

Code Quality

make              # Run all checks (fmt, lint, db, test)
make fmt          # Format code with ruff
make lint         # Lint with ruff and mypy (strict)
make test         # Run pytest with coverage
make db           # Validate migrations

Project Structure

src/
β”œβ”€β”€ bot/                    # Telegram bot
β”‚   β”œβ”€β”€ handlers/           # Message & callback handlers
β”‚   β”œβ”€β”€ keyboards/          # Inline & reply keyboards
β”‚   β”œβ”€β”€ locales/            # i18n translations (ru, en, ko)
β”‚   └── middleware/         # User loading, i18n
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ audio/              # TTS generation & S3 storage
β”‚   β”œβ”€β”€ srs/                # Spaced repetition (SM-2)
β”‚   β”œβ”€β”€ users/              # User management
β”‚   β”œβ”€β”€ vocabulary/         # Words, translations, user dictionary
β”‚   └── voice/              # Voice transcription & feedback
β”œβ”€β”€ core/                   # API core (routes, middleware, DI)
β”œβ”€β”€ db/                     # Database config & sessions
└── config.py               # Application settings

tests/
β”œβ”€β”€ unit/                   # Unit tests
β”œβ”€β”€ integration/            # API & database tests
└── conftest.py             # Shared fixtures

Adding Features

See CLAUDE.md for detailed development guidelines.

Testing

# Run all tests
make test

# Run by category
uv run pytest -k unit -v
uv run pytest -k integration -v

# Run specific module
uv run pytest tests/unit/modules/audio/ -v

Coverage requirements: 80% line, 70% branch.

Configuration

Variable Description Default
DB__* PostgreSQL connection localhost:5432
telegram__bot_token Telegram bot token -
openai__api_key OpenAI API key -
S3__ENDPOINT_URL MinIO/S3 endpoint http://localhost:9000
S3__ACCESS_KEY S3 access key -
S3__SECRET_KEY S3 secret key -
S3__BUCKET_NAME Audio bucket name lingooru-audio
LOGGING_LEVEL Log level INFO

License

MIT

About

Lingooru - AI Telegram bot for studying foreign languages.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages