# Tunisian CIN Fraud Detection
A modular pipeline that decides whether a photograph of the **front side** of a
Tunisian national ID card (CIN — *Carte d'Identité Nationale*) is genuine, a
**presentation attack** (printed copy, screen replay, re-laminated card), or a
**digital injection** (face swap, text tampering, splicing).
Ships as a FastAPI service with a React capture UI and an admin dashboard.
> **Status: validated prototype, not production.** It works end to end and its
> core module is measured against ISO/IEC 30107-3, but it is trained on a very
> small dataset and several thresholds are uncalibrated. Read
> Honest status before building on it.
---
## Table of contents
- Quickstart
- Architecture
- How a card is scored
- API
- Project layout
- Results
- Honest status
- Where to pick up
- Data and privacy
- References
---
## Quickstart
**Requirements:** Python 3.10 (developed on 3.10.6), Node 18+, ~4 GB disk for
model weights and dependencies. CPU-only is fine; everything runs without a GPU.
```bash
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
```
```bash
cd frontend && npm install && npm run build && cd ..
```
```bash
python -m uvicorn api.main:app --host 0.0.0.0 --port 8000
```
Then open:
| URL | What it is |
|---|---|
| `
localhost` | Capture UI — guided camera, auto-capture, verdict |
| `
localhost` | Admin dashboard — past runs, scores, evidence images |
| `
localhost` | Interactive OpenAPI docs |
**First run is slow** — EasyOCR downloads its Arabic model and `transformers`
downloads `facebook/dinov2-large` (~1.2 GB). Both are cached afterwards.
> ⚠️ **Use the project venv.** The shipped `.pkl` models are pickled with
> **scikit-learn 1.7.2**. Under 1.9.x they still load but emit *"may lead to
> invalid results"*. `requirements.txt` pins this — don't loosen it without
> retraining. Verify with:
```bash
python -c "import sys, sklearn; print(sys.executable, sklearn. …