OSS · OPEN SOURCE · 2025

LLM Chat System (ITSE500)

Full-stack AI chat platform with Django REST (JWT/OAuth), React web, and Flutter mobile

Django · Flutter · React · JWT

GitHub | Release v1.0.0 | Live

Prompeteer ITSE500 v1.0.0 Django REST LLM chat backend, JWT/OAuth PKCE, and async inference showcase

Overview / Engineering Problem

Building a multi-platform AI chat application requires coordinating unified conversation state, flexible authentication (including frictionless onboarding via guest sessions alongside authenticated user accounts), and consistent API contracts across both web browsers and mobile devices.

LLM Chat System (ITSE500) is an open-source, full-stack AI chat platform uniting a Django REST backend with JWT/OAuth authentication, a live React web client, and a Flutter Android mobile client—complete with seamless guest session support.

Live & Open Source: Explore the deployed React web client at react.itse500-ok.ly and inspect the backend source at arousi/ITSE500-Django.

Architecture & Technical Decisions

The platform enforces a clean API-first separation between backend orchestration and multi-client interfaces:

  • Django REST Backend Core: Serves as the central API authority managing LLM chat interactions, conversation persistence, and unified authentication flows.
  • Dual Authentication + Guest Sessions (JWT & OAuth): Combines stateless JWT token validation and OAuth flows for registered accounts with structured guest session support so visitors can interact immediately without mandatory signup friction.
  • React Web Client: Provides a responsive browser interface deployed live at https://react.itse500-ok.ly, consuming the same REST contracts as mobile clients.
  • Flutter Android Client: Delivers a native mobile experience sharing the backend's JWT/OAuth and guest session endpoints, demonstrating cross-client contract consistency.
Multi-Client Contract Discipline: Both React and Flutter clients talk to one unified Django REST API surface, ensuring conversation history, auth tokens, and guest session semantics stay consistent everywhere.

SDLC & Quality Practices

Designing a cross-platform academic/open-source system with production deployment discipline:

  1. API Contract Consistency: Standardizing JSON payloads, error structures, and token handling across web and Android clients prevented client-specific backend forks.
  2. Clear Auth Boundaries: Isolating guest session privileges from authenticated JWT/OAuth capabilities kept onboarding smooth without weakening access boundaries.
  3. Public Verification: Released openly on GitHub alongside a live web deployment for transparent evaluation.

Stack & Deliverables

Layer Technology / Deliverable Role in System
Backend & Auth Django REST, JWT & OAuth Chat orchestration, auth flows, and guest session API
Web Frontend React Live browser chat client (react.itse500-ok.ly)
Mobile Client Flutter (Android) Native Android chat application consuming unified APIs
Open Source & Live GitHub (arousi/ITSE500-Django) & Live Demo Publicly verifiable full-stack codebase and web deployment

Latest Release: 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.0 marks the initial release milestone (bbcd3a3). Subsequent updates on main expanded chat_api, environment-gated production infrastructure, CI workflows, and the published api/schema.yaml contract 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), with ROTATE_REFRESH_TOKENS=True and BLACKLIST_AFTER_ROTATION=True backed by Custom_User UUID primary keys.
  • Multi-Provider OAuth + PKCE: Unified authorize/callback/bridge endpoints for Google, OpenRouter, GitHub, and Microsoft with OAuthState TTL tracking and encrypted provider token persistence (ProviderOAuthToken).
  • Privacy-Preserving Guest Mode: Visitors receive a stable temp_id UUID for multi-device conversation sync via UnifiedSyncView without requiring PII.
  • Hardening & Scoping: DRF rate throttling (auth: 10/min, anon: 60/min), user-scoped queryset filtering (returning 404 for non-owned chat resources), and fail-fast startup checks when DJANGO_DEBUG=False without SECRET_KEY or BACKEND_PASSWORD_SALT.

Docker, Compose & Env-Gated Infrastructure

  • Container Runtime: Python 3.13-slim image (Dockerfile) running Gunicorn (prompeteer_server.wsgi:application, 3 workers on port 8000) via entrypoint.sh (migrate --noinput and collectstatic --noinput with WhiteNoise).
  • Production Stack (docker-compose.prod.yml): Orchestrates web (health-checked on /api/v1/auth_api/health/), celery-worker, and celery-beat (plus an optional channels ASGI/Uvicorn service) behind a TLS reverse proxy (Caddy/nginx).
  • Env-Gated Services with Local Fallbacks:
    • PostgreSQL (DB_HOST set) → falls back to SQLite.
    • Redis (REDIS_URL set) → falls back to LocMemCache / InMemoryChannelLayer.
    • MinIO / S3 Media (AWS_S3_ENDPOINT_URL set) → falls back to local FileSystemStorage.
    • Celery (CELERY_BROKER_URL / REDIS_URL set) → falls back to synchronous inline execution (CELERY_TASK_ALWAYS_EAGER=True).

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.0 snapshot exhibits edge-case bugs that require debugging.
  • Key Rotation (crypto_api): POST /api/v1/crypto_api/umk/?rotate=true currently returns 400 (Rotation not implemented).