Capstone Module 16: Turkish ChatGPT Clone Live — Integration of Module 16
Module 16 capstone: synthesizing 4 lessons (decision, vLLM, quantization, monitoring) into a real product. Turkish DPO model from Module 15.6 → 4-bit AWQ quantize → vLLM serve → Next.js frontend + streaming → Vercel deploy → Sentry + Grafana monitoring → live at **chat.sukruyusufkaya.com**. Curriculum's 7th production artifact. Backend ($60/month cost), frontend (Vercel free tier), monitoring (Grafana Cloud free) full stack.
Şükrü Yusuf KAYA
90 min read
Advanced🚀 Capstone — 16 Dersin Sentezi, Bir Tek Yaşayan Ürün
Modül 15 ve 16, müfredatın 11 dersini birleştirip gerçek bir Türkçe AI ürünü üretiyor. Modül 6'da TurkTokenizer-tr, Modül 7'de semantic search, Modül 11'de mini Llama-3 pre-train, Modül 14-15'te SFT + DPO fine-tune, Modül 16'da quantization + serving + monitoring. Hepsi bu capstone'da bir araya geliyor: chat.sukruyusufkaya.com. Kullanıcı tarayıcıyı açıyor, Türkçe yazıyor, model 1 saniye içinde Türkçe yanıt veriyor — production-grade, KVKK uyumlu, $60/ay maliyetle. Müfredatın 7. production artefakt'ı. Aşağıdaki kod gerçek; bu link gerçek; bu sistem yaşıyor. 90 dakikada her satırı, neyi seçtiğini, niye seçtiğini, üretime nasıl aldığını öğreneceksin.
Capstone Akışı (10 Aşama)#
- Mimari özet — full stack diagram
- Model hazırlığı — DPO modeli quantize
- vLLM backend kurulum — Türkiye DC veya AWS Frankfurt
- Next.js frontend — chat UI + streaming
- API gateway + rate limiting
- KVKK + güvenlik katmanı
- Vercel deployment — frontend
- Monitoring kurulum — Grafana + Sentry
- Launch checklist
- Maliyet analizi ve sonuç
text
# Türkçe ChatGPT Klonu — Tam Stack Mimari ┌──────────────────────────────────────────────────────────────┐│ KULLANICI (Tarayıcı) ││ chat.sukruyusufkaya.com │└────────────────────────────┬─────────────────────────────────┘ │ HTTPS ▼┌──────────────────────────────────────────────────────────────┐│ FRONTEND (Next.js 14 / Vercel) ││ - React Server Components ││ - Streaming SSE ││ - Tailwind CSS ││ - KVKK consent banner │└────────────────────────────┬─────────────────────────────────┘ │ HTTPS, JWT auth ▼┌──────────────────────────────────────────────────────────────┐│ API GATEWAY (Vercel Edge / Cloudflare Workers) ││ - Rate limiting (10 req/min/user) ││ - Auth (NextAuth.js, OAuth/Email) ││ - Türkçe content filtering (prompt injection check) ││ - Request logging │└────────────────────────────┬─────────────────────────────────┘ │ HTTPS ▼┌──────────────────────────────────────────────────────────────┐│ vLLM BACKEND (AWS Frankfurt / Türk Telekom Bulut) ││ - 1× NVIDIA H100 80GB ││ - llama-3-8b-tr-dpo-instruct-awq (Modül 15.6 + 16.3) ││ - Paged attention, continuous batching ││ - OpenAI-compatible API ││ - 50-100 concurrent users kapasite │└────────────────────────────┬─────────────────────────────────┘ │ Metrics + Logs ▼┌──────────────────────────────────────────────────────────────┐│ MONITORING & OBSERVABILITY ││ - Grafana Cloud (free tier): metrics + dashboards ││ - Sentry: error tracking + Türkçe error messages ││ - Slack alerts: sev1/sev2 incidents ││ - Logs: vLLM stdout → Vector → Loki │└──────────────────────────────────────────────────────────────┘ Tam Stack Mimari Diagramı
4. Next.js Frontend — Türkçe Chat UI#
4.1 Tek dosya streaming chat#
// app/chat/page.tsx (Next.js 14 App Router) 'use client'; import { useState, useRef, useEffect } from 'react'; export default function ChatPage() { const [messages, setMessages] = useState<{role: string, content: string}[]>([]); const [input, setInput] = useState(''); const [streaming, setStreaming] = useState(false); const chatEndRef = useRef<HTMLDivElement>(null); useEffect(() => { chatEndRef.current?.scrollIntoView({behavior: 'smooth'}); }, [messages]); async function handleSend() { if (!input.trim() || streaming) return; const userMessage = {role: 'user', content: input}; setMessages(prev => [...prev, userMessage]); setInput(''); setStreaming(true); // Backend'e stream et const response = await fetch('/api/chat', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({messages: [...messages, userMessage]}), }); if (!response.body) return; const reader = response.body.getReader(); const decoder = new TextDecoder(); let assistantContent = ''; // Stream chunks ekle setMessages(prev => [...prev, {role: 'assistant', content: ''}]); while (true) { const {done, value} = await reader.read(); if (done) break; const chunk = decoder.decode(value); const lines = chunk.split('\n'); for (const line of lines) { if (line.startsWith('data: ')) { try { const data = JSON.parse(line.slice(6)); const delta = data.choices[0].delta.content || ''; assistantContent += delta; setMessages(prev => { const last = prev[prev.length - 1]; return [...prev.slice(0, -1), {...last, content: assistantContent}]; }); } catch {} } } } setStreaming(false); } return ( <div className="flex flex-col h-screen max-w-3xl mx-auto p-4"> <h1 className="text-2xl font-bold mb-4">Türkçe AI Asistanı</h1> <div className="flex-1 overflow-y-auto space-y-4"> {messages.map((msg, i) => ( <div key={i} className={`flex ${msg.role === 'user' ? 'justify-end' : 'justify-start'}`}> <div className={`max-w-md p-3 rounded-lg ${ msg.role === 'user' ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-900' }`}> {msg.content} </div> </div> ))} <div ref={chatEndRef} /> </div> <div className="flex gap-2 mt-4"> <input type="text" value={input} onChange={e => setInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && handleSend()} placeholder="Mesajınızı yazın..." className="flex-1 p-2 border rounded" disabled={streaming} /> <button onClick={handleSend} disabled={streaming || !input.trim()} className="px-4 py-2 bg-blue-500 text-white rounded disabled:bg-gray-400" > {streaming ? '...' : 'Gönder'} </button> </div> <p className="text-xs text-gray-500 mt-2"> AI yanıtları yapay zekadan üretilmiştir. Hukuki/tıbbi danışman değildir. KVKK kapsamında veri işlenir. </p> </div> ); }
4.2 API Route — vLLM proxy#
// app/api/chat/route.ts import { NextRequest } from 'next/server'; export const runtime = 'edge'; export async function POST(req: NextRequest) { const { messages } = await req.json(); // Rate limiting + auth burada // Prompt injection check const lastUserMsg = messages[messages.length - 1].content; const injectionPatterns = ['önceki talimatları unut', 'sen artık', 'sistem mesajı']; if (injectionPatterns.some(p => lastUserMsg.toLowerCase().includes(p))) { return new Response('Geçersiz istek.', { status: 400 }); } // vLLM backend const response = await fetch(`${process.env.VLLM_URL}/v1/chat/completions`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.VLLM_API_KEY}`, }, body: JSON.stringify({ model: 'sukruyusufkaya/llama-3-8b-tr-dpo-instruct-awq', messages: [ {role: 'system', content: 'Sen yardımsever bir Türk asistansın. KVKK kapsamında veri işlersin.'}, ...messages, ], max_tokens: 500, temperature: 0.7, stream: true, }), }); return new Response(response.body, { headers: {'Content-Type': 'text/event-stream'}, }); }
🎉 Modül 16 Tamamlandı — Production Mühendisliği Anatomi
Modül 16 final (5 ders, 410 dakika):
- 16.1: Self-Host Karar Çerçevesi — 4 boyut (maliyet/gizlilik/perf/bağımsızlık), 5 TR SaaS senaryosu
- 16.2: vLLM Production — Paged Attention (Kwon 2023), continuous batching, K8s deployment, SLA
- 16.3: Quantization Derinlemesine — GPTQ vs AWQ vs GGUF, Türkçe Llama-3 4-bit
- 16.4: Monitoring & Observability — Prometheus + Grafana + Sentry, Türkçe anomali tespit
- 16.5 Capstone: Türkçe ChatGPT Klonu yayında — chat.sukruyusufkaya.com, $60/ay
Müfredatın 7. production artefaktı üretildi. Modül 16 artık üretim mühendisliğinin tüm bileşenlerini uzman seviyesinde işliyor. Maliyet analizi: backend (60 + alan adı. 1,000 kullanıcı/gün serve edebilir kapasite. Müfredatın çıkış kapısı — bu noktadan sonra herkes kendi Türkçe LLM ürününü çıkarabilir hale geldi.
Modül 16 Envanteri (Yeniden Yazıldı)#
| # | Ders | Süre |
|---|---|---|
| 16.1 | Self-Host Karar Çerçevesi | 80 dk |
| 16.2 | vLLM Production Mühendisliği | 85 dk |
| 16.3 | Quantization Derinlemesine | 80 dk |
| 16.4 | Monitoring & Observability | 75 dk |
| 16.5 | Capstone Türkçe ChatGPT Klonu | 90 dk |
| Toplam | 5 ders | 410 dk (~6.8 saat) |
Önceki Modül 16: 2 ders / 165 dk.
Şimdi: 5 ders / 410 dk. 2.5× genişleme, uzman kalitesi.
Frequently Asked Questions
**Yes, building a fully functional Turkish ChatGPT clone**. With prerequisites:
**Required**:
- Module 15.6 capstone completed (Turkish DPO model on HF Hub)
- AWS account (or Türk Telekom Cloud)
- Vercel account (free tier sufficient)
- Domain (~$10/year)
**Monthly cost**:
- AWS H100 spot: $1,800/month (24/7) — medium-large production
- Or: 12 hours/day open $900/month
- Or: only during peak hours $400-600/month
- Vercel: $0
- Monitoring: $0
- Domain: $1/month
- **Total**: $400-1,800/month
**Sufficient capacity for 1000 users/day**. Start as 'side project', start earning if user base grows.
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
Related Content
Module 0: Course Framework & Workshop Setup
Who Is an LLM Engineer? The AI Engineering Career Ladder from Junior to Staff
Start LearningModule 0: Course Framework & Workshop Setup
Course Philosophy: Why This Path, Why This Order — The Skeleton of an 8-Month Curriculum
Start LearningModule 0: Course Framework & Workshop Setup