Skip to content

nutthakorn7/ThaiScamBench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

302 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ ThaiScamBench (World Class Edition)

The Gold Standard in Thai Scam Detection & Prevention

AI-powered scam detection system for Thai language messages and bank slip images, featuring adaptive learning and crowd-sourced threat intelligence.

🏦 4-Layer Image Detection System

Advanced bank slip verification with 70%+ risk reduction for genuine slips!

How It Works

  1. πŸ”€ Text Analysis (25% weight)

    • OCR extraction via Google Vision API
    • Keyword pattern matching
    • AI classification (Gemini/GPT)
  2. πŸ‘οΈ Visual Forensics (15% weight)

    • Error Level Analysis (ELA)
    • Metadata examination
    • Clone detection
    • JPEG compression analysis
  3. 🏦 Slip Verification (40% weight)

    • βœ… Bank name detection (14+ Thai banks)
    • βœ… Account format validation
    • βœ… Amount sanity checks
    • βœ… Date/time format verification
  4. πŸ“± QR Code Validation (20% weight) [NEW]

    • πŸ” PromptPay Decoding (EMVCo Standard)
    • πŸ’° Amount Cross-Check (QR Payload vs OCR Text)
    • πŸ›‘οΈ Critical Risk Logic: QR Mismatch = Immediate Flag 🚩

Smart Fusion Algorithm

if qr_valid:  # QR Amount matches OCR exactly
    trust_score += 0.2
    final_risk = 0.0 # High Confidence Safe
elif qr_mismatch:
    final_risk = 1.0 # Critical Risk (Tampering Detected)

Production Results βœ…

Tested with 4 Real Bank Slips - 100% Accuracy!

Slip Text Risk Slip Trust Final Risk Improvement
Bangkok Bank 20 THB 0.95 83% 0.37 -61% βœ…
Krungthai 90 THB 0.00 100% 0.00 Perfect βœ…
SCB 50,000 THB 0.65 83% 0.28 -57% βœ…
Kasikorn 150 THB 0.10 67% 0.10 -90% βœ…

Average Risk Reduction: 68% | False Positives: 0%

A production-grade, AI-powered scam detection platform featuring a modern Next.js 14 Frontend, FastAPI Backend, and enterprise-grade Security.

Next.js FastAPI CI/CD Deployment 3-Layer Detection License Status


✨ Key Features (New!)

🎨 World-Class UX

  • Dynamic Hero: Interactive 3D typewriter effects and aurora backgrounds.
  • Glassmorphism 2.0: Premium frosted glass aesthetics across the entire UI.
  • Responsive Design: Mobile-perfect touch targets (>44px) and fluid grids.

πŸš€ Interactive Detection

  • Radar Scanning: High-tech scanning animations (no more boring spinners).
  • Instant Haptics: Screen shake for danger, confetti detonation for safe results.
  • Staggered Results: Data points reveal sequentially for maximum impact.

πŸ“Š Enterprise Dashboard

  • Real-Time Ticker: Live view of detection events as they happen (/stats/recent).
  • Interactive Analytics: Rich recharts Area Charts visualizing 7-month trends.
  • Data Integration: Connected directly to PostgreSQL for live insights.

πŸ›‘οΈ Pro Security

  • NextAuth.js: Secure, session-based authentication for admins.
  • Middleware: Server-side route protection for all /admin paths.
  • Rate Limiting: Intelligent throttling per IP and Partner API key.

πŸ› οΈ Tech Stack

Component Technology Highlights
Frontend Next.js 14 (App Router) React Server Components, TailwindCSS v4, Framer Motion
Backend Python 3.9 + FastAPI Async, SQLAlchemy, Pydantic v2
Database PostgreSQL Relational data, optimized indexing
Auth NextAuth.js Credential provider, Secure HTTP-only cookies
Ops Docker Multi-stage builds, CI/CD with GitHub Actions

πŸš€ Quick Start

1. Requirements

  • Docker & Docker Compose
  • Node.js 20+ (for local frontend dev)
  • Python 3.9+ (for local backend dev)

2. Run with Docker (Recommended)

# Start all services (Frontend + Backend + DB)
docker-compose up -d --build

Access the app at http://localhost:3000.

3. Local Development

Backend:

cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend:

cd frontend
npm install
npm run dev

πŸ”’ Security

This project implements Phase 5 Security Standards:

  1. Strict Middleware: Unauthenticated users are strictly blocked from /admin.
  2. Environment Isolation: Secrets are loaded from .env only (see .env.example).
  3. Hashed Tokens: API keys are hashed SHA-256 before storage.

🀝 Partners & API

Partners can integrate using our secure REST API:

POST /api/partner/detect
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json

{
  "message": "ΰΈ„ΰΈΈΰΈ“ΰΉ„ΰΈ”ΰΉ‰ΰΈ£ΰΈ±ΰΈšΰΈ£ΰΈ²ΰΈ‡ΰΈ§ΰΈ±ΰΈ₯ 1,000 ΰΈšΰΈ²ΰΈ—"
}

πŸ“‚ Project Structure

ThaiScamBench/
β”œβ”€β”€ app/                    # Backend API (FastAPI)
β”‚   β”œβ”€β”€ api/               # API route handlers
β”‚   β”œβ”€β”€ core/              # Core utilities and exceptions
β”‚   β”œβ”€β”€ middleware/        # Authentication, security, rate limiting
β”‚   β”œβ”€β”€ models/            # Database models and schemas
β”‚   β”œβ”€β”€ services/          # Business logic
β”‚   └── utils/             # Helper functions
β”‚
β”œβ”€β”€ frontend/              # Next.js 14 Frontend
β”‚   β”œβ”€β”€ app/              # App Router pages
β”‚   β”œβ”€β”€ components/       # Reusable React components
β”‚   β”œβ”€β”€ features/         # Feature-specific components
β”‚   └── lib/              # Client utilities
β”‚
β”œβ”€β”€ scripts/              # Utility scripts (see scripts/README.md)
β”‚   β”œβ”€β”€ deployment/      # Deployment and provisioning
β”‚   β”œβ”€β”€ migrations/      # Database migrations
β”‚   β”œβ”€β”€ utils/           # Helper scripts
β”‚   └── maintenance/     # Cleanup and testing
β”‚
β”œβ”€β”€ docs/                 # Documentation
β”œβ”€β”€ data/                 # Database files (local dev)
β”œβ”€β”€ datasets/             # Training and test datasets
β”œβ”€β”€ tests/                # Test suites
β”‚   β”œβ”€β”€ unit/
β”‚   β”œβ”€β”€ integration/
β”‚   └── load/
β”‚
└── docker-compose.yml    # Production deployment config

οΏ½ Deployment

Quick Production Deploy

# Method 1: Automated script (Recommended)
./scripts/deployment/quick_deploy.sh

# Method 2: GitHub Actions (CI/CD)
# Go to: GitHub β†’ Actions β†’ "πŸš€ Deploy to Production"
# Type "DEPLOY" to confirm

# Method 3: Manual SSH
ssh root@172.104.171.16 -i ~/.ssh/thaiscam_deploy
cd /opt/thaiscam && git pull && docker-compose up -d --build

Deployment Documentation

πŸ“– Full deployment guide: docs/DEPLOYMENT.md

  • Production server setup
  • GitHub Actions CI/CD pipeline
  • Manual deployment procedures
  • Health checks & monitoring
  • Rollback strategies
  • Troubleshooting guide

πŸ“„ License

MIT License Β© 2024 ThaiScamBench Team

Made with ❀️ for Thai Internet Safety

About

Thai Scam Detection

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors