مفتوح المصدر · مفتوح المصدر · 2025
نظام محادثة ذكي (ITSE500)
منصة محادثة متكاملة بخلفية Django REST وواجهة React وتطبيق Flutter مع جلسات الضيوف
Django · Flutter · React · JWT
GitHub | Release v1.0.0 | Live

نظرة عامة والمشكلة الهندسية
يتطلب بناء منصة محادثة ذكاء اصطناعي متعددة المنصات توحيد إدارة المحادثات، وتوفير آليات مصادقة مرنة تجمع بين الحسابات المسجلة وتجربة الضيوف الفورية، مع الحفاظ على عقود اتصال متسقة بين متصفح الويب وتطبيقات الهاتف.
يمثل نظام المحادثة الذكي (ITSE500) منصة مفتوحة المصدر متكاملة الطبقات، تجمع بين خلفية Django REST مع مصادقة JWT/OAuth، وواجهة ويب تفاعلية بـ React، وتطبيق Android عبر Flutter، مع دعم متكامل لجلسات الضيوف.
المعمارية والقرارات التقنية
تعتمد المنصة على معمارية موجهة بواجهات API تفصل الخادم الموحد عن تعدد العملاء:
- نواة الخادم (Django REST Framework): تدير طلبات نماذج المحادثة، وحفظ الجلسات، ومنطق المصادقة عبر واجهة برمجية مركزية موحدة.
- المصادقة المزدوجة وجلسات الضيوف (JWT وOAuth): الجمع بين رموز JWT وتسجيل الدخول عبر OAuth للمستخدمين المسجلين، مع دعم جلسات الضيوف لتمكين التجربة المباشرة دون عوائق التسجيل المسبق.
- عميل الويب (React): واجهة متصفح حديثة منشورة فعلياً على
https://react.itse500-ok.lyتتواصل مع نفس نقاط الاتصال المخصصة لتطبيق الهاتف. - عميل الموبايل (Flutter Android): تطبيق Android أصيل يستهلك واجهات JWT/OAuth وجلسات الضيوف نفسها لضمان تجربة متطابقة عبر المنصات.
دورة حياة البرمجيات وممارسات الجودة
طُبقت ممارسات هندسية واضحة لضمان تكامل الطبقات الثلاث:
- توحيد واجهة API: اعتماد بنية استجابات ومعالجة أخطاء موحدة منعت تشتت منطق الخادم بين عميل الويب وعميل الهاتف.
- فصل صلاحيات الجلسات: ضبط حدود واضحة بين جلسات الضيوف المؤقتة والحسابات المصادق عليها عبر JWT وOAuth.
- نشر وإتاحة علنية: توفير شيفرة الخلفية بشكل مفتوح المصدر مع نسخة ويب حية جاهزة للاختبار والمراجعة.
التقنيات والمخرجات
| الطبقة | التقنية / المخرج | الدور في المنظومة |
|---|---|---|
| الخلفية والمصادقة | Django REST وJWT وOAuth | إدارة المحادثات، المصادقة، وجلسات الضيوف |
| واجهة الويب | React | عميل ويب منشور ومتصل بالخادم (react.itse500-ok.ly) |
| تطبيق الموبايل | Flutter (Android) | تطبيق هاتف يتكامل مع نفس واجهات الخادم |
| الإتاحة والاختبار | GitHub (arousi/ITSE500-Django) ورابط حي |
مستودع مفتوح المصدر ونشر تشغيلي للواجهة |
أحدث إصدار: v1.0.0 — Prompeteer Django REST LLM Chat Backend (v1.0.0)
Overview
Prompeteer Server (arousi/ITSE500-Django) is a Django 5.1.7 / Django REST Framework backend for a privacy-focused, multi-provider LLM chat application developed for ITSE500. It powers multi-provider OAuth, JWT & guest/visitor authentication, unified profile and conversation sync, client-side encryption key provisioning, and asynchronous LLM execution, while serving as the canonical OpenAPI contract source (api/schema.yaml) for the Flutter and React clients.
Tag Note: Tag
v1.0.0marks the initial release milestone (bbcd3a3). Subsequent updates onmainexpandedchat_api, environment-gated production infrastructure, CI workflows, and the publishedapi/schema.yamlcontract documented below.
Verified Modules & API Surface
All API endpoints are namespaced under /api/v1/<app>/:
| Module | Base Path | Responsibilities & Key Endpoints |
|---|---|---|
auth_api |
/api/v1/auth_api/ |
Registration (/register/), login (/login/), logout with refresh-token blacklisting (/logout/), JWT refresh (/token/refresh/), email PIN verification (/verify-email-pin/), password setup (/set-password-after-email-verify/), health check (/health/), and OAuth flows (/google/, /openrouter/, /github/, /microsoft/ /authorize/, /callback/, /oauth/result/<state_value>/). |
user_mang |
/api/v1/user_mang/ |
UnifiedSyncView (/me/) supporting GET/POST/PATCH/DELETE for profile and conversation sync, guest (temp_id) resolution, CSV/PDF data export, and account soft-delete. |
chat_api |
/api/v1/chat_api/ |
User-scoped CRUD for conversations/ and conversations/{id}/, paginated conversations/{id}/messages/, and multipart conversations/{id}/messages/{mid}/attachments/ (25 MB cap, server-computed SHA-256 & byte size). Dispatches LLM completions via litellm/openai through a strict pending → streaming → complete / error state machine. |
crypto_api |
/api/v1/crypto_api/ |
UserUMKView (/umk/) for GET/POST retrieval and one-time provisioning of a base64-encoded 32-byte User Master Key (UMK). |
core & prompeteer_server |
/, /admin/, /api/ |
Host-aware SPA/landing routing (root_router), /team/, Jazzmin admin (/admin/), and drf-spectacular OpenAPI schema (/api/schema/), Swagger UI (/api/docs/), and ReDoc (/api/redoc/). |
Authentication, Security & Guest Architecture
- JWT Lifecycle: Short-lived 15-minute access tokens (
JWT_ACCESS_MINUTES) paired with 7-day refresh tokens (JWT_REFRESH_DAYS), withROTATE_REFRESH_TOKENS=TrueandBLACKLIST_AFTER_ROTATION=Truebacked byCustom_UserUUID primary keys. - Multi-Provider OAuth + PKCE: Unified authorize/callback/bridge endpoints for Google, OpenRouter, GitHub, and Microsoft with
OAuthStateTTL tracking and encrypted provider token persistence (ProviderOAuthToken). - Privacy-Preserving Guest Mode: Visitors receive a stable
temp_idUUID for multi-device conversation sync viaUnifiedSyncViewwithout requiring PII. - Hardening & Scoping: DRF rate throttling (
auth:10/min,anon:60/min), user-scoped queryset filtering (returning404for non-owned chat resources), and fail-fast startup checks whenDJANGO_DEBUG=FalsewithoutSECRET_KEYorBACKEND_PASSWORD_SALT.
Docker, Compose & Env-Gated Infrastructure
- Container Runtime: Python
3.13-slimimage (Dockerfile) running Gunicorn (prompeteer_server.wsgi:application, 3 workers on port8000) viaentrypoint.sh(migrate --noinputandcollectstatic --noinputwith WhiteNoise). - Production Stack (
docker-compose.prod.yml): Orchestratesweb(health-checked on/api/v1/auth_api/health/),celery-worker, andcelery-beat(plus an optionalchannelsASGI/Uvicorn service) behind a TLS reverse proxy (Caddy/nginx). - Env-Gated Services with Local Fallbacks:
- PostgreSQL (
DB_HOSTset) → falls back to SQLite. - Redis (
REDIS_URLset) → falls back to LocMemCache / InMemoryChannelLayer. - MinIO / S3 Media (
AWS_S3_ENDPOINT_URLset) → falls back to local FileSystemStorage. - Celery (
CELERY_BROKER_URL/REDIS_URLset) → falls back to synchronous inline execution (CELERY_TASK_ALWAYS_EAGER=True).
- PostgreSQL (
Known Issues
The following limitations from the initial v1.0.0 release are preserved for transparency and open contributions:
- OTP Email Dispatch: Email dispatch for OTPs requires thorough debugging.
- Password Reset: Password reset functionality is coupled to OTP delivery and is impacted by the OTP email dispatch issue.
- Account Verification: Account verification depends on receiving OTPs from the email dispatcher.
- Chat Data Storage: Chat data storage in the initial
v1.0.0snapshot exhibits edge-case bugs that require debugging. - Key Rotation (
crypto_api):POST /api/v1/crypto_api/umk/?rotate=truecurrently returns400(Rotation not implemented).