Cariex is a full‑stack web platform for automated dental caries (cavity) detection and clinical decision support. It combines a Django REST API, a TensorFlow segmentation/classification model, and a modern Next.js (React + TypeScript) frontend.
Cariex-BE/ # Django REST API, AI model and data layer
Cariex-FE/ # Next.js frontend (App Router) for clinicians
Main apps (Django project backend):
authentication– custom user model, JWT auth (login, registration, password reset).accounts– account/profile management.dashboard– patients, statistics and high‑level overview.AIModel– model loading, image preprocessing, diagnosis, and explainability (XAI) endpoints.dentist_feedback– capture clinician feedback on model outputs.
Key endpoints are exposed under /api/* (see backend/urls.py):
/api/auth/…– authentication and user management./api/dashboard/…– dashboard and patient‑related data./api/accounts/…– account/profile endpoints./api/ai/…– AI pipeline:upload/– upload dental image for analysis.preprocess/<id>/,detect/<id>/,classify/<id>/– internal pipeline stages.diagnosis/all/,diagnosis/<id>/,diagnosis/<id>/delete/– diagnosis management.
/api/feedback/…– dentist feedback endpoints.
The AI model is loaded from AIModel/ml_models/adult_teeth.h5 using TensorFlow, with utilities for
preprocessing, severity classification and bounding‑box generation.
Next.js 16 (App Router) + React 19 + TypeScript with:
- UI: Tailwind CSS v4, Radix UI, Lucide icons, Recharts, Framer Motion.
- Data: Supabase client, REST calls to the Django API.
- State & utilities: custom hooks and service modules in
services/andhooks/.
Important areas:
app/– routing and pages (authentication, dashboard, upload, analysis, patients, profile).services/– typed API clients (auth, dashboard, patients, scans, XAI, etc.).lib/supabase.ts– Supabase browser client.types/– shared TypeScript types.
The frontend talks to the backend via NEXT_PUBLIC_API_URL and to Supabase via
NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY.
Backend
- Python 3.x
- Django 5
- Django REST Framework
djangorestframework-simplejwtfor JWT auth- PostgreSQL (primary database)
- TensorFlow 2, OpenCV, NumPy for image analysis
python-decouplefor environment configuration- Supabase Python client for storage/integration
Frontend
- Next.js 16 (App Router)
- React 19, TypeScript 5
- Tailwind CSS 4, Radix UI, Lucide, Recharts, Framer Motion
@supabase/supabase-jsfor Supabase access
- Node.js >= 18 (recommended: latest LTS)
- npm (or yarn/pnpm, examples use npm)
- Python >= 3.10
- PostgreSQL (local instance or managed service)
- Supabase project (optional but required for Supabase‑backed features)
All commands below are written for Windows PowerShell, but work similarly on other platforms.
-
Create and activate a virtual environment
cd Cariex-BE python -m venv .venv .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
The Django settings use
python-decoupleto read configuration such as the secret key, database, email and Supabase credentials.Create a
.envfile inCariex-BE/(or configure equivalent environment variables) with e.g.:# Django SECRET_KEY=your-django-secret-key # Database (PostgreSQL) DB_NAME=cariex DB_USER=cariex_user DB_PASSWORD=your-db-password DB_HOST=localhost DB_PORT=5432 # Email (for password reset and notifications) EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USE_TLS=True EMAIL_HOST_USER=your-email@example.com EMAIL_HOST_PASSWORD=your-email-app-password DEFAULT_FROM_EMAIL="Cariex <no-reply@your-domain.com>" # Supabase (backend access key) SUPABASE_URL=https://your-project-id.supabase.co SUPABASE_KEY=your-service-role-or-secret-key
-
Apply migrations and create a superuser
python manage.py migrate python manage.py createsuperuser
-
Run the development server
python manage.py runserver 0.0.0.0:8000
The API will be available at
http://localhost:8000/api/….
Note: Media uploads (dental images, etc.) are stored under
Cariex-BE/media/and served viaMEDIA_URLwhenDEBUG=True.
-
Install dependencies
cd Cariex-FE npm install -
Configure environment variables
Create a
.env.localfile inCariex-FE/:# Base URL for the Django API (note the /api suffix) NEXT_PUBLIC_API_URL=http://localhost:8000/api # Supabase (browser client) NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-public-anon-key
-
Run the frontend
npm run dev
The app will be available at
http://localhost:3000.
- Uses a custom
Usermodel (AUTH_USER_MODEL = "authentication.User"). - JWT authentication via
rest_framework_simplejwt:- Access and refresh tokens are issued by the
/api/auth/login/endpoint. - Frontend stores tokens in
localStorageand sends them viaAuthorization: Bearer <token>.
- Access and refresh tokens are issued by the
- Default REST Framework permission is
IsAuthenticated, so most API endpoints require a valid JWT.
Make sure you:
- Use a strong, unique
SECRET_KEYin production. - Set
DEBUG=Falseand configureALLOWED_HOSTSappropriately. - Use secure database and Supabase credentials (never commit
.envfiles).
- Image upload – the frontend sends an image (and patient id) to
/api/ai/upload/. - Preprocessing – images are normalized and resized to the model input size.
- Inference – TensorFlow model in
AIModel/ml_models/adult_teeth.h5predicts caries presence and severity. - Postprocessing – severity classification, affected area estimation and bounding‑box generation.
- Explainability – additional XAI utilities generate visual overlays to help clinicians interpret results.
- Storage – images and related artifacts can be stored locally (media folder) and/or in Supabase.
Diagnoses can then be listed, inspected and deleted through the /api/ai/diagnosis/* endpoints and
consumed by the frontend (e.g. analysis and dashboard screens).
Backend
cd Cariex-BE
.venv\Scripts\activate # if not already active
python manage.py testFrontend
Currently there are no dedicated unit tests configured; you can run the linter with:
cd Cariex-FE
npm run lint-
Configure all environment variables for both backend and frontend in your deployment environment.
-
Set
DEBUG=Falseand updateALLOWED_HOSTSandCORS_ALLOWED_ORIGINSinbackend/settings.py. -
Use a production‑grade PostgreSQL instance and secure Supabase keys.
-
For the frontend, build and serve a static production bundle:
cd Cariex-FE npm run build npm start
If you’d like, I can also add shorter service‑specific READMEs inside Cariex-BE/ and Cariex-FE/ with only the commands and environment variables relevant to each side.