Backend service for a Deepfake Detection Platform that allows users to analyze images/videos and determine whether they are AI-generated or real.
- π User Authentication (JWT + API Key)
- π Per-user API Key system
- π API Key regeneration
- π‘ Deepfake detection (URL & file upload)
- π Scan history tracking
- ποΈ PostgreSQL (Supabase)
- β‘ High-performance APIs with FastAPI
- Framework: FastAPI
- Database: PostgreSQL (Supabase)
- ORM: SQLAlchemy
- Auth: JWT (python-jose)
- Hashing: Passlib (bcrypt)
- Containerization: Docker
.
βββ app/
β βββ __pycache__/
β β
β βββ detectors/
β β βββ image_model.py
β β βββ video_detector.py
β β
β βββ models/
β β βββ image_detect/
β β β βββ xception_deepfake_base.keras
β β βββ video-detect/
β β βββ model.ipynb
β β βββ video_model.keras
β β
β βββ routes/
β β βββ __pycache__/
β β βββ api.py
β β βββ auth.py
β β
β βββ services/
β β βββ __pycache__/
β β βββ image_scraper.py
β β βββ ytdlp_service.py
β β
β βββ auth.py
β βββ db.py
β βββ image_model.py
β βββ main.py
β βββ models.py
β βββ schemas.py
β βββ utils.py
β
βββ venv/
βββ .env
βββ .gitignore
βββ cookies.txt
βββ LICENSE
βββ README.md
Run the backend without installing Python or dependencies.
- Install Docker Desktop
git clone <your-repo-url>
cd deepfake-backendDATABASE_URL=postgresql://username:password@host:port/database
use ipv4 instead of ipv6 in case of supabase
β οΈ Use Supabase Session Pooler if required.
docker compose up --build-
Backend: π http://localhost:8080
-
Swagger Docs: π http://localhost:8080/docs
docker compose downdocker compose up --build- First build may take time (Docker image build)
- Ensure port 8080 is free
.envfile is required- No need to install Python locally
The API supports two authentication methods:
Use the token received after login:
Authorization: Bearer YOUR_JWT_TOKENUse the API key received during registration/login:
x-api-key: YOUR_API_KEY- Creates a new user
- Returns API key
-
Returns:
- JWT token
- API key
- Generates a new API key
- Invalidates the old one
POST /auth/registerβ Register userPOST /auth/loginβ Login & get JWT + API keyPOST /auth/regenerate-keyβ Generate new API key
POST /analyse/urlβ Analyze media from URLPOST /analyse/analyse_uploadβ Analyze uploaded fileGET /historyβ Get user scan history
POST /analyse/url
Headers:
Authorization: Bearer YOUR_JWT_TOKEN
Body:
{
"url": "https://example.com/video.mp4"
}POST /analyse/url
Headers:
x-api-key: YOUR_API_KEY
Body:
{
"url": "https://example.com/video.mp4"
}- Swagger UI supports authentication via the π button
- JWT is recommended for frontend apps
- API keys are useful for scripts and external integrations
- π€ Model improvements
- β±οΈ Rate limiting (Redis)
- π Chrome extension
- π Dashboard
- π Multiple API keys
- bcrypt limit: 72 characters
- Use URL-safe DB credentials
- Prefer Supabase Session Pooler for production
Built as part of a hackathon project β Sentinel AI
Pull requests are welcome. Open an issue for major changes.
If you want next-level polish, I can:
- add badges (Docker, FastAPI, stars, etc.)
- or make it look like a top-tier GitHub repo (with screenshots + demo GIF)