Case Study her mesajdan sonra gramer / kelime / akıcılık (0–10) skorları üretir, EMA ile yumuşatır ve seviye tamponu (buffer) üzerinden zorluk dengesini ayarlar. Amaç: Gereksiz karar yükü olmadan sürdürülebilir mikro ilerleme.
- Dengeli seviye ilerleme (histerezis buffer)
- Anlık ama sakin metrikler (EMA)
- Bağlamsal kelime pekiştirme
- Günlük hedef ve streak motivasyonu
- Az fakat anlamlı gösterge seti
Adaptasyon: Seviye testi, dinamik seviye, hedef yapı rotasyonu Sohbet: Çoklu kanal, AI yanıt, kelime önerisi Metrikler: Grammar / Vocab / Fluency / Buffer göstergeleri Kelime: Seviye & kategori istatistikleri, otomatik ekleme Günlük: Hedefler, ilerleme, hata profili, streak Güvenlik: JWT, rate limit, CORS kontrolü
Mesaj -> Heuristik skor -> EMA güncelle -> Buffer ayarı -> Gerekirse seviye / hedef yapı güncelle -> Metrik pencere güncelle -> Yanıt.
Client: Next.js, React, TailwindCSS Server: Node.js (Express), MongoDB (Mongoose) State: JWT + Zustand Logic: EMA + buffer histerezisi
Backend:
cd server
npm install
cp .env.example .env
npm run devFrontend:
cd client
npm install
cp .env.example .env.local
npm run devİsteğe bağlı seed:
cd server && npm run seedPORT=5000
MONGO_URI=mongodb://localhost:27017/madlen
JWT_SECRET=değiştirin
CLIENT_URL=http://localhost:3000
GEMINI_API_KEY=...
Frontend:
NEXT_PUBLIC_API_URL=http://localhost:5000
| Endpoint | Amaç |
|---|---|
| POST /api/auth/login | Kimlik doğrulama |
| GET /api/chat/channels | Kanallar |
| POST /api/chat | Mesaj + adaptif döngü |
| GET /api/users/me | Adaptif durum |
| GET /api/users/me/daily | Günlük hedefler |
| GET /api/words/stats/summary | Kelime istatistikleri |
User: level, dynamicLevel, levelBuffer, currentTargetStructure, metricsWindow[], daily { goals, progress, streak, errorProfile }. Word: word, meaning, translation, level, categories, flags (autoAdded, pendingReview). Chat: channel, messages[]{ role, content, scores }.
- Node 20+ kurulu olmalı (macOS/Linux: nvm önerilir, Windows: nvm-windows veya resmi installer).
- MongoDB 6+ (yerel servis) veya bir Atlas connection string kullanın.
- Terminal 1:
cd server
npm install
cp .env.example .env # Windows PowerShell: copy .env.example .env
npm run dev
- Terminal 2:
cd client
npm install
cp .env.example .env.local # yoksa oluştur
npm run dev
- Tarayıcı: http://localhost:3000 (API: http://localhost:5000)
Önkoşul: Docker Desktop (Windows/macOS) veya Docker Engine + docker compose plugin (Linux).
docker compose up -d --build
Ardından:
- Client: http://localhost:3000
- API Health: http://localhost:5000/health
Logları görmek:
docker compose logs -f server
docker compose logs -f client
Durdurmak / temizlemek:
docker compose down # konteynerleri kapatır
docker compose down -v # + persistent volume (mongo_data) siler
Apple Silicon (arm64) + x86 uyumlu push için örnek:
docker buildx create --name madlenbuilder --use
docker buildx build --platform linux/amd64,linux/arm64 -t yourrepo/madlen-server:latest ./server --push
docker buildx build --platform linux/amd64,linux/arm64 -t yourrepo/madlen-client:latest ./client --push
Compose dosyasında varsayılan env var. Kendi .env dosyanızı kök dizine ekleyip (docker compose otomatik okur) şu değerleri özelleştirebilirsiniz:
JWT_SECRET=...güçlü...
CLIENT_URL=http://localhost:3000
GEMINI_API_KEY=
Docker compose volume mount ile çalışıyor; Node modülleri container içinde tutuluyor. Değişiklik yaptığınızda server otomatik restart olur (nodemon). Production imaj için dev script yerine minimal start komutları tanımlanabilir.
- PowerShell'de
cpyerineCopy-Itemkullanabilirsiniz. - Eğer 5000 portu doluysa
.enviçinde PORT değiştirip client.env.localdosyasındaNEXT_PUBLIC_API_URLeşleştirin. - Git Bash kullanırken
export NEXT_PUBLIC_API_URL=...şeklinde geçici env set edebilirsiniz.
- Dosya izinleri: Mongo volume klasörü root altında kalırsa izin hatası alırsanız kullanıcı mapping için ek ayar gerekebilir.
lsof -i :5000ile port çakışması kontrol edin.
- Reverse proxy (Nginx / Caddy) ile client (Next build output) ve API ayrıştır.
- Production için client Dockerfile'da
next build+next startkullan (şu an dev mode). Basit değişiklik:RUN npm install && npm run buildCMD ["npm","run","start"]
- Server için sadece production bağımlılıkları ve process manager (örn.
node index.jsyeterli) kullan.
- Otomatik test (supertest + jest) smoke flow.
- Health endpoint’e build git commit hash ekleme.
- CI pipeline (GitHub Actions) ile lint + test + çok mimarili imaj build.