DAFU (Data Analytics Functional Utilities) is an enterprise fraud detection platform with an integrated CLI that provides:
- 🔐 Authentication & User Management (JWT-based)
- 📋 System Logging & Analytics
- 📊 Fraud Detection Reports
- 🛍️ Product Risk Management
- 🤖 ML Model Execution
- 🐳 Docker Service Orchestration
All from one unified CLI: ./dafu
docker run -d --name dafu-postgres \
-e POSTGRES_USER=dafu \
-e POSTGRES_PASSWORD=dafu_secure_password \
-e POSTGRES_DB=dafu \
-p 5432:5432 \
postgres:15-alpinecd fraud_detection
./start_api.shKeep this running! Wait for:
INFO: Uvicorn running on http://0.0.0.0:8000
INFO: Application startup complete.
./dafu
dafu> help # See all commands
dafu> auth register # Register first time
dafu> auth login # Login
dafu> auth whoami # Check user info
dafu> logs list # View logs
dafu> reports list # View reports
dafu> products stats # Product statistics| Command | Description | Example |
|---|---|---|
auth login |
Login to API (interactive) | ./dafu auth login |
auth logout |
Logout and clear session | ./dafu auth logout |
auth whoami |
Show current user info | ./dafu auth whoami |
auth register |
Register new user | ./dafu auth register |
Example:
./dafu auth login
# Username: admin
# Password: ********
# ✓ Logged in as 'admin'| Command | Description | Example |
|---|---|---|
logs list [limit] |
List recent logs | ./dafu logs list 20 |
logs stats [hours] |
Show log statistics | ./dafu logs stats 24 |
Example:
./dafu logs list 10
# Output:
# ID | Level | Message | Time
# 10 | INFO | User logged in | 2025-10-17 12:00
# 9 | INFO | Report completed | 2025-10-17 11:55
# ...| Command | Description | Example |
|---|---|---|
reports list [limit] |
List your reports | ./dafu reports list |
reports create |
Create new report (interactive) | ./dafu reports create |
reports view <id> |
View report details | ./dafu reports view 1 |
reports stats |
Show report statistics | ./dafu reports stats |
Example:
./dafu reports create
# Report Name: Monthly Fraud Analysis
# Report Type: fraud_detection
# Description: October 2025 analysis
# ✓ Report created with ID: 5
./dafu reports view 5
# Report Details:
# ID: 5
# Name: Monthly Fraud Analysis
# Status: completed
# Progress: 100%
# ...| Command | Description | Example |
|---|---|---|
products list [limit] |
List products | ./dafu products list 50 |
products high-risk [limit] |
List high-risk products | ./dafu products high-risk |
products stats |
Show product statistics | ./dafu products stats |
Example:
./dafu products high-risk 5
# Output:
# ID | SKU | Name | Risk Score | Incidents
# 15 | PHONE-X | Phone Model X | 0.85 | 12
# 23 | WATCH-L | Luxury Watch | 0.78 | 8
# ...| Command | Description | Example |
|---|---|---|
fraud-detection |
Run ML models (interactive) | ./dafu fraud-detection |
models |
Alias for fraud-detection | ./dafu models |
ml |
Alias for fraud-detection | ./dafu ml |
Example:
./dafu fraud-detection
# Interactive menu appears:
# 1. 🔍 ISOLATION FOREST & RISK SCORE
# 2. 🧠 SEQUENCE MODELS (LSTM & GRU)
# 3. ℹ️ MODEL COMPARISON
# 4. ❓ HELP & INFORMATION
# 5. 🚪 EXIT| Command | Description | Example |
|---|---|---|
docker up |
Start Docker services | ./dafu docker up |
docker down |
Stop Docker services | ./dafu docker down |
docker restart |
Restart Docker services | ./dafu docker restart |
docker status |
Show service status | ./dafu docker status |
docker logs |
View Docker logs | ./dafu docker logs |
docker rebuild |
Rebuild services | ./dafu docker rebuild |
| Command | Description | Example |
|---|---|---|
status |
Show platform status | ./dafu status |
version |
Show version info | ./dafu version |
info |
Show system info | ./dafu info |
help |
Show help menu | ./dafu help |
clear |
Clear screen | ./dafu clear |
exit |
Exit CLI | ./dafu exit |
./dafu
# Interactive session starts
dafu> help
dafu> auth login
dafu> logs list
dafu> reports stats
dafu> exitBenefits:
- Stay in one session
- Run multiple commands
- Faster execution
- Better UX
./dafu auth whoami
./dafu logs list 20
./dafu reports view 1
./dafu products statsBenefits:
- Quick one-off commands
- Scriptable
- CI/CD friendly
# Start DAFU CLI
./dafu
# Login
dafu> auth login
# Check current user
dafu> auth whoami
# View recent logs
dafu> logs list 50
# Check latest reports
dafu> reports list 10
# View high-risk products
dafu> products high-risk 20
# Check statistics
dafu> logs stats 24
dafu> reports stats
dafu> products stats
# Logout
dafu> auth logout./dafu
dafu> auth login
# Create new fraud detection report
dafu> reports create
# Name: Weekly Fraud Analysis
# Type: fraud_detection
# Description: Weekly fraud pattern analysis
# List reports to get ID
dafu> reports list
# View report details (assuming ID is 7)
dafu> reports view 7
# Check report statistics
dafu> reports stats./dafu
dafu> auth login
# List all products
dafu> products list 100
# Focus on high-risk products
dafu> products high-risk 10
# Check product statistics
dafu> products stats
# View system logs related to products
dafu> logs list 20./dafu
# Run ML models
dafu> fraud-detection
# Select model, train, analyze...
# (returns to CLI when done)
# Check if report was created
dafu> reports list
# View system logs
dafu> logs list
# Check product risk updates
dafu> products high-risk-
PostgreSQL (for API data storage)
docker run -d --name dafu-postgres \ -e POSTGRES_USER=dafu \ -e POSTGRES_PASSWORD=dafu_secure_password \ -e POSTGRES_DB=dafu \ -p 5432:5432 \ postgres:15-alpine
-
DAFU API (for auth, logs, reports, products)
cd fraud_detection ./start_api.sh -
Python Environment (auto-managed by CLI)
- Virtual environment created automatically
- Dependencies installed automatically
# 1. Clone repository
git clone https://github.com/MasterFabric/dafu.git
cd dafu
# 2. Make CLI executable
chmod +x dafu
# 3. Start PostgreSQL
docker run -d --name dafu-postgres \
-e POSTGRES_USER=dafu \
-e POSTGRES_PASSWORD=dafu_secure_password \
-e POSTGRES_DB=dafu \
-p 5432:5432 \
postgres:15-alpine
# 4. Start API (new terminal)
cd fraud_detection
./start_api.sh
# 5. Register user (first time - use curl)
curl -X POST "http://localhost:8000/api/v1/auth/register" \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"email": "admin@example.com",
"password": "admin123"
}'
# 6. Use DAFU CLI
./dafu
dafu> auth login
# Username: admin
# Password: admin123
dafu> auth whoamiCreate .env file in root:
# API Configuration
API_PORT=8000
SECRET_KEY=your-secret-key-here
# Database
DATABASE_URL=postgresql://dafu:dafu_secure_password@localhost:5432/dafu
# Features
ENABLE_MONITORING=true
ENABLE_RATE_LIMITING=true- Session File:
~/.dafu_session - Token Expiry: 24 hours
- Auto-login: Session persists across CLI restarts
- Logout: Clears session file
Problem: API not running Solution:
cd fraud_detection
./start_api.shProblem: PostgreSQL not running Solution:
# Check if running
docker ps | grep dafu-postgres
# Start if stopped
docker start dafu-postgres
# Or create new
docker rm -f dafu-postgres
docker run -d --name dafu-postgres \
-e POSTGRES_USER=dafu \
-e POSTGRES_PASSWORD=dafu_secure_password \
-e POSTGRES_DB=dafu \
-p 5432:5432 \
postgres:15-alpineProblem: No active session Solution:
./dafu auth loginProblem: Old API process running Solution:
pkill -9 -f uvicorn
sleep 2
# Then restart API- API Usage Guide - Complete API documentation
- API Quick Start - 5-minute API setup
- CLI Guide - Original CLI guide
- CLI Integration - API integration details
- CLI Step-by-Step - Detailed CLI usage
- Quick Start - ML models quick start
- Docker Status - Docker deployment info
#!/bin/bash
# automated_check.sh
# Login (non-interactive - use session file)
# First create session manually: ./dafu auth login
# Run commands
./dafu logs stats 24 > daily_logs.txt
./dafu reports stats > daily_reports.txt
./dafu products high-risk > high_risk_products.txt
# Send reports via email
mail -s "Daily DAFU Report" admin@company.com < daily_logs.txtfrom fraud_detection.src.api.cli_client import DAFUClient
# Create client
client = DAFUClient(base_url="http://localhost:8000")
# Login
client.login("username", "password")
# Use API programmatically
user = client.get_current_user()
logs = client.get_my_logs(limit=100)
reports = client.get_reports(limit=50)
products = client.get_high_risk_products()
# Process data
for product in products:
if product['fraud_risk_score'] > 0.8:
print(f"Alert: {product['name']} - Risk: {product['fraud_risk_score']}")- Authentication System: JWT-based, role-based access control
- Logging System: Structured logging with analytics
- Report Management: Fraud detection report generation
- Product Management: Risk tracking and inventory
- ML Models: Isolation Forest, LSTM, GRU models
- Stream Processing: Real-time data processing
- Batch Processing: Large-scale analysis
- Model Persistence: Save/load trained models
- Unified CLI: Single command for all features
- Docker Support: Service orchestration
- Unified Interface: One CLI for everything
- Auto-Management: Virtual environment handled automatically
- Persistent Sessions: Login once, use everywhere
- Interactive & Scriptable: Works both ways
- Production-Ready: Enterprise-grade security and reliability
- Extensible: Easy to add new features
| Role | Permissions |
|---|---|
| viewer | Read-only access to own data |
| user | Create and manage own resources |
| analyst | Access all data, manage products, view all logs |
| admin | Full system access, user management |
- CLI: Bash + Python
- API: FastAPI
- Database: PostgreSQL
- Authentication: JWT (python-jose)
- Password Hashing: Passlib + bcrypt
- ORM: SQLAlchemy
- ML: scikit-learn, TensorFlow
- Containerization: Docker
- Documentation: OpenAPI/Swagger
- Documentation:
/docsdirectory - API Docs: http://localhost:8000/docs (when running)
- GitHub Issues: https://github.com/MasterFabric/dafu/issues
- Email: dafu@masterfabric.co
- ✅ Explore all CLI commands:
./dafu help - ✅ Try ML models:
./dafu fraud-detection - ✅ Create your first report:
./dafu reports create - ✅ Monitor products:
./dafu products high-risk - ✅ Check system health:
./dafu status - ✅ View API docs: http://localhost:8000/docs
DAFU - Your Complete Fraud Detection Platform 🚀
Version: 2.0.0 (with API integration) Updated: 2025-10-17 License: AGPL-3.0