# vishalmysore/frauddetectionagentinjava architecture

> Architecture diagram of the GitHub repository vishalmysore/frauddetectionagentinjava, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vishalmysore/frauddetectionagentinjava
- Repository: https://github.com/vishalmysore/frauddetectionagentinjava

## Overview

1. This repository is a small, plain-Java demo of an agentic fraud-detection workflow built on top of the Tools4AI framework. The core architectural idea is “language as code”: natural-language requests are mapped to Java action methods and strongly typed domain objects.

2. The top-level runtime entry point is `FraudDetectionExample`. It is the bootstrap class that wires together the Tools4AI processor, loads rules/configuration, and invokes fraud-related actions from user-style prompts rather than from a REST API or CLI parser.

3. The main execution boundary is the `actions` package. These classes are the business-facing agent surface:
   - `TransactionAnalysisAction` handles transaction-level fraud checks.
   - `FraudDetectionAction` appears to be the orchestration hub for broader fraud assessment.
   - `InvestigationAction` coordinates multi-step investigations.
   - `AccountManagementAction` handles account control actions such as freezing or managing accounts.
   - `TransactionHistory` provides access to historical transaction retrieval/pattern inspection.
   These are the methods that Tools4AI discovers and invokes based on intent descriptions.

4. The `domain` package holds the typed data model passed between actions and the AI mapping layer. The key entities are `Transaction`, `CustomerProfile`, `FraudAlert`, and `FraudRules`. These objects are the contract between natural-language input, rule transformation, and deterministic Java business logic.

5. The data flow is centered on intent-to-POJO mapping. A natural-language request such as “analyze transaction of $25000 from Oakhaven at 2am” is interpreted by Tools4AI, which extracts the relevant fields and populates a `Transaction` object. The action method then runs standard Java logic on that object. This is the main architectural pattern in the repo.

6. Rules are externalized instead of hard-coded. `src/main/resources/fruaddetectionrules.txt` stores human-readable fraud policy text, and `utils/RuleLoader` transforms that text into the `FraudRules` domain object. This creates a second data path: unstructured policy text in, validated typed configuration out, then consumed by action logic.

7. The `callback` package contains `FraudMonitoringCallback`, which suggests an event/approval boundary for monitoring or human-in-the-loop intervention. In the repo’s model, callbacks are the place where execution can be observed, paused, or audited rather than immediately completed.

8. The `tools4ai.properties` resource is the integration/configuration boundary to the external AI layer. This is where model/runtime credentials and framework settings live, so the repo’s behavior depends on runtime configuration rather than compile-time wiring. The architecture therefore has a small but important external dependency on an LLM-backed processing service.

9. The `debug` package contains `JsonUtilsRepro`, which looks like a support class for reproducing or inspecting JSON transformation behavior. It is not part of the main fraud flow, but it indicates the project relies on structured serialization/deserialization during AI-to-Java mapping.

10. `FraudRulesTest` in `src/test` provides the main automated verification boundary. Given the project’s design, testing likely focuses on ensuring rules are correctly transformed and interpreted, rather than on HTTP or persistence behavior. That matches the repo’s emphasis on deterministic Java execution after AI-based input interpretation.

11. The architectural boundaries are therefore:
   - Natural language and AI interpretation on the outside.
   - Typed Java domain objects in the middle.
   - Deterministic fraud logic inside the action classes.
   - Externalized rules/configuration in resources.
   This makes the system easier to diagram as an intent-processing pipeline rather than a conventional service stack.

12. In short, the repository is not a full fraud platform; it is a demonstration of an AI-orchestrated fraud engine. The important diagram should show a user prompt entering Tools4AI, mapped into actions and domain objects, with rules loaded from resources and results emitted as alerts, history, or account actions.

Main entry points: [`src/main/java/io/github/vishalmysore/fraud/actions/FraudDetectionAction.java`](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/FraudDetectionAction.java) (Fraud Engine), [`src/main/java/io/github/vishalmysore/fraud/utils/RuleLoader.java`](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/utils/RuleLoader.java) (Rule Loader), [`src/main/java/io/github/vishalmysore/fraud/actions/TransactionAnalysisAction.java`](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/TransactionAnalysisAction.java) (Txn Analysis), [`src/main/java/io/github/vishalmysore/fraud/domain/Transaction.java`](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/Transaction.java) (Transaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_fraud_example["Example<br/>bootstrap"]
end

subgraph group_actions["Actions"]
  node_txn_action["Txn Analysis<br/>action"]
  node_fraud_action["Fraud Engine<br/>action"]
  node_invest_action["Investigation<br/>action"]
  node_account_action["Account Mgmt<br/>action"]
  node_history_action["History<br/>action"]
end

subgraph group_domain["Domain"]
  node_transaction["Transaction<br/>domain object<br/>[Transaction.java]"]
  node_customer["Customer<br/>domain object"]
  node_alert["Alert<br/>domain object<br/>[FraudAlert.java]"]
  node_rules["Rules<br/>domain object<br/>[FraudRules.java]"]
end

subgraph group_infra["Infra"]
  node_tools4ai["Tools4AI<br/>framework"]
  node_rule_loader["Rule Loader<br/>[RuleLoader.java]"]
  node_rules_text["Rule Text<br/>resource"]
  node_callback["Monitoring<br/>callback"]
  node_tools_props["Config<br/>resource"]
end

subgraph group_support["Support"]
  node_json_debug["JSON Debug<br/>support"]
end

subgraph group_tests["Tests"]
  node_fraud_test["Rules Test"]
end

node_fraud_example -->|"boots"| node_tools4ai
node_tools_props -->|"configures"| node_tools4ai
node_fraud_example -->|"loads"| node_rule_loader
node_rule_loader -->|"reads"| node_rules_text
node_rule_loader -->|"builds"| node_rules
node_tools4ai -->|"invokes"| node_txn_action
node_tools4ai -->|"invokes"| node_fraud_action
node_tools4ai -->|"invokes"| node_invest_action
node_tools4ai -->|"invokes"| node_account_action
node_tools4ai -->|"invokes"| node_history_action
node_txn_action -->|"uses"| node_transaction
node_txn_action -->|"uses"| node_customer
node_fraud_action -->|"applies"| node_rules
node_fraud_action -->|"emits"| node_alert
node_invest_action -->|"escalates"| node_alert
node_account_action -->|"triggers"| node_alert
node_history_action -->|"inspects"| node_transaction
node_callback -.->|"observes"| node_fraud_action
node_json_debug -.->|"repro"| node_transaction
node_fraud_test -->|"verifies"| node_rule_loader
node_fraud_test -->|"asserts"| node_rules

click node_fraud_example "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/FraudDetectionExample.java"
click node_txn_action "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/TransactionAnalysisAction.java"
click node_fraud_action "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/FraudDetectionAction.java"
click node_invest_action "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/InvestigationAction.java"
click node_account_action "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/AccountManagementAction.java"
click node_history_action "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/TransactionHistory.java"
click node_transaction "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/Transaction.java"
click node_customer "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/CustomerProfile.java"
click node_alert "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/FraudAlert.java"
click node_rules "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/FraudRules.java"
click node_rule_loader "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/utils/RuleLoader.java"
click node_rules_text "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/resources/fruaddetectionrules.txt"
click node_callback "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/callback/FraudMonitoringCallback.java"
click node_tools_props "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/resources/io/github/vishalmysore/fraud/tools4ai.properties"
click node_json_debug "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/debug/JsonUtilsRepro.java"
click node_fraud_test "https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/test/java/io/github/vishalmysore/fraud/FraudRulesTest.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fraud_example toneBlue
class node_txn_action,node_fraud_action,node_invest_action,node_account_action,node_history_action toneAmber
class node_transaction,node_customer,node_alert,node_rules toneMint
class node_tools4ai,node_rule_loader,node_rules_text,node_callback,node_tools_props toneRose
class node_json_debug toneIndigo
class node_fraud_test toneTeal
```

## Components

### Runtime

Entry and orchestration

- [Example](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/FraudDetectionExample.java): bootstrap · Top-level runtime entry point · `src/main/java/io/github/vishalmysore/fraud/FraudDetectionExample.java`

### Actions

Agent-facing business operations

- [Txn Analysis](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/TransactionAnalysisAction.java): action · Transaction-level fraud checks · `src/main/java/io/github/vishalmysore/fraud/actions/TransactionAnalysisAction.java`
- [Fraud Engine](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/FraudDetectionAction.java): action · Broader fraud assessment orchestration · `src/main/java/io/github/vishalmysore/fraud/actions/FraudDetectionAction.java`
- [Investigation](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/InvestigationAction.java): action · Multi-step investigation coordination · `src/main/java/io/github/vishalmysore/fraud/actions/InvestigationAction.java`
- [Account Mgmt](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/AccountManagementAction.java): action · Account control actions · `src/main/java/io/github/vishalmysore/fraud/actions/AccountManagementAction.java`
- [History](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/actions/TransactionHistory.java): action · Transaction history retrieval and inspection · `src/main/java/io/github/vishalmysore/fraud/actions/TransactionHistory.java`

### Domain

Typed fraud model

- [Transaction](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/Transaction.java): domain object · Transaction input and analysis contract · `src/main/java/io/github/vishalmysore/fraud/domain/Transaction.java`
- [Customer](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/CustomerProfile.java): domain object · Customer profile context · `src/main/java/io/github/vishalmysore/fraud/domain/CustomerProfile.java`
- [Alert](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/FraudAlert.java): domain object · Fraud alert output and signal · `src/main/java/io/github/vishalmysore/fraud/domain/FraudAlert.java`
- [Rules](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/domain/FraudRules.java): domain object · Typed fraud policy model · `src/main/java/io/github/vishalmysore/fraud/domain/FraudRules.java`

### Infra

Rules, callbacks, framework config

- **Tools4AI**: framework · External intent-to-method mapping runtime
- [Rule Loader](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/utils/RuleLoader.java): utility · Transforms rule text into FraudRules · `src/main/java/io/github/vishalmysore/fraud/utils/RuleLoader.java`
- [Rule Text](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/resources/fruaddetectionrules.txt): resource · Human-readable fraud policy source · `src/main/resources/fruaddetectionrules.txt`
- [Monitoring](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/callback/FraudMonitoringCallback.java): callback · Human-in-the-loop or audit boundary · `src/main/java/io/github/vishalmysore/fraud/callback/FraudMonitoringCallback.java`
- [Config](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/resources/io/github/vishalmysore/fraud/tools4ai.properties): resource · Framework and runtime settings · `src/main/resources/io/github/vishalmysore/fraud/tools4ai.properties`

### Support

Debug and serialization

- [JSON Debug](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/main/java/io/github/vishalmysore/fraud/debug/JsonUtilsRepro.java): support · Serialization and repro helper · `src/main/java/io/github/vishalmysore/fraud/debug/JsonUtilsRepro.java`

### Tests

Verification

- [Rules Test](https://github.com/vishalmysore/frauddetectionagentinjava/blob/main/src/test/java/io/github/vishalmysore/fraud/FraudRulesTest.java): test · Verifies rule transformation behavior · `src/test/java/io/github/vishalmysore/fraud/FraudRulesTest.java`

## Connections

- Example → Tools4AI: boots · Starts the AI-driven processing runtime
- Config → Tools4AI: configures · Provides framework/runtime settings
- Example → Rule Loader: loads · Initializes external fraud rules
- Rule Loader → Rule Text: reads · Consumes human-readable policy text
- Rule Loader → Rules: builds · Produces typed fraud rules
- Tools4AI → Txn Analysis: invokes · Maps intent to transaction checks
- Tools4AI → Fraud Engine: invokes · Maps intent to broad assessment actions
- Tools4AI → Investigation: invokes · Maps intent to investigation flows
- Tools4AI → Account Mgmt: invokes · Maps intent to account controls
- Tools4AI → History: invokes · Maps intent to history retrieval
- Txn Analysis → Transaction: uses · Analyzes typed transaction input
- Txn Analysis → Customer: uses · Adds customer context to checks
- Fraud Engine → Rules: applies · Evaluates transaction behavior against rules
- Fraud Engine → Alert: emits · Produces fraud alerts
- Investigation → Alert: escalates · Converts suspicious cases into investigations
- Account Mgmt → Alert: triggers · May freeze or manage accounts based on findings
- History → Transaction: inspects · Retrieves prior transactions for pattern checks
- Monitoring → Fraud Engine: observes · Monitoring or intervention boundary
- JSON Debug → Transaction: repro · Helps inspect JSON mapping for domain objects
- Rules Test → Rule Loader: verifies · Checks rule transformation behavior
- Rules Test → Rules: asserts · Validates resulting typed rules
