Backend-for-Frontend (BFF) with Centralized AI Processing
Version 6.0 | BUILD #107
┌─────────────────────────────────────────────────────────────────┐ │ YAKKI EDU │ ├─────────────────────────────────────────────────────────────────┤ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Android │ │ Flutter │ │ Web │ │ │ │ (Kotlin) │ │ (Dart) │ │ (Future) │ │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │ │ │ │ │ │ └──────────────────┼──────────────────┘ │ │ │ │ │ ┌───────▼───────┐ │ │ │ yakki-intel │ │ │ │ (Rust+Axum) │ │ │ │ api.yakki.app │ │ │ └───────┬───────┘ │ │ │ │ │ ┌───────▼───────┐ │ │ │ Gemini 2.0 │ │ │ │ Flash │ │ │ └───────────────┘ │ └─────────────────────────────────────────────────────────────────┘
Pattern
Backend-for-Frontend (BFF)
Current State
Hybrid online/offline
Target State
Full multi-platform
| Component | Technology | Purpose |
|---|---|---|
| Framework | Axum | Async HTTP server |
| Database | SQLite | User/Grammar/Vocabulary storage |
| AI | Gemini 2.0 Flash | Content generation & validation |
| Auth | bcrypt | Password hashing (cost 12) |
| Runtime | Tokio | Async runtime |
server/yakki-intel/src/ ├── main.rs # Routes & server setup ├── auth_handlers.rs # Login, registration, user management ├── handlers.rs # Legacy endpoints ├── batch_handlers.rs # Parallel mission generation ├── vocabulary_handlers.rs # Grammar rules & vocabulary ├── heartbeat_handlers.rs # Online status tracking ├── db.rs # SQLite operations ├── models.rs # Data structures ├── config.rs # Environment configuration └── gemini.rs # Gemini AI client
┌───────────────────────────────────────────────────────────────────┐
│ :app │
│ (DI, Navigation, MainActivity, UI Screens, YakkiApp) │
└────────────────────────┬──────────────────────────────────────────┘
│ depends on
┌────────────────┼────────────────┬─────────────────┐
▼ ▼ ▼ ▼
┌─────────┐ ┌─────────────┐ ┌─────────┐ ┌──────────────┐
│ :domain │ │ :data │ │:conductor│ │:intel-reader │
│(Models) │◀───│(Room+Ktor) │ │ (Logic) │ │(Feature Mod) │
└─────────┘ └─────────────┘ └─────────┘ └──────────────┘
▲ │ │ │
└────────────────┴────────────────┴────────────────┘
depends on :domain
libraries/intel-reader/
├── di/
│ └── NetworkModule.kt
├── network/
│ └── IntelReaderApiService.kt
├── repository/
│ └── IntelReaderRepository.kt
├── ui/
│ ├── IntelReaderComponent.kt
│ ├── IntelReaderViewModel.kt
│ ├── LoginScreen.kt
│ ├── DebugScreen.kt
│ ├── MissionSelectScreen.kt
│ ├── MissionCreateScreen.kt
│ └── StudentSelectScreen.kt
└── models/
└── ReadingMission.kt
IntelReaderViewModel
AuthState
GR-{CATEGORY}-{SUBCATEGORY}-{NUMBER}
GR-TENSE-PRES-SIMPLE-001 — Present Simple basics
GR-ARTICLE-DEF-001 — Definite article 'the'
GR-PREP-TIME-001 — Prepositions of time
GR-MODAL-CAN-001 — Modal verb 'can'
| Category | Count | CEFR Levels |
|---|---|---|
| Tenses | 24 | A1-B2 |
| Articles | 12 | A1-B1 |
| Prepositions | 18 | A1-B2 |
| Pronouns | 10 | A1-A2 |
| Modals | 15 | A2-B2 |
| Comparatives | 8 | A2-B1 |
| Conditionals | 9 | B1-C1 |
| Passive | 8 | B1-B2 |
POST /api/auth/login-password
Request: { first_name, last_name, password }
Response: { user_id, username, display_name, role, rating, cefr_level, token }
POST /api/admin/create-teacher
Header: X-Admin-Id: admin-001-...
Request: { first_name, last_name, password }
POST /api/teacher/create-learner
Header: X-Teacher-Id: teacher-001-...
Request: { first_name, last_name, password, cefr_level? }
GET /api/teacher/{teacher_id}/students
Response: [{ id, username, display_name, role, cefr_level, is_online, ... }]
GET /api/student/{id}/vocabulary
Response: { student_id, total, mastered, unmastered, vocabulary: [...] }
POST /api/student/{id}/vocabulary/error
Request: { word, rule_id?, context? }
POST /api/student/{id}/vocabulary/correct
Request: { vocabulary_id } → Response: { correct_count, is_mastered }
GET /api/rules
Response: { total: 104, rules: [...] }
GET /api/rules/{id}
Response: { id, category, subcategory, name, description, cefr_level, examples }
GET /api/rules/level/{cefr}
Response: { cefr_level, count, rules: [...] }
Host
35.252.21.14
Domain
api.yakki.app
Path
/home/baruch/yakki-intel
Service
yakki-intel.service (systemd)
yakki_flutter/ ├── lib/ │ ├── api/ # Flutter API client │ ├── models/ # Shared models │ └── screens/ # iOS/Desktop UI └── CLAUDE.md # Flutter-specific docs