DUS sistemi backend geliştirme talimatları — FastAPI, SQLAlchemy, Auth, API endpoint'leri
DUS sisteminin Infrastructure + Presentation katmanlarını geliştirir.
Domain (entities, interfaces) ← DOKUNMA, sadece import et
Application (services, dtos) ← DOKUNMA, sadece import et
Infrastructure (db, repos, agents) ← SEN YAZIYORSUN
Presentation (api.py) ← SEN YAZIYORSUN
mapped_column, DeclarativeBase).env → SUPABASE_DB_URLget_db() → Dependency injection (yield session)create_tables() → Base.metadata.create_all(engine)SUPABASE_DB_URL yoksa sqlite:///./dus.db kullan__tablename__: snake_case, çoğul (users, questions, vb.)created_at alanları server_default=func.now()question_repo.py → IQuestionRepository implementasyonuuser_repo.py → IUserRepository implementasyonuquiz_repo.py → IQuizRepository implementasyonubookmark_repo.py → IBookmarkRepository implementasyonudef __init__(self, db: Session)seed_database(session) fonksiyonuopenai Python SDK kullanır.env → OPENAI_API_KEYgpt-4oasync def generate(prompt, system_instruction?) -> strAgenticOrchestrator class:
analyze_weakness(user_answers) -> dictgenerate_hint(question) -> strexplain_answer(question, selected) -> stranalyze_weakness.py → Yanlış cevapları analiz et, zayıf konuları bulgenerate_hint.py → Soru için ipucu üret (cevabı vermeden)explain_answer.py → Seçilen cevabın neden doğru/yanlış olduğunu açıkla/api/v1//api/v1/auth/)| Method | Path | Açıklama |
|---|---|---|
| POST | /register | Kullanıcı kaydı |
| POST | /login | JWT token döner |
| GET | /me | Mevcut kullanıcı bilgisi |
/api/v1/categories/)| Method | Path | Açıklama |
|---|---|---|
| GET | / | Tüm kategoriler (soru sayısı dahil) |
/api/v1/questions/)| Method | Path | Açıklama |
|---|---|---|
| GET | /random | Rastgele soru(lar) |
/api/v1/quiz/)| Method | Path | Açıklama |
|---|---|---|
| POST | /start | Sınav başlat |
| POST | /answer | Soruya cevap ver |
| POST | /finish | Sınavı bitir |
| GET | /history | Geçmiş |
/api/v1/ai/)| Method | Path | Açıklama |
|---|---|---|
| POST | /hint | Soru ipucu |
| POST | /explain | Cevap açıklaması |
| GET | /weakness | Zayıf konu analizi |
/api/v1/bookmarks/)| Method | Path | Açıklama |
|---|---|---|
| GET | / | Listele |
| POST | / | Ekle |
| DELETE | /{id} | Sil |
/api/v1/stats/)| Method | Path | Açıklama |
|---|---|---|
| GET | /overview | Genel başarı |
| GET | /by-category | Kategoriye göre |
passlib[bcrypt]python-jose JWT, 24h TTLSECRET_KEY → .envdef get_quiz_service(db: Session = Depends(get_db)) -> QuizService:
return QuizService(
question_repo=QuestionRepository(db),
quiz_repo=QuizRepository(db),
)
fastapi
uvicorn[standard]
sqlalchemy
psycopg2-binary
pydantic
python-jose[cryptography]
passlib[bcrypt]
python-multipart
python-dotenv
aiofiles
openai