# divyaazz/ai-lie-detector architecture

> Architecture diagram of the GitHub repository divyaazz/ai-lie-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/divyaazz/ai-lie-detector
- Repository: https://github.com/divyaazz/ai-lie-detector

## Overview

##### Project Type & Purpose
- This is a full-stack, multi-modal AI application that ingests voice, video, or text input, processes it through ML pipelines (audio processing, facial recognition, NLP), classifies the response as “Truth” or “Lie,” and presents results via a web interface.

##### High-Level Architecture Components
a. Client Layer
- Web UI (Streamlit or Flask front-end)
b. Ingestion & Preprocessing Layer
- Audio Preprocessor (Librosa, OpenSMILE)
- Video/Facial Preprocessor (OpenCV, MediaPipe, dlib)
- Text Preprocessor (NLTK, spaCy, Transformers)
c. Feature Extraction Layer
- Audio Feature Extractor (MFCC, pitch, energy vectors)
- Facial Feature Extractor (landmarks, expression vectors)
- Text Embedding Generator (BERT embeddings)
d. Classification Layer
- Neural Network Model(s) (TensorFlow/Keras or PyTorch)
– Single unified classifier or separate per-modality with ensemble logic
- Decision logic to output “Truth” or “Lie” and confidence score
e. Data Storage Layer
- Local filesystem for raw input and feature caches
- MongoDB (optional) for storing labeled inputs, training/serving data
f. Deployment & Infrastructure
- Containerization (Docker)
- Cloud deployment: Heroku or AWS (EC2 for servers, Lambda for serverless inference)
- CI/CD pipelines (optional)

##### Relationships & Data Flows
- User uploads or streams input → Web UI
- Web UI calls ingestion endpoints → dispatches to appropriate Preprocessing service
- Preprocessed data forwarded to Feature Extraction modules
- Extracted features aggregated and sent to Classification service
- Prediction results returned to Web UI → display “Truth”/“Lie” + confidence
- All inputs, features, and predictions logged/stored in Data Storage for auditing or model retraining

##### Architectural Patterns & Design Principles
- Layered/microservices approach for each modality preprocessor
- Single Responsibility: each service (audio, video, text) does one thing
- Modular ML pipeline: easy to swap out models or add new modalities
- Stateless front-end; stateful or stateless back-end depending on chosen deployment
- Optional event-driven messaging (e.g., RabbitMQ or AWS SNS/SQS) if scaling async jobs

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        UI["Web UI (Streamlit/Flask)"]:::frontend
        Microphone["Microphone Input"]:::frontend
        Webcam["Webcam Input"]:::frontend
        TextBox["Text Input"]:::frontend
    end

    %% Ingestion & Preprocessing Layer
    subgraph "Ingestion & Preprocessing Layer"
        direction TB
        AudioPrep["Audio Preprocessor\n(Librosa, OpenSMILE)"]:::preprocess
        VideoPrep["Video Preprocessor\n(OpenCV, MediaPipe, dlib)"]:::preprocess
        TextPrep["Text Preprocessor\n(NLTK, spaCy, Transformers)"]:::preprocess
    end

    %% Feature Extraction Layer
    subgraph "Feature Extraction Layer"
        direction TB
        AudioFeat["Audio Feature Extractor\n(MFCC, pitch, energy vectors)"]:::model
        FacialFeat["Facial Feature Extractor\n(landmarks, expression vectors)"]:::model
        TextEmbed["Text Embedding Generator\n(BERT embeddings)"]:::model
    end

    %% Classification Layer
    subgraph "Classification Layer"
        direction TB
        Classifier["Neural Network Classifier\n(TensorFlow/Keras or PyTorch)"]:::model
        Decision["Decision Logic\nTruth/Lie + Confidence"]:::model
    end

    %% Data Storage Layer
    subgraph "Data Storage Layer"
        direction TB
        RawFS["Local Filesystem\n(Raw Input)"]:::storage
        FeatureFS["Local Filesystem\n(Feature Cache)"]:::storage
        Mongo["MongoDB"]:::storage
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        direction TB
        Docker["Docker Container"]:::deploy
        Cloud["Heroku/AWS\n(EC2, Lambda)"]:::deploy
        CICD["CI/CD Pipeline"]:::deploy
    end

    %% Data Flows
    Microphone --> UI
    Webcam --> UI
    TextBox --> UI

    UI -->|"Raw audio"| AudioPrep
    UI -->|"Raw video"| VideoPrep
    UI -->|"Raw text"| TextPrep

    AudioPrep -->|"Audio frames"| AudioFeat
    VideoPrep -->|"Video frames"| FacialFeat
    TextPrep -->|"Tokenized text"| TextEmbed

    AudioFeat -->|"Audio vectors"| Classifier
    FacialFeat -->|"Facial vectors"| Classifier
    TextEmbed -->|"Text embeddings"| Classifier

    Classifier --> Decision
    Decision -->|"Prediction"| UI

    %% Logging to Storage
    AudioPrep --> RawFS
    VideoPrep --> RawFS
    TextPrep --> RawFS

    AudioFeat --> FeatureFS
    FacialFeat --> FeatureFS
    TextEmbed --> FeatureFS

    Decision --> Mongo

    %% Deployment Flows
    UI --> Docker
    Classifier --> Docker
    Docker --> Cloud
    CICD --> Docker
    CICD --> Cloud

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef preprocess fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef model fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef storage fill:#ECEFF1,stroke:#607D8B,color:#455A64
    classDef deploy fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C
```
