# neo4j-graph-examples/fraud-detection architecture

> Architecture diagram of the GitHub repository neo4j-graph-examples/fraud-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/neo4j-graph-examples/fraud-detection
- Repository: https://github.com/neo4j-graph-examples/fraud-detection

## Overview

##### Project Type and Purpose
- This is an open-source demo/data-driven project (“fraud-detection”) showcasing how to detect fraud on the Paysim financial dataset using Neo4j Graph Data Science (GDS) and Neo4j Bloom. It provides data dumps, Cypher scripts for building and analyzing the graph, a Bloom perspective for visualization, and multi-language client examples.

##### Main Components
A. Data Assets
- `data/` – Paysim dataset dumps (`.dump`) for Neo4j
- (Optionally) CSV/flat files loaded via `scripts/`
B. Ingestion & ETL
- `scripts/*.cypher` – Cypher scripts to:
– Load raw data (e.g. `loadWCCNamedGraph.cypher`)
– Create named graphs in GDS
– Run algorithms (PageRank, WCC, Louvain, similarity)
– Write results back to the database
- Neo4j‐admin load (via `README.adoc` instructions)
C. Graph Database
- Neo4j DBMS with GDS plugin (v3.5 & v4.x compatible)
- Graph model (nodes: Client, Merchant, Transaction; relationships: PERFORMED, TO, etc.)
- In-memory named graphs & projected graphs managed by GDS
D. Analytics Engine
- GDS procedures invoked by Cypher scripts
- Produces fraud scores, community detection, path analyses
E. Visualization & UX
- Neo4j Bloom perspective: `bloom/fraud-detection.bloom-perspective`
- Neo4j Browser guide: `documentation/fraud-detection.neo4j-browser-guide`
- Model & example images: `documentation/img/model.svg`, `documentation/img/example.png`
F. Client Applications
- `code/javascript/example.js`
- `code/java/Example.java`
- `code/python/example.py`
- `code/csharp/Example.cs`
- `code/go/example.go`
– Each uses official Neo4j drivers over Bolt/HTTP to run sample queries
G. Documentation
- `README.adoc` – project overview, setup, usage
- `documentation/` – detailed AsciiDoc guides, images, helper scripts

##### Relationships & Data Flow
1. Data Load:
- Paysim dump or CSV ➔ ingest via Neo4j‐admin or `scripts/*.cypher`
2. Graph Construction:
- Cypher ingestion scripts create the core graph schema in Neo4j
3. Analytics Pipeline:
- `CALL gds.*` procedures ➔ in-memory graphs ➔ results written back as node/relationship properties or named graphs
4. Access & Visualization:
- Neo4j Bloom & Browser connect to DB via Bolt/HTTP for exploration
- Client apps query the DB for example use cases

##### Architectural Patterns & Design Principles
- ETL pipeline separating data ingestion, processing, and storage
- Modular Cypher scripts organized by algorithm type
- Layered architecture: storage (Neo4j), analytics (GDS), presentation (Bloom/clients)
- Polyglot client support demonstrating driver‐agnostic design

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources
    subgraph "Data Sources"
        DA1["Paysim Neo4j Dumps"]:::data
        DA2["CSV/Flat Files (Optional)"]:::data
    end

    subgraph "Paysim Neo4j Dumps"
        D1["fraud-detection-35.dump"]:::data
        D2["fraud-detection-40.dump"]:::data
        D3["fraud-detection-43.dump"]:::data
        D4["fraud-detection-50.dump"]:::data
    end

    %% ETL & GDS Analytics
    subgraph "ETL & GDS Analytics"
        SC["scripts/"]:::etl
        LWG["loadWCCNamedGraph.cypher"]:::etl
        PP["secondPartyFraudPageRankStream.cypher"]:::etl
        LO["louvainStream.cypher"]:::etl
        OS["onePairSimilarity.cypher"]:::etl
    end

    %% Neo4j DB & GDS
    subgraph "Neo4j Database & Analytics Engine"
        DB["Neo4j DBMS (with GDS)"]:::db
        GDS["GDS Procedures"]:::db
    end

    %% Visualization & UX
    subgraph "Visualization & UX"
        Bloom["Bloom Perspective"]:::viz
        Browser["Neo4j Browser Guide"]:::viz
    end

    %% Client Applications
    subgraph "Client Applications"
        JS["JavaScript Example"]:::client
        JAVA["Java Example"]:::client
        PY["Python Example"]:::client
        CS["C# Example"]:::client
        GO["Go Example"]:::client
        GQL["GraphQL Example"]:::client
    end

    %% Documentation
    subgraph "Documentation"
        RM["README.adoc"]:::doc
        AD["fraud-detection.adoc"]:::doc
        DSL["documentation/scripts/"]:::doc
        IMG["documentation/img/"]:::doc
        BG["documentation/fraud-detection.neo4j-browser-guide"]:::doc
    end

    %% Connections
    DA1 -->|neo4j-admin load| SC
    DA2 -->|LOAD CSV / APOC| SC
    SC -->|CREATE / MERGE graph| DB
    DB -->|CALL gds.*| GDS
    GDS -->|WRITE results to graph| DB
    DB -->|Bolt/HTTP| Bloom
    DB -->|Bolt/HTTP| Browser
    DB -->|Bolt driver| JS
    DB -->|Bolt driver| JAVA
    DB -->|Bolt driver| PY
    DB -->|Bolt driver| CS
    DB -->|Bolt driver| GO
    DB -->|Bolt driver| GQL

    %% Click Events
    click DA1 "https://github.com/neo4j-graph-examples/fraud-detection/tree/main/data/"
    click D1 "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/data/fraud-detection-35.dump"
    click D2 "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/data/fraud-detection-40.dump"
    click D3 "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/data/fraud-detection-43.dump"
    click D4 "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/data/fraud-detection-50.dump"
    click SC "https://github.com/neo4j-graph-examples/fraud-detection/tree/main/scripts/"
    click LWG "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/scripts/loadWCCNamedGraph.cypher"
    click PP "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/scripts/secondPartyFraudPageRankStream.cypher"
    click LO "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/scripts/louvainStream.cypher"
    click OS "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/scripts/onePairSimilarity.cypher"
    click Bloom "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/bloom/fraud-detection.bloom-perspective"
    click Browser "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/documentation/fraud-detection.neo4j-browser-guide"
    click RM "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/README.adoc"
    click AD "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/documentation/fraud-detection.adoc"
    click DSL "https://github.com/neo4j-graph-examples/fraud-detection/tree/main/documentation/scripts/"
    click IMG "https://github.com/neo4j-graph-examples/fraud-detection/tree/main/documentation/img/"
    click JAVA "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/java/Example.java"
    click JS "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/javascript/example.js"
    click PY "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/python/example.py"
    click CS "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/csharp/Example.cs"
    click GO "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/go/example.go"
    click GQL "https://github.com/neo4j-graph-examples/fraud-detection/blob/main/code/graphql/example.js"

    %% Styles
    classDef data fill:#cce5ff,stroke:#004085,color:#004085
    classDef etl fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef viz fill:#f5c6cb,stroke:#721c24,color:#721c24
    classDef client fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef doc fill:#e9ecef,stroke:#6c757d,color:#6c757d
```
