Build your own fraud detection on Cozystack: a legacy card switch, GitOps, an LLM and managed services A team at Aenix published a hands-on Cozystack workshop that builds a real-time card-fraud detection system around a legacy payment switch, wiring Kafka, Redis, PostgreSQL and a locally hosted language model into a GitOps-managed cluster. The setup keeps the switch's 400-millisecond stand-in processing as a fallback, journals every decision for reconciliation, and keeps card data and the LLM inside the cluster, then stress-tests it with 10x traffic, a crashed primary database and a live VM migration. The full commands and files are in the public aenix-org/cozystack-workshop repository. This isn’t a case study. It’s a workshop packed into a blog post, and you can run it on your own Cozystack installation to see how the platform behaves and where it might fit into your projects. In about two hours, without leaving the terminal, we’ll build a system that catches card fraud in real time, and then we’ll give it a truly bad day: ten times the usual traffic, a crashed primary database server and a live migration of a virtual machine with payments flowing through it. Everything runs on Cozystack https://cozystack.io/ , an open-source platform for building clouds and a CNCF Incubating project. Cozystack turns your servers into a ready-made cloud with managed Kubernetes, databases, message brokers, GPU as a Service and more. One note before we start: the fraud detection here is a teaching example, not a product. Its job is to give the story a plot. What we’re really after is a close look at the platform and a feel for how it would fit your own work. When you pay by card in a store, the terminal asks the bank that issued the card whether the payment can go through. The program that answers is called a switch. In many banks it’s a legacy application that has sat on the same virtual machine for years, and nobody wants to touch it: if it ain’t broke, don’t fix it. Ours is no exception. It approves every payment under $5,000, which makes life very easy for fraudsters. We’re not going to rewrite the switch, of course. We’ll build a payment check around it instead, roughly like this: The switch stays as it is; everything else is built around it The switch sends every payment to Kafka. The scoring service scorer in the code checks it against the card’s recent payment history, which lives in Redis, and posts its decision back to Kafka. The switch writes every decision to a journal, no matter who made it, and the cases service moves each journal entry into PostgreSQL, from where it shows up on the fraud team’s dashboard. On top of all that, a language model explains in plain words why a payment was declined. Front-line support needs this: customers will call the bank to ask why their card didn’t work, and someone has to tell them. The design rests on three properties. First, the switch never waits longer than it can afford. If the scorer has not answered within 400 milliseconds, the switch decides on its own, using the logic hard-coded into it. Banks call this stand-in processing, and it’s the difference between a slow fraud check and a processing outage. A slow check lets fraudulent payments slip through at peak hours. An outage lets nothing through at all, honest customers buying groceries included. Second, the journal gets written no matter who made the decision, so you can always compare what the switch told the terminals with what ended up in the database. The two have to match. Third, card data stays inside our cluster. Even the language model that writes explanations for support staff runs right next to the other services and never calls out to the internet. The full guide, with every command and file, is in the public aenix-org/cozystack-workshop https://github.com/aenix-org/cozystack-workshop repository, in the fraud/ https://github.com/aenix-org/cozystack-workshop/tree/master/fraud folder. It is available in English https://github.com/aenix-org/cozystack-workshop/blob/master/fraud/README.md and in Russian https://github.com/aenix-org/cozystack-workshop/blob/master/fraud/README.ru.md . The same repository has materials from our other workshops and labs: en/laptop/ en/laptop/labs/ fraud/app/ Along the way we’ll lean on the Cozystack documentation https://cozystack.io/docs/v1.7/ . All commands in this post run from the fraud/ folder of the cloned repository. In the terminal recordings you’ll see ~/workshop instead; that’s what the folder was called on the environment I recorded on. This post grew out of a workshop we’ve already run in several cities, where our team prepared everything in advance. Each participant got a ready tenant with the legacy switch VM already running, a Kubernetes cluster, a GitLab account and a login on a bastion VM with all the tools installed virtctl, kubectl and so on . Here you’ll do that prep yourself, on your own Cozystack cluster and your own laptop. It takes about half an hour. You’ll need Cozystack 1.7 or newer and platform admin rights, because we’re going to create a tenant. If you don’t have Cozystack yet, start with the getting started guide https://cozystack.io/docs/v1.7/getting-started/ . The cluster needs the replicated StorageClass and the ubuntu-24.04 image in the VM image catalog; a standard Cozystack install has both. On your computer you need kubectl , virtctl , git and curl . I gave the tenant a generous quota of 160 vCPU and 96 GiB of memory. Even at peak, the whole system uses about 10 GiB of RAM and around 20 vCPU. All the YAML manifests for setup live in fraud/instructor/ https://github.com/aenix-org/cozystack-workshop/tree/master/fraud/instructor . They use the placeholder dallasXX instead of a tenant name, so first pick a name and make a copy of the manifests with the placeholder replaced. In the examples the tenant is called fraud1 , and by Cozystack convention its namespace is tenant-fraud1 : git clone https://github.com/aenix-org/cozystack-workshop.git cd cozystack-workshop/fraud export NAME=fraud1 T=tenant-fraud1 mkdir -p ~/fraud-env for f in instructor/ .yaml; do sed "s/tenant-dallasXX/$T/g; s/dallasXX/$NAME/g" "$f" ~/fraud-env/$ basename "$f" done The tenant is created inside the root tenant, tenant-root . It won’t need its own monitoring in this guide, so we switch that off to save memory. You can do it in the Cozystack dashboard or, as the admin, with a single command: kubectl apply -f - <