Connic

Kafka Fraud Detector

Score transactions for fraud in real-time on Kafka streams. Uses velocity analysis, geo-anomaly detection, and pattern matching per customer.

securityadvancedKafkaView on GitHub
connic init my-project --templates=kafka-fraud-detector

Overview

Consumes transactions from a Kafka topic and scores each for fraud risk using velocity analysis, geo-anomaly detection, and knowledge base pattern matching. Conditional tools restrict admin_override access based on context. Concurrency control queues transactions by customer_id to prevent race conditions. High-risk alerts are formatted by a tool agent and published to a Kafka outbound topic.

Use cases

Payment fraud detection

Score every transaction in real-time for fraud signals like impossible travel, velocity spikes, and known patterns.

Risk-based routing

Route transactions to different review queues based on risk level: auto-approve, flag, hold, or block.

Pattern learning

Store novel fraud patterns in the knowledge base so detection improves over time.

Architecture

Kafka (transactions)
fraud-scorer
Knowledge Base
fraud-escalator
Kafka (alerts)

Scaffolded project structure

Running connic init my-project --templates=kafka-fraud-detector creates this file tree.

kafka-fraud-detector/
  agents/
    fraud-scorer.yaml
    fraud-escalator.yaml
  tools/
    fraud_tools.py
  middleware/
    fraud-scorer.py
  schemas/
    fraud-assessment.json
  requirements.txt
  README.md

Get started

Install the template, create a Connic project, and deploy. Choose Git (automatic on push) or CLI (works with any provider).

Prerequisites

  • Python 3.10+
  • A Connic account (create a project first)
  • API key for your LLM provider (e.g. Gemini, OpenAI) to add in project variables
Create project
1

Install and scaffold

Install the SDK and create a project from this template.

terminal
pip install connic-composer-sdk
connic init my-project --templates=kafka-fraud-detector

Then cd my-project

2

Deploy

Pick your deployment method. Git auto-deploys on push; CLI works with GitLab, Bitbucket, or no Git.

Git integration

  1. In Connic: Project Settings → Git Repository, connect your GitHub repo
  2. Settings → Environments: map branch (e.g. main) to Production
  3. Push your scaffolded project to that repo
terminal
git add .
git commit -m "Add Kafka Fraud Detector template"
git push origin main

CLI deploy

  1. In Connic: Project Settings → CLI, create an API key and copy project ID
  2. Run connic login in your project folder
  3. connic test to try with hot-reload, or connic deploy for production
terminal
connic login
connic test    # Ephemeral dev env with hot-reload
connic deploy # Deploy to production
3

Connect and configure

Add a Kafka inbound connector for the transactions topic and a Kafka outbound connector for fraud alerts. Configure bootstrap servers and optional SASL authentication. Add your LLM provider API key in Project Settings → LLM Provider API Keys.

Template source

Browse the full template, contribute improvements, or fork for your own use.

connic-org/connic-awesome-agents/tree/main/kafka-fraud-detector