File size: 20,276 Bytes
d89b78a
 
 
 
 
 
 
 
 
 
 
470a637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3337c5d
470a637
 
 
 
 
 
 
 
 
 
 
 
 
3337c5d
6b659dc
470a637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b659dc
470a637
6b659dc
470a637
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
---
title: Authrix Deepfake Detector
emoji: πŸ”
colorFrom: green
colorTo: green
sdk: docker
pinned: false
app_port: 7860
license: mit
---

<div align="center">

# πŸ” AUTHRIX
### AI-Powered Deepfake Detection Engine

[![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.111-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com)
[![React](https://img.shields.io/badge/React-19-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev)
[![HuggingFace](https://img.shields.io/badge/πŸ€—_HuggingFace-ViT_Ensemble-FFD21E?style=for-the-badge)](https://huggingface.co)
[![Docker](https://img.shields.io/badge/Docker-Ready-2496ED?style=for-the-badge&logo=docker&logoColor=white)](https://docker.com)
[![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)

**Authrix** is a full-stack, multi-agent deepfake detection platform that analyzes videos for AI-generated content using a Vision Transformer (ViT) ensemble, temporal consistency analysis, C2PA metadata scanning, and AI audio detection β€” all wrapped in a sleek cyberpunk-themed dashboard and a Chrome extension.

[πŸš€ Live Demo](https://aarav13-authrix.hf.space) Β· [🧩 Chrome Extension](#browser-extension) Β· [πŸ“‘ API Reference](#api-reference) Β· [πŸ’¬ Pricing](#pricing--tiers)

</div>

---

## ✨ Key Features

| Feature | Description |
|---|---|
| 🧠 **ViT Ensemble** | 2-model Vision Transformer ensemble (dima806 + prithivMLmods) with float16 batched inference |
| 🎞️ **Temporal Analysis** | Detects AI video patterns: unnatural motion smoothness, temporal flickering, color drift |
| πŸ” **C2PA / Metadata Scan** | Identifies AI generator signatures from Veo3, Sora, Runway, Firefly, Kling, etc. |
| πŸ”Š **Audio Detection** | Spectral analysis for AI voice synthesis & audio-visual mismatch detection |
| 🌐 **Browser Extension** | Chrome/Edge extension (MV3) that captures tab video stream for real-time analysis |
| πŸ”— **URL Analysis** | Paste any YouTube/TikTok/Twitter/Instagram URL β€” powered by yt-dlp |
| πŸ”‘ **API Key System** | Tiered access control with per-month usage quotas and Stripe billing integration |
| 🐳 **Docker + Render** | One-command deployment to Render (or any Docker host / HuggingFace Spaces) |

---

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        CLIENT LAYER                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  React Frontend β”‚  β”‚ Chrome Extension β”‚  β”‚  REST API  β”‚  β”‚
β”‚  β”‚  (Vite + TW4)  β”‚  β”‚    (MV3, JS)     β”‚  β”‚  Consumers β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β”‚
└───────────┼─────────────────── ┼─────────────────── β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                    β”‚                     β”‚
            β–Ό                    β–Ό                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      FastAPI BACKEND                         β”‚
β”‚                                                              β”‚
β”‚  POST /analyze      POST /analyze-url      GET /health       β”‚
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                  DETECTION PIPELINE                    β”‚  β”‚
β”‚  β”‚                                                        β”‚  β”‚
β”‚  β”‚  Agent 0a: Metadata Agent  (C2PA / AI tool scan)       β”‚  β”‚
β”‚  β”‚  Agent 0b: Temporal Agent  (flicker / motion CV)       β”‚  β”‚
β”‚  β”‚  Agent 1:  Frame Extractor (dedup, 40-frame sample)    β”‚  β”‚
β”‚  β”‚  Agent 2:  Face Detector   (MediaPipe, single ctx)     β”‚  β”‚
β”‚  β”‚  Agent 3:  Decision Agent  (ViT ensemble, float16)     β”‚  β”‚
β”‚  β”‚  Agent 4:  Report Agent    (calibrated + audio fused)  β”‚  β”‚
β”‚  β”‚  Agent 5:  Audio Agent     (librosa spectral + AV sync)β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Detection Pipeline

1. **Metadata Agent** β€” Binary-scans the first 512 KB + last 64 KB of the video file for C2PA markers, XMP tags, and known AI-generator signatures (Veo, Sora, Runway, Kling, Firefly…). If a C2PA block is found, the file is immediately flagged with 98% confidence.

2. **Temporal Agent** β€” Measures pixel-level temporal variance, frame-difference coefficient of variation, high-frequency noise consistency, and color-channel drift across frames. Catches modern AI video generators that produce unnaturally smooth motion.

3. **Frame Extractor** β€” Intelligently samples up to 40 deduplicated frames, skipping near-identical consecutive frames to save inference time.

4. **Face Detector** β€” MediaPipe face detection runs in a **single context** across all frames (avoids repeated model init) and crops each face with 20% padding.

5. **Decision Agent (ViT Ensemble)** β€” All face crops are sent to **both ViT models in a single batched forward pass** (float16). Model 2 is early-exited if Model 1 is already very confident (>88% or <12%). Scores are ensemble-weighted 55/45.

6. **Audio Agent** β€” Extracts audio track via MoviePy/ffmpeg, runs librosa spectral analysis to detect AI voice synthesis, unnatural pitch/tempo regularity, and audio-visual sync mismatches.

7. **Report Agent** β€” Fuses all signals with an adaptive threshold. A C2PA hard match always wins; audio-visual mismatch overrides visual; otherwise, temporal + visual ensemble determines the final verdict with calibrated confidence.

---

## πŸ—‚οΈ Project Structure

```
authrix/
β”œβ”€β”€ backend/                    # FastAPI backend
β”‚   β”œβ”€β”€ main.py                 # App entry point, routes, middleware
β”‚   β”œβ”€β”€ detector.py             # Core multi-agent detection engine (all 5 agents)
β”‚   β”œβ”€β”€ audio_detector.py       # Audio analysis agent (librosa + AV sync)
β”‚   β”œβ”€β”€ auth.py                 # API key validation, tier limits
β”‚   β”œβ”€β”€ stripe_integration.py   # Stripe billing hooks
β”‚   β”œβ”€β”€ create_owner_key.py     # CLI helper to mint API keys
β”‚   β”œβ”€β”€ test_temporal.py        # Unit tests for temporal analysis
β”‚   β”œβ”€β”€ requirements.txt        # Python dependencies
β”‚   └── uploads/                # Temp upload directory (auto-cleaned)
β”‚
β”œβ”€β”€ frontend/                   # React 19 + Vite 8 + Tailwind 4 dashboard
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # UI components (Loader, ResultCard, etc.)
β”‚   β”‚   └── main.jsx            # App entry
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ frontend-vanilla/           # Vanilla HTML/JS fallback frontend
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ pricing.html
β”‚   └── script.js               # ~15KB β€” full upload + results UI
β”‚
β”œβ”€β”€ extension/                  # Chrome Extension (Manifest V3)
β”‚   β”œβ”€β”€ manifest.json           # Permissions, MV3 config
β”‚   β”œβ”€β”€ background.js           # Service worker (tab capture)
β”‚   β”œβ”€β”€ content.js              # Content script (overlay injection)
β”‚   β”œβ”€β”€ offscreen.js            # Offscreen document for MediaRecorder
β”‚   β”œβ”€β”€ popup.html / popup.js   # Extension popup UI
β”‚   β”œβ”€β”€ overlay.css             # Injected overlay styles
β”‚   └── icons/                  # Extension icons (16/48/128px)
β”‚
β”œβ”€β”€ Dockerfile                  # Multi-stage Docker build
β”œβ”€β”€ render.yaml                 # Render.com deployment config
β”œβ”€β”€ setup.sh / setup.bat        # One-command environment setup
β”œβ”€β”€ start.sh / start.bat        # Dev server launcher
└── BUSINESS_MODEL.md           # Monetization guide & pricing
```

---

## πŸš€ Getting Started

### Prerequisites

| Tool | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Backend runtime |
| Node.js | 18+ | Frontend build |
| npm / pnpm | Latest | JS package manager |
| ffmpeg | Any | Video conversion (auto-bundled via imageio-ffmpeg) |
| Docker | 24+ | Containerized deployment (optional) |

> **Windows users:** ffmpeg is bundled via `imageio-ffmpeg` β€” no manual install required.

---

### Option A β€” Quick Start (Local Dev)

#### 1. Clone the Repository

```bash
git clone https://github.com/Aarav-bit/Authrix.git
cd Authrix
```

#### 2. Backend Setup

```bash
cd backend
python -m venv ../venv

# Activate (Linux/macOS)
source ../venv/bin/activate

# Activate (Windows)
..\venv\Scripts\activate

pip install -r requirements.txt
```

> **Note:** First startup downloads ~2 GB of ViT model weights from HuggingFace. Subsequent starts use the local cache.

#### 3. Start the Backend

```bash
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
```

The API will be live at **http://localhost:8000** and the vanilla frontend will be served automatically.

#### 4. (Optional) Start the React Frontend

```bash
cd ../frontend
npm install
npm run dev
```

React dashboard available at **http://localhost:5173**.

---

### Option B β€” One-Command Setup Scripts

```bash
# Linux / macOS
./setup.sh
./start.sh

# Windows
setup.bat
start.bat
```

---

### Option C β€” Docker

```bash
# Build image
docker build -t authrix .

# Run
docker run -p 7860:7860 authrix
```

Open **http://localhost:7860**.

---

## 🌐 Deployment

### Render (Recommended)

1. Fork this repository.
2. Create a new **Web Service** on [Render](https://render.com).
3. Connect your GitHub repo β€” Render auto-detects `render.yaml`.
4. Set env vars (see below).
5. Deploy. βœ…

`render.yaml` configures:
- Runtime: Docker
- Health check: `GET /health`
- Port: `8000`

### HuggingFace Spaces

The `Dockerfile` is pre-configured for HuggingFace Spaces (port 7860, user 1000) and pre-caches both ViT models at build time.

1. Create a new Space β†’ **Docker** runtime.
2. Push this repo as the Space source.
3. Models are cached in the image β€” cold start is instant.

### Manual VPS

```bash
# Pull latest
git pull origin main

# Build frontend
cd frontend && npm run build
cp -r dist ../frontend-dist

# Install Python deps
cd ../backend
pip install -r requirements.txt

# Start with Gunicorn (production)
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 2
```

---

## βš™οΈ Environment Variables

| Variable | Required | Description | Example |
|---|---|---|---|
| `PORT` | No | Port to bind | `8000` |
| `PYTHONUNBUFFERED` | No | Force stdout flush | `1` |
| `STRIPE_SECRET_KEY` | Optional | Stripe billing | `sk_live_...` |
| `STRIPE_WEBHOOK_SECRET` | Optional | Stripe webhooks | `whsec_...` |

> API keys for end-users are stored in `backend/api_keys.json` (auto-generated). No external database required.

---

## πŸ”‘ API Reference

### Base URL
```
https://aarav13-authrix.hf.space   (production)
http://localhost:8000               (local)
```

### Authentication

Pass your API key as a header. For local development, the key is optional.

```
X-API-Key: authrix_YOUR_KEY_HERE
```

---

### `GET /health`

Check server readiness.

```bash
curl https://aarav13-authrix.hf.space/health
```

**Response:**
```json
{
  "status": "ok",
  "model": "Ensemble (2 ViT models)",
  "ready": true
}
```

---

### `POST /analyze`

Analyze an uploaded video file for deepfake content.

```bash
curl -X POST http://localhost:8000/analyze \
  -H "X-API-Key: authrix_YOUR_KEY" \
  -F "file=@/path/to/video.mp4"
```

**Supported formats:** `.mp4`, `.avi`, `.mov`, `.mkv`, `.webm`, `.wmv`  
**Max file size:** 100 MB

**Response:**
```json
{
  "result": "FAKE",
  "confidence": 87.3,
  "details": {
    "visual_score": 0.82,
    "audio_result": "AI_VOICE",
    "temporal_signals": ["Perfectly uniform motion (CV=0.01)"],
    "metadata_signals": ["c2pa", "tool:runway"],
    "face_coverage": 0.92,
    "frames_analyzed": 38
  },
  "frame_timeline": [
    { "frame_index": 0, "fake_probability": 0.84 },
    { "frame_index": 5, "fake_probability": 0.79 }
  ],
  "metadata": {
    "frames_analyzed": 38,
    "frames_with_faces": 35,
    "video_duration_sec": 12.4,
    "video_fps": 30.0,
    "resolution": "1280x720"
  }
}
```

---

### `POST /analyze-url`

Analyze a video from a URL (YouTube, TikTok, Twitter, Instagram, etc.).

```bash
curl -X POST http://localhost:8000/analyze-url \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.youtube.com/watch?v=..."}'
```

**Response:** Same structure as `/analyze`.

---

### Error Codes

| Status | Meaning |
|---|---|
| `400` | Bad request (unsupported format, invalid URL) |
| `401` | Invalid or missing API key |
| `413` | File too large (>100 MB) |
| `429` | Monthly usage limit exceeded |
| `503` | Server still initializing β€” retry in 30s |

---

## πŸ’° Pricing & Tiers

| Tier | Price | Analyses / Month | Features |
|---|---|---|---|
| **Free** | $0 | 10 | Extension, 2-min videos, community support |
| **Pro** | $9.99/mo | 100 | 10-min videos, API access (100 calls), email support |
| **Business** | $49/mo | 1,000 | Unlimited length, API (5K calls), white-label reports |
| **Enterprise** | Custom | Unlimited | On-premise, custom training, SLA, dedicated support |

### Pay-Per-Use API

| Video Length | Price |
|---|---|
| < 5 min | $0.05 |
| 5–15 min | $0.10 |
| > 15 min | $0.25 |

### Generate an API Key (Self-Hosted)

```bash
cd backend
python create_owner_key.py
# Or:
python -c "from auth import create_api_key; print(create_api_key('you@email.com', 'pro'))"
```

---

## 🧩 Browser Extension

The Authrix Chrome Extension (v2.2.0, Manifest V3) allows one-click deepfake analysis of any video playing in your browser tab.

### How It Works

1. User clicks the Authrix toolbar icon while a video is playing.
2. The background service worker uses the `tabCapture` API to start recording the tab's media stream.
3. An offscreen document captures ~8 seconds of video via `MediaRecorder`.
4. The clip is posted to the Authrix API and the result is overlaid on the page.

### Install (Developer Mode)

1. Open `chrome://extensions`
2. Enable **Developer Mode** (top-right toggle)
3. Click **Load unpacked** β†’ select the `extension/` folder
4. The Authrix icon appears in your toolbar

### Permissions

| Permission | Reason |
|---|---|
| `tabCapture` | Record tab video stream |
| `scripting` | Inject result overlay |
| `storage` | Cache API key & usage |
| `offscreen` | Run MediaRecorder out-of-context |
| `contextMenus` | Right-click menu |

---

## πŸ› οΈ Development

### Backend

```bash
# Run with hot-reload
uvicorn main:app --reload --port 8000

# Run tests
cd backend
python test_temporal.py

# Lint
flake8 . --max-line-length=120
```

### Frontend (React)

```bash
cd frontend
npm run dev      # Dev server with HMR
npm run build    # Production build β†’ dist/
npm run lint     # ESLint
npm run preview  # Preview production build
```

### Available Scripts Summary

| Command | Description |
|---|---|
| `uvicorn main:app --reload` | Backend dev server |
| `npm run dev` | React frontend dev server |
| `npm run build` | Build React app for production |
| `python create_owner_key.py` | Generate a new API key |
| `docker build -t authrix .` | Build Docker image |

---

## πŸ”¬ Tech Stack

### Backend
- **FastAPI 0.111** β€” Async REST API with automatic OpenAPI docs
- **Python 3.11** β€” Core runtime
- **OpenCV 4.9** β€” Video decoding and frame extraction
- **MediaPipe 0.10** β€” Face detection (single-context optimized)
- **HuggingFace Transformers** β€” ViT model loading and inference
- **PyTorch 2.3+** β€” Float16 batched tensor inference
- **librosa 0.10** β€” Audio feature extraction and spectral analysis
- **imageio-ffmpeg** β€” Bundled ffmpeg binary for video conversion
- **yt-dlp** β€” URL-based video download (YouTube, TikTok, etc.)
- **Stripe** β€” Payment processing and subscription management

### Frontend
- **React 19** β€” UI library
- **Vite 8** β€” Build tool and dev server
- **Tailwind CSS 4** β€” Utility-first styling
- **Three.js + @react-three/fiber** β€” 3D particle effects
- **Framer Motion** β€” Animations
- **Zustand** β€” Lightweight state management

### Infrastructure
- **Docker** β€” Containerization
- **Render** β€” PaaS deployment
- **HuggingFace Spaces** β€” Model hosting and demo deployment

### AI Models

| Model | Source | Purpose |
|---|---|---|
| `dima806/deepfake_vs_real_image_detection` | HuggingFace | Primary ViT classifier |
| `prithivMLmods/Deep-Fake-Detector-v2-Model` | HuggingFace | Secondary ViT classifier |

---

## πŸ”§ Troubleshooting

### Server takes a long time to start

**Cause:** HuggingFace models (~1–2 GB) are being downloaded on first run.  
**Fix:** Wait ~2–5 minutes. Subsequent starts use the local cache at `~/.cache/huggingface/`.

### `Could not open video` / OpenCV error on Windows

**Cause:** OpenCV on Windows cannot natively decode `.webm` or `.mkv`.  
**Fix:** The backend automatically converts these via bundled ffmpeg. Ensure `imageio-ffmpeg` is installed:
```bash
pip install imageio-ffmpeg
```

### Extension not sending data to the API

**Cause:** The extension is hard-coded to connect to `http://localhost:8000` (dev) or `https://aarav13-authrix.hf.space` (prod).  
**Fix:** Update `host_permissions` in `extension/manifest.json` to match your deployment URL, then reload the extension.

### `429 Monthly limit exceeded`

**Cause:** Your API key has hit its monthly quota.  
**Fix:** Upgrade your plan, or generate a new owner key locally:
```bash
python create_owner_key.py
```

### `503 Server still initializing`

**Cause:** The ViT models haven't finished loading yet.  
**Fix:** Hit `GET /health` and wait until `"ready": true`, then retry.

### Audio analysis not available

**Cause:** `librosa`, `soundfile`, or `moviepy` not installed, or the video has no audio track.  
**Fix:**
```bash
pip install librosa soundfile moviepy
```

---

## πŸ—ΊοΈ Roadmap

- [ ] Firefox extension support
- [ ] Real-time video stream analysis via WebSocket
- [ ] Mobile app (React Native)
- [ ] Batch analysis endpoint for enterprise workflows
- [ ] Webhook notifications for async analysis
- [ ] GDPR-compliant EU data residency option
- [ ] On-premise deployment Helm chart
- [ ] Fine-tuned model on latest Veo3 / Sora outputs

---

## 🀝 Contributing

Contributions are welcome! Please follow these steps:

1. Fork the repository
2. Create a feature branch: `git checkout -b feat/my-feature`
3. Commit your changes: `git commit -m 'feat: add my feature'`
4. Push to the branch: `git push origin feat/my-feature`
5. Open a Pull Request

Please make sure your code passes linting before submitting.

---

## πŸ“„ License

This project is licensed under the **MIT License** β€” see the [LICENSE](LICENSE) file for details.

---

## πŸ“§ Contact

| Channel | Link |
|---|---|
| Enterprise Sales | enterprise@authrix.ai |
| Live Demo | https://aarav13-authrix.hf.space |
| API Docs | https://aarav13-authrix.hf.space/docs |

---

<div align="center">

**Built with ❀️ by the Authrix Team**

*Fighting misinformation, one frame at a time.*

</div>