Development Guide
دليل التطوير للمساهمين في مشروع Book-to-Skills.
🛠️ الإعداد
# Clone
git clone https://github.com/Abdulrahman0Khaled/BOOK2SKILLS.git
cd BOOK2SKILLS
# Virtual Environment
python3 -m venv .venv
source .venv/bin/activate
# Install with dev dependencies
pip install -e ".[dev]"
# إعداد pre-commit (اختياري)
pip install pre-commit
pre-commit install
🧪 إجراءات التطوير
1. TDD First
كل feature جديد يبدأ باختبار فاشل:
# 1. اكتب الاختبار
# 2. تأكد من فشله
pytest tests/unit/test_new_feature.py -v
# 3. نفذ الكود
# 4. تأكد من نجاحه
pytest tests/unit/test_new_feature.py -v
# 5. راجع وتأكد من عدم كسر شيء
pytest -q
2. Quality Gates
# Ruff (lint + format)
ruff check src/ tests/
ruff format src/ tests/ --check
# MyPy type checking
mypy src/
# Full test suite
pytest --cov=book_to_skills -v
3. Git Workflow
- feature/: ميزات جديدة
- fix/: إصلاح أخطاء
- refactor/: تحسين كود
Commit messages:
feat(pipeline): add new XYZ stage
fix(extractor): handle empty PDF pages
refactor(cache): simplify disk backend
docs(api): add endpoint examples
test(domain): add KnowledgeUnit tests
4. Adding a New Pipeline Stage
- إنشاء ملف في
src/book_to_skills/pipeline/ - وراثة
BaseStage - تطبيق
async def process(self, context) -> PipelineContext - إضافة اختبارات
- إضافة stage إلى
stages_enabledفي config - إضافة إلى
PipelineOrchestrator
from .base import BaseStage
from ..domain.models import PipelineContext
class MyNewStage(BaseStage):
async def process(self, context: PipelineContext) -> PipelineContext:
# Your logic here
return context
5. Adding a New LLM Provider
- إنشاء ملف في
src/book_to_skills/llm/ - وراثة
BaseLLMProvider - تطبيق
generate()وgenerate_structured() - إضافة إلى
provider_factory.py - إضافة إلى
LLMProviderenum
6. Testing
# Unit tests (سريعة، بدون dependencies خارجية)
pytest -m unit -v
# Integration tests (تحتاج مكتبات مثبتة)
pytest -m integration -v
# E2E tests (كاملة)
pytest -m e2e -v
# Slow tests
pytest -m slow -v
# All except slow
pytest -m "not slow" -v
📝 Coding Standards
Python
- Python 3.11+ type hints
- 100 char line length
- Ruff linting (config في pyproject.toml)
- Google-style docstrings
- SOLID principles
- Composition over inheritance
Naming
- Classes: PascalCase
- Functions/Methods: snake_case
- Constants: UPPER_CASE
- Private: _prefix
Imports Order
- Python standard library
- Third-party
- Local
🐳 Docker Development
# Build
docker build -f docker/Dockerfile -t book-to-skills .
# Run with compose
docker-compose -f docker/docker-compose.yml up -d
# Run tests in container
docker run --rm book-to-skills pytest -v
📊 Monitoring
# Check logs
tail -f logs/pipeline.log
# Check cache size
du -sh cache/
# Check output skills
ls -la outputs/skills/
# Check vector DB
ls -la data/vector_store/
🚀 Release Process
- تحديث الإصدار في
pyproject.toml - تشغيل كامل الاختبارات
- تحديث التوثيق
- إنشاء Git Tag
- Push إلى GitHub
- CI/CD ينشر تلقائياً