# 230723pp第六组 **Repository Path**: APIJSON/real-time-fraud-risk ## Basic Information - **Project Name**: 230723pp第六组 - **Description**: 基于 Kafka、Spark Streaming、MySQL、APIJSON 和 ECharts 构建的实时金融交易欺诈风险平台。本仓库为副本,请给原仓库右上角点亮 ⭐️ Star - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: https://gitee.com/yi-huaimin/real-time-fraud-risk - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-08-09 - **Last Updated**: 2026-08-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Real-time Fraud Risk Platform Course-cluster implementation of real-time financial fraud detection. ## Verified architecture | Component | Deployment | |---|---| | Kafka 2.5.0 | Three brokers on `niit-master`, `niit-slave1`, and `niit-slave2`, all on port 9092 | | Topic | `bank_transaction`, 3 partitions, replication factor 3, `min.insync.replicas=2` | | Spark Streaming 2.4.6 | One Direct-mode application on `spark://niit-master:7077`, Scala 2.11, 3-second batches | | HDFS | `hdfs://niit-master:9000/checkpoint/fraud` and `/warehouse/realrisk` | | Hive 2.3.7 | Five external ORC tables with Snappy compression, queried through HiveServer2/Beeline | | MySQL 5.7.16 | Transaction detail, accumulated channel statistics, alerts, window statistics, and blacklist | | API | Spring Boot and APIJSON 8.2 on port 18080 | | Dashboard | ECharts 5.6, overview, trend, channels, heatmap, R01-R04, regions, and alerts | The Streaming artifact targets Java 8, Scala 2.11, and Spark 2.4.6. The API is built separately because it uses a newer Spring runtime. ## Cluster nodes | Host | IP | Roles | |---|---|---| | `niit-master` | `192.168.10.102` | HDFS NameNode, Spark Master, Kafka broker, MySQL, HiveServer2, API | | `niit-slave1` | `192.168.10.103` | HDFS DataNode, Spark Worker, Kafka broker, YARN ResourceManager/NodeManager | | `niit-slave2` | `192.168.10.104` | HDFS DataNode, Spark Worker, Kafka broker, YARN NodeManager | ## Build ```powershell $env:JAVA_HOME='C:\Program Files\Java\jdk1.8.0_144' mvn -f streaming-pom.xml -DskipTests clean package $env:JAVA_HOME='C:\Program Files\Java\jdk-21' mvn -f api-pom.xml -DskipTests clean package ``` ## Deployment The VM script expects passwordless SSH and pre-created root-only credential files on the master: - `/opt/realrisk/conf/app.env` (`0600`) - `/opt/realrisk/conf/mysql-admin.cnf` (`0600`) It never stores database passwords in Git. It preserves shared ZooKeeper, Hadoop, Hive, and Spark services. ```powershell powershell -ExecutionPolicy Bypass -File scripts\deploy-vm.ps1 -TransactionCount 5000 ``` The formal Producer always uses a random 50-500 ms delay. Do not use the deployment script to resume a completed formal run because it intentionally recreates project data. Post-processing recovery procedures are in [docs/CLUSTER_RUNBOOK.md](docs/CLUSTER_RUNBOOK.md). Dashboard: `http://192.168.10.102:18080/` Stop only project-owned API, Streaming, and Kafka processes: ```powershell powershell -ExecutionPolicy Bypass -File scripts\stop-vm.ps1 ``` The stop script does not stop or power off shared cluster services. ## Formal result The 2026-07-28 formal run produced 5,000 successful messages with zero failures in 1,463,537 ms. MySQL contains 5,000 transactions, channel totals of 5,000, and 68 alerts. See [docs/VM_CLUSTER_ACCEPTANCE.md](docs/VM_CLUSTER_ACCEPTANCE.md) and `evidence/vm-cluster/`. # Vue 3 Dashboard The production dashboard is implemented in `frontend/` with Vue 3, Vite, TypeScript, Vue Router, Pinia, Axios, and ECharts 5.6. All browser assets are bundled locally and remain usable when the VM has no Internet access. ```powershell cd frontend npm ci npm run type-check npm run dev # http://localhost:5173, /api proxies to the master VM npm run build ``` IDEA shared configurations include `Vue Dev`, `Vue Build`, `Financial Risk-Vue Development`, and `Financial Risk-Deploy Vue Page`. The deployment configuration builds the frontend and API, backs up the remote JAR, restarts only the project API, validates the formal `5000 / 5000 / 68` counts, and restores the backup automatically if validation fails. The previous page is retained at `/legacy.html`. ## IDEA green run Open `C:\Users\86132\fraud-risk-deployment-20260727` in IntelliJ IDEA and select `Financial Risk - Start and Open Dashboard` (the shared Chinese-named Application configuration). Press the green Run button. The Java launcher invokes only `scripts/start-existing-vm.ps1`, which powers on missing VMs, restores missing services, validates the formal `5000 / 5000 / 68` data, and opens `http://192.168.10.102:18080/`. The `Financial Risk - Stop Project Application Only` configuration passes `--stop` and stops only realrisk-owned API/legacy Streaming PIDs. Full formal redeployment is available solely through an explicit command-line `--deploy`; no shared IDEA configuration uses it. For frontend and backend development together, select the shared Application configuration `Financial Risk - Frontend/Backend One-click Start` (Chinese name in IDEA). It restores the existing remote backend, starts Vite on port 5173, and opens a new browser window. IDEA's Stop button terminates only the local Vite development process; shared VM services and formal data remain intact.