# jerlee123/deep_fake_api-main architecture

> Architecture diagram of the GitHub repository jerlee123/deep_fake_api-main, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jerlee123/deep_fake_api-main
- Repository: https://github.com/jerlee123/deep_fake_api-main

## Overview

This repository is a FastAPI video-authenticity backend with two user-facing flows: upload a video for deepfake analysis, or stream camera frames for live eKYC presentation-attack detection. The upload workflow produces predictions, metadata and frame-level review; the live workflow buffers frames and returns ongoing REAL/SPOOF results. Integrity signing and verification are separate API capabilities. The main API and model sources are sampled, but live-route internals and some report/training wiring are not, so uncertain connections are omitted. README also cautions that live inference may lack a trained checkpoint.

Main entry points: [`apiForAppNewOne.py`](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py) (REST upload API), [`realtime_ekyc_api.py`](https://github.com/jerlee123/deep_fake_api-main/blob/main/realtime_ekyc_api.py) (Realtime PAD API), [`ekyc_pad_pipeline.py`](https://github.com/jerlee123/deep_fake_api-main/blob/main/ekyc_pad_pipeline.py) (PAD pipeline), [`llm_report_generator.py`](https://github.com/jerlee123/deep_fake_api-main/blob/main/llm_report_generator.py) (LLM reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_upload["REST upload API<br/>[apiForAppNewOne.py]"]
  node_live["Live eKYC WebSocket<br/>[apiForAppNewOne.py]"]
  node_realtime["Realtime PAD API"]
end

subgraph group_vision["Video analysis"]
  node_video["Video preprocessing<br/>[apiForAppNewOne.py]"]
  node_metadata["Video metadata<br/>[apiForAppNewOne.py]"]
  node_sampling["Frame sampling<br/>[apiForAppNewOne.py]"]
  node_face["Face detection<br/>[apiForAppNewOne.py]"]
  node_explanation["Prediction explanation<br/>[apiForAppNewOne.py]"]
  node_csv["Frame-level analysis<br/>[apiForAppNewOne.py]"]
end

subgraph group_models["Inference models"]
  node_pad_pipeline["PAD pipeline"]
  node_deepfake["Deepfake model<br/>[deepfake_model.py]"]
  node_vivit["ViViT model<br/>[vivit_model.py]"]
  node_temporal["ViViT BiLSTM model"]
  node_llm_report["LLM reports"]
  node_checkpoint["Model checkpoints"]
end

subgraph group_integrity["Integrity services"]
  node_sign["Signature endpoints<br/>[apiForAppNewOne.py]"]
  node_keys["RSA key files"]
end

node_client(("Mobile or API client"))
node_llm_service["LLM provider"]
node_video_result["Analysis results"]
node_live_result["Live predictions"]
node_integrity_result["Signature response"]

node_client -->|"uploads video"| node_upload
node_upload -->|"processes upload"| node_video
node_upload -->|"extracts metadata"| node_metadata
node_upload -->|"dispatches CSV analysis"| node_csv
node_video -->|"samples frames"| node_sampling
node_video -->|"detects faces"| node_face
node_upload -->|"runs inference"| node_deepfake
node_upload -->|"builds explanation"| node_explanation
node_upload -->|"returns results"| node_video_result
node_client -->|"streams frames"| node_live
node_live -->|"dispatches stream"| node_realtime
node_realtime -->|"runs PAD inference"| node_vivit
node_realtime -->|"sends predictions"| node_live_result
node_client -->|"requests signing"| node_sign
node_sign -->|"uses RSA keys"| node_keys
node_sign -->|"returns signature"| node_integrity_result
node_pad_pipeline -->|"trains or predicts"| node_temporal
node_llm_report -.->|"requests report text"| node_llm_service
node_pad_pipeline -.->|"loads or saves"| node_checkpoint

click node_upload "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_live "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_video "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_metadata "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_sampling "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_face "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_explanation "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_csv "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_realtime "https://github.com/jerlee123/deep_fake_api-main/blob/main/realtime_ekyc_api.py"
click node_pad_pipeline "https://github.com/jerlee123/deep_fake_api-main/blob/main/ekyc_pad_pipeline.py"
click node_deepfake "https://github.com/jerlee123/deep_fake_api-main/blob/main/deepfake_model.py"
click node_vivit "https://github.com/jerlee123/deep_fake_api-main/blob/main/vivit_model.py"
click node_temporal "https://github.com/jerlee123/deep_fake_api-main/blob/main/vivit_bilstm_model.py"
click node_sign "https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py"
click node_keys "https://github.com/jerlee123/deep_fake_api-main/tree/main/keys"
click node_llm_report "https://github.com/jerlee123/deep_fake_api-main/blob/main/llm_report_generator.py"
click node_checkpoint "https://github.com/jerlee123/deep_fake_api-main/blob/main/ekyc_checkpoint.pth"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_upload,node_live,node_realtime,node_client toneBlue
class node_video,node_metadata,node_sampling,node_face,node_explanation,node_csv toneAmber
class node_pad_pipeline,node_deepfake,node_vivit,node_temporal,node_llm_report,node_checkpoint toneMint
class node_sign,node_keys toneRose
class node_llm_service,node_video_result,node_live_result,node_integrity_result toneIndigo
```

## Components

### API workflows

- [REST upload API](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Live eKYC WebSocket](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Realtime PAD API](https://github.com/jerlee123/deep_fake_api-main/blob/main/realtime_ekyc_api.py): `realtime_ekyc_api.py`

### Video analysis

- [Video preprocessing](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Video metadata](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Frame sampling](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Face detection](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Prediction explanation](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [Frame-level analysis](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`

### Inference models

- [PAD pipeline](https://github.com/jerlee123/deep_fake_api-main/blob/main/ekyc_pad_pipeline.py): `ekyc_pad_pipeline.py`
- [Deepfake model](https://github.com/jerlee123/deep_fake_api-main/blob/main/deepfake_model.py): `deepfake_model.py`
- [ViViT model](https://github.com/jerlee123/deep_fake_api-main/blob/main/vivit_model.py): `vivit_model.py`
- [ViViT BiLSTM model](https://github.com/jerlee123/deep_fake_api-main/blob/main/vivit_bilstm_model.py): `vivit_bilstm_model.py`
- [LLM reports](https://github.com/jerlee123/deep_fake_api-main/blob/main/llm_report_generator.py): `llm_report_generator.py`
- [Model checkpoints](https://github.com/jerlee123/deep_fake_api-main/blob/main/ekyc_checkpoint.pth): `ekyc_checkpoint.pth`

### Integrity services

- [Signature endpoints](https://github.com/jerlee123/deep_fake_api-main/blob/main/apiForAppNewOne.py): `apiForAppNewOne.py`
- [RSA key files](https://github.com/jerlee123/deep_fake_api-main/tree/main/keys): `keys`

### Other components

- **Mobile or API client**
- **LLM provider**
- **Analysis results**
- **Live predictions**
- **Signature response**

## Connections

- Mobile or API client → REST upload API: uploads video
- REST upload API → Video preprocessing: processes upload
- REST upload API → Video metadata: extracts metadata
- REST upload API → Frame-level analysis: dispatches CSV analysis
- Video preprocessing → Frame sampling: samples frames
- Video preprocessing → Face detection: detects faces
- REST upload API → Deepfake model: runs inference
- REST upload API → Prediction explanation: builds explanation
- REST upload API → Analysis results: returns results
- Mobile or API client → Live eKYC WebSocket: streams frames
- Live eKYC WebSocket → Realtime PAD API: dispatches stream
- Realtime PAD API → ViViT model: runs PAD inference
- Realtime PAD API → Live predictions: sends predictions
- Mobile or API client → Signature endpoints: requests signing
- Signature endpoints → RSA key files: uses RSA keys
- Signature endpoints → Signature response: returns signature
- PAD pipeline → ViViT BiLSTM model: trains or predicts
- LLM reports → LLM provider: requests report text
- PAD pipeline → Model checkpoints: loads or saves
