Skip to content
prathameshfukePublic

About

Graph-Based Collusion Detection for Merchant Fraud Prevention (ARGUS = Abuse-Ring Graph-based User Sentinel)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ARGUS: Abuse-Ring Graph-based User Sentinel

Explainable collusion-ring detection and triage desk for merchant risk teams.

Tests Python FastAPI React


Executive Summary & Problem Framing

Modern fraud and promo abuse operations rarely manifest as solitary bad actors conducting large, anomalous transactions. Coordinated fraud rings operate across dozens or hundreds of synthetic merchant accounts. Each individual account exhibits standard transaction velocities, legitimate order amounts, and low refund counts. When evaluated in isolation by tabular rules engines, every account passes risk checks.

The coordination becomes detectable only when analyzing relational metadata across the account population. Fraud rings frequently share high-entropy digital identifiers: device hardware fingerprints, payment instrument tokens, subnet IP addresses, and billing/shipping physical addresses.

ARGUS models merchant ecosystems as an undirected multigraph, clusters coordinated account groups using modularity optimization, and scores each community against a 6-factor composite collusion heuristic. The system serves results through an explainable, human-in-the-loop analyst workstation with explicit false-positive review cost projections.

ARGUS Pitch Deck: Problem Framing


Core Detection Methodology

ARGUS detects collusion rings in four sequential computational stages:

ARGUS Pitch Deck: How ARGUS Works

1. Shared-Identifier Graph Construction

The platform constructs an undirected multigraph $G = (V, E)$, where vertices $V$ represent merchant accounts and edges $E$ represent shared digital identifiers.

Edge weights reflect the uniqueness and evidentiary strength of each identifier type:

Identifier Type Base Weight Description
shared_device 1.0 Shared hardware device fingerprint
shared_payment 0.9 Shared payment instrument or credit card token
shared_ip 0.7 Shared IP address or subnet
shared_address 0.5 Shared physical billing or shipping address

To prevent high-traffic shared identifiers (such as public Wi-Fi access points or corporate proxies) from creating false dense clusters, ARGUS applies Inverse Document Frequency (IDF) weighting:

$$w_{\text{final}}(u, v) = \sum_{t \in T(u, v)} w_{\text{base}}(t) \cdot \ln\left(1 + \frac{|V|}{\text{count}(t)}\right)$$

2. Louvain Modularity Clustering & Residual Pass

To partition the graph into communities without arbitrary size assumptions, ARGUS executes the Louvain community detection algorithm with modularity optimization ($\gamma = 1.00$).

Because large, loose clusters can absorb smaller, tightly-coordinated rings during the initial global modularity pass, ARGUS runs an automated residual re-detection pass. High-confidence communities are extracted, and a secondary Louvain pass partitions remaining connected subgraphs.

3. Composite Collusion Risk Scoring

Every detected community with at least 3 members is evaluated across six orthogonal risk dimensions, producing a normalized composite score $S \in [0, 1]$:

$$S = 0.30 \cdot D_{\text{graph}} + 0.25 \cdot R_{\text{refund}} + 0.20 \cdot P_{\text{promo}} + 0.10 \cdot V_{\text{tx}} + 0.10 \cdot Y_{\text{age}} + 0.05 \cdot K_{\text{diversity}}$$

  • Topological Density ($D_{\text{graph}}$): Ratio of realized internal edges to maximum possible edges.
  • Average Refund Rate ($R_{\text{refund}}$): Mean ratio of refunded to completed transactions across members.
  • Average Promo Usage Rate ($P_{\text{promo}}$): Mean promotion discount utilization across members.
  • Transaction Velocity ($V_{\text{tx}}$): Normalized order frequency relative to baseline population norms.
  • Young Account Fraction ($Y_{\text{age}}$): Proportion of member accounts created within the last 90 days.
  • Edge Type Diversity ($K_{\text{diversity}}$): Entropy of shared identifier types across community links.

4. Operational False-Positive Cost Calibration

ARGUS evaluates predicted communities against ground-truth rings using Intersection-over-Union (IoU) set matching at an overlap threshold of $\text{IoU} \ge 0.50$.

Each flagged legitimate account incurs an operational manual review cost of $25.00 USD. The system models the trade-off across three calibrated operating points:

  • 0.50 Balanced Triage: 93.9% precision, 62.0% recall (31 true positive rings caught, $1,325.00 total review expense).
  • 0.46 Moderate Triage: 81.4% precision, 70.0% recall (35 true positive rings caught, $2,175.00 total review expense).
  • 0.35 Broader Review: 8.5% precision, 88.0% recall (44 true positive rings caught, forensic queue).

System Architecture & Verification

ARGUS Pitch Deck: Built & Verified End-to-End

graph TD
    subgraph Data Pipeline
        GEN["data/generator.py<br/>Synthetic Accounts & Transactions"]
        GB["data/graph_builder.py<br/>IDF Edge-Weighted Multigraph"]
    end

    subgraph Detection Engine
        BASE["detection/baseline.py<br/>Louvain Community Detection & Residual Pass"]
        SCORE["Composite Risk Scorer<br/>6-Factor Heuristic Weighting"]
    end

    subgraph Evaluation
        EVAL["evaluation/metrics.py<br/>IoU Matching & FP Cost Analysis"]
    end

    subgraph Application & Interface
        API["api/main.py<br/>FastAPI Service + Lifespan Bootstrap + SlowAPI Rate Limiting"]
        UI["frontend/src<br/>React 19 + Cytoscape.js Workstation"]
    end

    GEN --> GB
    GB --> BASE
    BASE --> SCORE
    SCORE --> EVAL
    SCORE --> API
    EVAL --> API
    API --> UI
Loading

Request Flow

sequenceDiagram
    autonumber
    actor Analyst as Risk Analyst
    participant UI as React Workstation
    participant API as FastAPI Backend (api/main.py)
    participant FS as Artifact Storage (outputs/)

    Analyst->>UI: Adjusts Triage Score Cutoff (e.g., 0.50)
    UI->>API: GET /clusters?threshold=0.50&limit=100
    alt Pipeline artifacts missing
        API->>FS: Check baseline_results.json
        FS-->>API: Missing file
        API-->>UI: HTTP 503 Service Unavailable (detail message)
        UI-->>Analyst: Displays pipeline generation instruction
    else Pipeline artifacts present
        API->>FS: Read baseline_results.json
        FS-->>API: Parse community records
        API-->>UI: HTTP 200 OK (Ranked clusters, risk scores, summary metadata)
        UI-->>Analyst: Renders ranked list & metric ledger
    end

    Analyst->>UI: Selects Community #1476
    UI->>API: GET /clusters/1476/graph
    API->>FS: Query subgraph and identifier hubs
    API-->>UI: HTTP 200 OK (Cytoscape elements: nodes, hubs, edges)
    UI-->>Analyst: Renders interactive network topology specimen
Loading

Analyst Workstation Interface

The analyst workstation is designed following Swiss information design principles to maintain clarity and auditability during high-stakes reviews.

ARGUS Pitch Deck: Live Demo Overview

Workstation Interface Gallery (Click to Zoom)

Collusion Triage Desk Financial Metrics & FP Cost
Collusion Triage Desk Financial Metrics & FP Cost
Mathematical Methodology Collapsible Case Rail
Mathematical Methodology Collapsible Case Rail

Key Interface Modules

  1. Case Rail: Persistent navigation providing access to the Triage Desk, Financial Metrics Ledger, and Mathematical Methodology view. Supports full width collapsing for density on compact displays.
  2. Review Control Docket: Interactive score cutoff slider with calibrated operational presets (0.35 Broader Review, 0.50 Balanced Triage, 0.70 High Certainty) and real-time review burden calculations.
  3. Ranked Communities List: Score-ranked queue of flagged clusters displaying member counts, risk tiers, and primary edge types.
  4. Evidence Dossier & Topology Specimen: Deep inspection pane with interactive Cytoscape.js graph rendering (teal accounts, saffron identifier hubs, dotted evidentiary links), 6-bar score driver decompositions, and specific link evidence pairings.

Setup and Execution

Prerequisites

  • Python 3.11 or 3.12
  • Node.js 18+ and npm

1. Clone and Environment Setup

git clone https://github.com/prathameshfuke/argus.git
cd argus

python -m venv .venv
# On Linux/macOS:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activate

pip install -r requirements.txt

2. Frontend Installation

cd frontend
npm install
cd ..

3. Configuration

ARGUS is configured via environment variables. Create a .env file in the root directory based on .env.example:

# Server configuration
HOST=0.0.0.0
PORT=8000

# CORS settings (comma-separated origins)
ALLOWED_ORIGINS=http://localhost:5173,http://127.0.0.1:5173

# Rate limiting
RATE_LIMIT_DEFAULT=60/minute

# Startup bootstrap (auto-runs pipeline on boot if outputs are missing)
AUTO_RUN_PIPELINE_ON_STARTUP=true

# Storage directories
ARGUS_DATA_DIR=data
ARGUS_OUTPUTS_DIR=outputs

For custom frontend API hosts, create frontend/.env based on frontend/.env.example:

VITE_API_BASE_URL=http://localhost:8000

4. Running the Platform

Running the Pipeline

To manually run or regenerate all pipeline artifacts:

python run_pipeline.py --skip-gnn

Use --force to recompute existing artifacts:

python run_pipeline.py --force --skip-gnn

Starting the Backend API

uvicorn api.main:app --host 0.0.0.0 --port 8000

Note: If AUTO_RUN_PIPELINE_ON_STARTUP=true (default), the server automatically generates dataset and baseline artifacts on startup if missing.

Starting the Frontend Workstation

cd frontend
npm run dev

Open http://localhost:5173 in your browser.


Production Deployment

Frontend Production Build

cd frontend
VITE_API_BASE_URL="https://api.yourdomain.com" npm run build
npm run preview -- --host 0.0.0.0 --port 4173

Backend Production Server

ALLOWED_ORIGINS="https://workstation.yourdomain.com" uvicorn api.main:app --host 0.0.0.0 --port 8000 --workers 2

API Reference

All endpoints return JSON and enforce CORS origin validation and rate limiting.

GET /health

Platform health and pipeline readiness status.

Example Response:

{
  "status": "healthy",
  "service": "ARGUS API",
  "version": "1.0.0",
  "pipeline_ready": true
}

GET /

Service metadata and documentation links.

Example Response:

{
  "service": "ARGUS API",
  "version": "1.0.0",
  "docs": "/docs",
  "health": "/health"
}

GET /config

Display-safe mathematical parameters and score weights for UI synchronization. Exposes zero internal paths or credentials.

Example Response:

{
  "iou_match_threshold": 0.5,
  "eval_thresholds": [0.35, 0.46, 0.5],
  "fp_cost_per_account_usd": 25.0,
  "edge_weights": {
    "shared_device": 1.0,
    "shared_payment": 0.9,
    "shared_ip": 0.7,
    "shared_address": 0.5
  },
  "louvain_resolution": 1.0,
  "scorer_weights": {
    "density": 0.3,
    "avg_refund_rate": 0.25,
    "avg_promo_usage_rate": 0.2,
    "avg_transaction_velocity": 0.1,
    "young_account_fraction": 0.1,
    "edge_type_diversity": 0.05
  },
  "min_cluster_size": 3,
  "viz_high_risk_threshold": 0.48,
  "viz_medium_risk_threshold": 0.35
}

GET /clusters

Ranked list of detected communities filtered by threshold and size constraints.

Parameter Type Default Description
threshold float 0.5 Minimum composite risk score cutoff
min_size int 3 Minimum community member count
max_size int 500 Maximum community member count
limit int 100 Maximum records returned (capped at 500)

Example Response:

{
  "total": 2,
  "threshold": 0.5,
  "min_size": 3,
  "max_size": 500,
  "clusters": [
    {
      "community_id": 1476,
      "size": 11,
      "risk_score": 0.5647,
      "risk_tier": "high",
      "top_edge_types": ["shared_device", "shared_payment", "shared_ip"],
      "density": 0.5091,
      "avg_refund_rate": 0.3541,
      "avg_promo_usage_rate": 0.5512,
      "young_account_fraction": 1.0
    }
  ]
}

GET /clusters/{community_id}

Detailed cluster dossier including full member ID arrays, 6-factor features, and evidence trails.

Example Response:

{
  "community_id": 1476,
  "size": 11,
  "risk_score": 0.5647,
  "risk_tier": "high",
  "members": [2969, 10774, 10775, 10776, 10777, 10778, 10779, 10780, 10781, 10782, 10783],
  "features": {
    "size": 11,
    "internal_edges": 28,
    "density": 0.5091,
    "avg_refund_rate": 0.3541,
    "avg_promo_usage_rate": 0.5512,
    "avg_transaction_velocity": 9.94,
    "young_account_fraction": 1.0,
    "edge_type_diversity": 4
  },
  "evidence": [
    {
      "account_a": 2969,
      "account_b": 10774,
      "shared_identifiers": ["shared_device", "shared_ip"],
      "combined_weight": 2.1287
    }
  ]
}

GET /clusters/{community_id}/graph

Cytoscape.js graph elements formatted for client-side graph rendering.

Example Response:

{
  "community_id": 1476,
  "elements": [
    {
      "data": {"id": "acc_2969", "label": "#2969", "type": "account"},
      "classes": "account-node"
    },
    {
      "data": {"id": "hub_2969_10774_shared_device", "label": "DEVICE", "type": "identifier", "ident_type": "shared_device"},
      "classes": "identifier-node"
    },
    {
      "data": {"id": "e_2969_hub_2969_10774_shared_device", "source": "acc_2969", "target": "hub_2969_10774_shared_device", "weight": 2.1287, "edge_type": "account_link"},
      "classes": "account-link"
    }
  ]
}

GET /metrics

Ring-level precision, recall, and F1 at evaluated operating points.

Example Response:

{
  "dataset": "outputs/baseline_results.json",
  "model": "baseline",
  "total_predicted_clusters": 2361,
  "total_ground_truth_rings": 50,
  "iou_threshold": 0.5,
  "thresholds": {
    "0.35": {
      "num_flagged_clusters": 519,
      "precision": 0.0848,
      "recall": 0.8800,
      "f1": 0.1547,
      "true_positives": 44,
      "false_positives": 475,
      "false_negatives": 6
    },
    "0.46": {
      "num_flagged_clusters": 43,
      "precision": 0.8140,
      "recall": 0.7000,
      "f1": 0.7527,
      "true_positives": 35,
      "false_positives": 8,
      "false_negatives": 15
    },
    "0.50": {
      "num_flagged_clusters": 33,
      "precision": 0.9394,
      "recall": 0.6200,
      "f1": 0.7470,
      "true_positives": 31,
      "false_positives": 2,
      "false_negatives": 19
    }
  }
}

GET /fp-cost

Three-tier operational review cost table based on $25.00 USD manual review expense per account.

Example Response:

[
  {
    "threshold": "0.35",
    "flagged_clusters": "519",
    "precision": "0.0848",
    "recall": "0.8800",
    "f1": "0.1547",
    "true_positives": "44",
    "false_positives": "475",
    "false_negatives": "6",
    "legitimate_accounts_flagged": "1562",
    "estimated_fp_cost_usd": "39050.0"
  },
  {
    "threshold": "0.46",
    "flagged_clusters": "43",
    "precision": "0.8140",
    "recall": "0.7000",
    "f1": "0.7527",
    "true_positives": "35",
    "false_positives": "8",
    "false_negatives": "15",
    "legitimate_accounts_flagged": "87",
    "estimated_fp_cost_usd": "2175.0"
  },
  {
    "threshold": "0.50",
    "flagged_clusters": "33",
    "precision": "0.9394",
    "recall": "0.6200",
    "f1": "0.7470",
    "true_positives": "31",
    "false_positives": "2",
    "false_negatives": "19",
    "legitimate_accounts_flagged": "53",
    "estimated_fp_cost_usd": "1325.0"
  }
]

GET /dataset-stats

Statistical population summary for current graph and transaction artifacts.

Example Response:

{
  "total_accounts": 50000,
  "fraud_ring_accounts": 587,
  "fraud_ring_pct": 1.17,
  "total_rings": 50,
  "total_transactions": 2508209,
  "total_edges": 39269,
  "total_communities": 2361,
  "dataset_label": "Synthetic (injected fraud rings)"
}

Automated Testing

ARGUS includes a comprehensive automated test suite with zero mocking of core graph computations or evaluation routines.

python -m pytest tests/ -v

The test suite validates:

  • Set Mathematics (TestMetricsHelpers): Exact IoU calculation, disjoint sets, partial overlaps, and empty set edge cases.
  • Graph Construction (TestGraphBuilder): Real NetworkX multigraph assembly, edge weight calculations, connected component isolation, and attribute assignment.
  • Risk Scoring (TestRiskScorer): Value boundary invariants, high-risk vs low-risk profile discrimination, and weight sum validation.
  • Data Generation (TestDataGenerator): Realistic attribute distributions and positive domain constraints.
  • Evaluation Harness (TestEvaluation): IoU ring matching, true positive pairing, and false positive accounting.
  • API Integration (TestAPIEndpoints): Live ASGI tests for all endpoints (/health, /config, /clusters, /metrics, /fp-cost, /dataset-stats), CORS allowed and rejected header assertions, and fail-loud HTTP 503 behavior on missing pipeline files.

Known Limitations

  1. Synthetic Data Calibration: The baseline heuristic scorer is calibrated against synthetic populations where fraud rings exhibit higher refund rates and identifier sharing. When applying to live production traffic, threshold sweeps (scripts/check_scores.py) must be re-run against historical labeled chargebacks.
  2. Evidentiary Edge Pruning & Precision Tradeoff: Strategy C2 implements evidentiary pruning on single weak identifiers (isolated address/IP links) and multi-identifier exponential weighting ($1.5^{|T|-1}$), achieving 62.0% recall and 93.9% precision at threshold 0.50 (31 true positive rings caught, only $1,325.00 review expense). Extremely loose rings sharing only a single weak identifier are intentionally pruned to prevent giant component over-merging.
  3. Defense-Only Scope: ARGUS intentionally does not implement automated fund freezes or merchant de-platforming hooks. It is architected specifically as an explainable triage interface for human risk analysts.
  4. Optional GNN Module: The GraphSAGE model (detection/gnn_model.py) is an experimental extension requiring PyTorch and PyTorch Geometric (requirements-gnn.txt). It is not active in the default production deployment.

About

Graph-Based Collusion Detection for Merchant Fraud Prevention (ARGUS = Abuse-Ring Graph-based User Sentinel)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages