Tunisian Derja Chatbot
A full-stack AI chatbot that speaks Tunisian Arabic dialect (Derja). Built with React, Express, PostgreSQL, and TypeScript across the stack, with JWT authentication and real-time streaming responses.
Overview
This project is a ChatGPT-style chatbot that communicates exclusively in Tunisian dialect, regardless of what language the user writes in. It consists of two separate applications — a React frontend and an Express backend — that communicate over a REST API with Server-Sent Events (SSE) for streaming AI responses.
The AI behavior is driven by a dedicated system prompt that instructs the model to reply in authentic Tunisian Derja, including natural code-switching with French and Arabizi support.
Key features
Tunisian dialect chatbot — replies in Derja regardless of input language
Real-time token-by-token streaming via Server-Sent Events
JWT-based authentication with bcrypt password hashing
Persistent conversation history stored in PostgreSQL
Auto-generated conversation titles from the first message
Light/dark theme toggle with persisted preference
Type-safe database access via Drizzle ORM
Optimistic UI updates for instant message feedback
Full TypeScript coverage across frontend and backend
Unit-tested backend services (Jest)
---
## Overview
Technology stack
Frontend (chatbot-frontend/)
React + TypeScript + Vite
Zustand — global client state (auth, chat, UI)
TanStack React Query — server state, caching, mutations
React Router — client-side routing and protected routes
Tailwind CSS — styling
react-markdown + remark-gfm — rendering AI responses
Backend (chatbot-backend/)
Express + TypeScript
Drizzle ORM + PostgreSQL
JWT (jsonwebtoken) + bcryptjs — authentication
Server-Sent Events — streaming AI responses
Jest + Supertest — unit testing
AI provider: Gemini API (swappable — see AI Provider section)
## Key Features
- TypeScript throughout (frontend & backend)
- Vite-powered React frontend (fast HMR)
- Express API with secur …