An open API service indexing awesome lists of open source software.

https://github.com/aldrees7/language-companion

Streamlit-based AI Language Tutor β€” explain grammar, translate text, generate quizzes, and run SRS reviews with memory persistence. Built with OpenAI + Python.
https://github.com/aldrees7/language-companion

ai education langchain language-learning nlp openai python srs streamlit tutor

Last synced: about 2 months ago
JSON representation

Streamlit-based AI Language Tutor β€” explain grammar, translate text, generate quizzes, and run SRS reviews with memory persistence. Built with OpenAI + Python.

Awesome Lists containing this project

README

          

# πŸ§‘β€πŸ« Language Companion
**An AI-powered study partner for language learners.**
Paste any lesson or upload files to explain, translate, analyze grammar, generate quizzes, extract vocabulary, and build review notes with spaced-repetition tracking.

---

## πŸš€ Quick Start

### 1️⃣ Install dependencies
```bash
uv venv
uv sync
```

### 2️⃣ Set your API key
```bash
# PowerShell
$env:OPENAI_API_KEY="sk-..."
# or Linux/Mac
export OPENAI_API_KEY="sk-..."
```

### 3️⃣ Launch the app
```bash
uv run streamlit run src/app/app.py
```

---

## ✨ Features

### 🧩 Core Modes
| Mode | Description |
|-------|--------------|
| **Explain** | Simplifies and paraphrases text for A2/B1 learners. |
| **Translate** | Produces a natural, fluent English translation. |
| **Grammar** | Highlights key grammar points and examples. |
| **Quiz** | Generates 10 mixed question types (MCQ, cloze, meaning). |
| **Vocab** | Extracts 10–12 key words/phrases with examples. |

---

### 🧾 Review Note Formats
| Format | Output Style | Use Case |
|---------|---------------|----------|
| **Study Sheet** | Structured sections (TL;DR, Grammar, Vocab, Drills). | Print-style learning notes. |
| **Flashcards** | `Q:` / `A:` pairs. | Self-testing or Anki import. |
| **Compact** | 1-line bullets for quick review. | Mobile or smartwatch notes. |

---

### πŸ’Ύ Spaced Repetition System (SRS)
- Vocabulary cards saved locally in `src/data/srs_db.json`.
- Grading buttons adjust review schedule:
- **Again:** soon (reset)
- **Hard:** shorter delay
- **Good:** normal delay
- **Easy:** longer delay
- Persistent storage β€” all progress is saved between sessions.

---

### πŸ“‚ File Support
Supports `.txt`, `.md`, `.pdf`, and `.docx` uploads.
Automatically extracts text using **PyMuPDF** (for PDFs) and **python-docx** (for Word files).

---

## 🧠 Architecture Overview

```
src/
β”œβ”€ app/
β”‚ └─ app.py # Streamlit UI
β”œβ”€ agent_core/
β”‚ β”œβ”€ agent.py # LangChain logic and prompts
β”‚ └─ prompts/system.json # Base system prompt
β”œβ”€ utils/
β”‚ β”œβ”€ constants.py # Configuration values
β”‚ β”œβ”€ storage.py # Local JSON persistence
β”‚ └─ srs.py # Spaced repetition scheduler
└─ data/
└─ srs_db.json # Local SRS deck
```

---

## 🧩 Tech Stack
| Component | Library |
|------------|----------|
| **Frontend** | Streamlit |
| **LLM / Agents** | LangChain + OpenAI (GPT-4o-mini) |
| **Data Handling** | JSON (local storage) |
| **PDF & Word Parsing** | PyMuPDF, python-docx |
| **Code Quality** | Ruff + Black |
| **Dependency Management** | uv |

---

## πŸ”§ Constants & Config
All static configuration lives in `src/utils/constants.py` β€” including:
- model (`OPENAI_MODEL`)
- SRS intervals
- review batch size
- upload limits
- paths for data and review notes

---

## πŸ§ͺ Example Usage
Upload a file or paste text such as:

```
Anna steht frΓΌh auf und geht in das kleine CafΓ© an der Ecke.
Sie bestellt einen Kaffee mit Milch und ein BrΓΆtchen mit Marmelade.
```

Then choose:
- Mode β†’ **Explain**
- Review Note Format β†’ **Study Sheet**
- Click **Analyze** or **πŸ“ Make Review Note**

---

## πŸ“˜ Project Status
βœ… Functional & stable prototype.
πŸ’‘ Optional future upgrades:
- Deck statistics in sidebar.
- Lesson history viewer.
- Cloud sync for user data.

---

## βš–οΈ License
MIT License Β© 2025 Language Companion Developers