Skip to content

Repository files navigation

TruthGuard AI

AI-Powered Hoax & Scam Detection Platform

TruthGuard AI is an AI-powered web application designed to help users analyze potentially misleading information, scams, and suspicious messages.

The platform combines Laravel-based backend architecture with Google Gemini AI to provide structured analysis including verdict, confidence score, risk level, explanation, and recommended actions.

TruthGuard AI helps users make more informed decisions before trusting or sharing suspicious information.


Overview

Online scams and misleading information continue to evolve rapidly, making it increasingly difficult to distinguish legitimate information from potentially harmful content.

TruthGuard AI provides an accessible first layer of analysis. Users can submit suspicious text and receive an AI-generated assessment in Indonesian.

The system is designed with a modular architecture so that AI providers can be extended or replaced without tightly coupling the application to a single provider.


Key Features

Feature Description
Scam Detection Analyze suspicious messages for potential scam indicators
Hoax Detection Analyze potentially misleading or false information
AI Analysis Powered by Google Gemini
Confidence Score Indicates the AI's confidence in the classification
Risk Classification Categorizes results into Low, Medium, or High
AI Explanation Provides contextual reasoning behind the result
Recommendation Gives users practical next-step recommendations
AI Chat Conversational interface for discussing suspicious information
REST API Backend API for analysis requests
Provider Architecture AI integrations are separated through provider interfaces
Indonesian Output Analysis results are generated in Indonesian

How It Works

┌──────────────────────┐
│        User          │
│                      │
│  Suspicious Message  │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│    Laravel API       │
│                      │
│ AnalysisController   │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ AI Analysis Service  │
│                      │
│ Business Logic       │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│   AI Provider Layer  │
│                      │
│   Gemini Provider    │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│    Google Gemini     │
│      AI Model        │
└──────────┬───────────┘
           │
           ▼
┌────────────────────────────┐
│      Structured Result     │
│                            │
│ Verdict                    │
│ Confidence                 │
│ Risk Level                 │
│ Explanation                │
│ Recommendation             │
└────────────────────────────┘

Architecture

TruthGuard AI follows a service-oriented approach within the Laravel application.

HTTP Request
     │
     ▼
Controller
     │
     ▼
Service Layer
     │
     ├── DTO
     │
     ├── Contract
     │
     └── Provider
             │
             ▼
        External AI API

This separation makes the application easier to maintain and allows additional AI providers to be introduced in the future.

AI Provider Structure

app/Services/AI/
│
├── Contracts/
│   ├── AIProvider.php
│   └── ChatProvider.php
│
├── DTO/
│   ├── AIAnalysisResponse.php
│   └── ChatResponse.php
│
├── Providers/
│   ├── GeminiProvider.php
│   ├── GeminiChatProvider.php
│   └── OpenAIChatProvider.php
│
├── AIAnalysisService.php
└── ChatService.php

Technology Stack

Backend

  • PHP 8.3+
  • Laravel 12
  • Laravel Eloquent
  • Guzzle HTTP Client

Frontend

  • Blade
  • JavaScript
  • CSS
  • Vite

AI

  • Google Gemini API
  • Provider-based AI integration architecture

Database

  • SQLite for lightweight deployment
  • MySQL supported for development environments

Deployment

  • Ubuntu 24.04
  • Nginx
  • PHP-FPM
  • Composer
  • Node.js / npm

Project Structure

app/
├── Enums/
│   ├── AnalysisStatus.php
│   ├── AnalysisType.php
│   ├── AnalysisVerdict.php
│   └── RiskLevel.php
│
├── Http/
│   └── Controllers/
│       └── Api/
│           ├── AnalysisController.php
│           └── ChatController.php
│
├── Models/
│   ├── Analysis.php
│   ├── AnalysisResult.php
│   └── User.php
│
├── Services/
│   └── AI/
│       ├── Contracts/
│       ├── DTO/
│       ├── Providers/
│       ├── AIAnalysisService.php
│       └── ChatService.php
│
database/
├── migrations/
└── seeders/

resources/
├── css/
├── js/
└── views/

routes/
├── api.php
├── web.php
└── console.php

Installation

Requirements

Before installing TruthGuard AI, make sure your environment has:

  • PHP 8.3 or newer
  • Composer
  • Node.js and npm
  • SQLite or MySQL
  • Google Gemini API key

1. Clone the Repository

git clone https://github.com/MasMuham24/TruthGuard-AI.git

cd TruthGuard-AI

2. Install Backend Dependencies

composer install

3. Install Frontend Dependencies

npm install

4. Configure Environment

cp .env.example .env

Generate the Laravel application key:

php artisan key:generate

5. Configure AI

Add the following variables to .env:

GEMINI_API_KEY=your_gemini_api_key
GEMINI_BASE_URL=https://generativelanguage.googleapis.com
GEMINI_MODEL=gemini-3.5-flash

Never commit .env or expose your API key in the repository.

6. Configure Database

For SQLite:

touch database/database.sqlite

Then run:

php artisan migrate

7. Build Frontend

npm run build

8. Run the Application

php artisan serve

Open:

http://127.0.0.1:8000

API Reference

Analyze Message

POST /api/analyze

Request

{
    "type": "scam",
    "message": "Selamat! Anda mendapatkan hadiah. Klik link berikut untuk mengambil hadiah Anda."
}

Parameters

Parameter Type Required Values
type string Yes hoax, scam
message string Yes Minimum 5 characters

Example Response

{
    "verdict": "scam",
    "confidence": 99,
    "risk_level": "high",
    "explanation": "Pesan memiliki karakteristik yang umum ditemukan pada pola penipuan.",
    "recommendation": "Jangan memberikan informasi pribadi atau mengikuti instruksi dari pesan tersebut."
}

Analysis Result

TruthGuard AI returns a structured assessment consisting of:

Verdict

Possible classifications:

safe
hoax
scam
uncertain

Confidence

A numerical score representing the AI's confidence in the classification.

Risk Level

low
medium
high

Explanation

A contextual explanation describing why the AI reached the given classification.

Recommendation

A recommendation intended to help users decide what to do next.


Security

TruthGuard AI follows several basic security practices:

  • API credentials are stored in environment variables.
  • .env is excluded from version control.
  • Application secrets are not hardcoded into source files.
  • Production debugging should be disabled.
  • HTTPS should be used in production.
  • API access should be appropriately restricted for production deployments.

Production Configuration

APP_ENV=production
APP_DEBUG=false

Laravel caches can then be optimized using:

php artisan config:cache
php artisan route:cache
php artisan view:cache

Deployment Architecture

A production deployment can use the following architecture:

                 Internet
                    │
                    ▼
              ┌───────────┐
              │   Nginx   │
              └─────┬─────┘
                    │
                    ▼
              ┌───────────┐
              │ PHP-FPM   │
              └─────┬─────┘
                    │
                    ▼
              ┌───────────┐
              │  Laravel  │
              └─────┬─────┘
                    │
          ┌─────────┴─────────┐
          ▼                   ▼
     Database            Gemini API

Development

Run the frontend development server:

npm run dev

Run Laravel:

php artisan serve

For a production build:

npm run build

Roadmap

Future development may include:

  • URL analysis
  • News article analysis
  • Integration with trusted fact-checking sources
  • Analysis history
  • User authentication and profiles
  • Advanced analytics dashboard
  • Multi-language analysis
  • Additional AI providers
  • Browser extension
  • Progressive Web App
  • Real-time scam intelligence

Important Disclaimer

TruthGuard AI is an AI-assisted analysis tool, not an authoritative fact-checking service.

AI-generated results may contain errors or incomplete interpretations. Users should verify important information through reliable sources before making decisions or sharing information.


Project Status

Status: Active Development

TruthGuard AI was developed as an AI-focused project for exploring practical applications of artificial intelligence in digital safety and information verification.


Author

Muhammad Syafi'i

Full Stack Engineer

  • 🏆 1st Place — LKS Web Technology Kabupaten Demak 2026
  • 💻 Laravel • PHP • JavaScript • AI Integration
  • 🚀 Focused on building practical web applications and AI-powered systems

License

This project is open-sourced under the MIT License.


TruthGuard AI
Analyze before you trust. Verify before you share.

About

TruthGuard AI is an AI-powered web application designed to help users analyze potentially misleading information, scams, and suspicious messages.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages