# shubhamdalvi1999/neo4j-graph-fraud-detection architecture

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

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

## Overview

##### Project type and purpose
- This is a graph-analytics fraud-detection pipeline built around a single Neo4j database.
- It ingests a Paysim dataset dump, uses Cypher scripts and the Neo4j GDS/APOC plugins to detect first-party (synthetic identity) and second-party (money mule) fraud, and exposes results via Python and Neo4j Bloom for exploration.

##### File structure
- Top‐level:
- `docker-compose.yml` – spins up Neo4j with GDS & APOC
- `data/` – pre-processed `.dump` file(s) for import
- `code/cypher/` – Cypher modules (data loading, graph projection, WCC, PageRank, node similarity, scoring)
- `code/python/` – Python example connecting via Bolt driver
- `fraud demo/` – ad-hoc Cypher scripts for generating and visualizing demo scenarios
- Runbooks and README provide operational guidance.
- Key patterns:
- A single graph database holds all nodes & relationships.
- Analytic steps are implemented as discrete Cypher modules (module1…module4).
- External components (Python, Bloom) query the post-processed graph.

##### README for additional insights
- Confirms core components: Neo4j DB, GDS plugin, APOC plugin, data dump, Cypher scripts, Python driver, optional Neo4j Bloom.

##### Detail and capture essential elements
- Break the “processing layer” into four sub-steps (module1…4) to reflect the code structure.
- GDS & APOC plugins as auxiliaries attached to Neo4j.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    Data["Paysim Dump"]:::data

    %% Orchestration
    subgraph "Orchestration"
        DockerCompose["Docker Compose"]:::orchestration
    end

    %% Database
    Neo4j["Neo4j DB\n(GDS & APOC)"]:::storage

    %% Processing Layer
    subgraph "Processing Layer"
        M1["module1: Problem Definition & Data Loading"]:::compute
        M2["module2: Data Analysis & Graph Projection"]:::compute
        M3["module3: First-Party Fraud Detection"]:::compute
        M4["module4: Second-Party Fraud Detection"]:::compute
    end

    %% Ad-hoc Demo Scripts
    subgraph "Ad-hoc Demo Scripts"
        Demo1["Create First-Party Example"]:::compute
        Demo2["Visualize First-Party Example"]:::compute
        Demo3["Create Second-Party Example"]:::compute
        Demo4["Visualize Second-Party Example"]:::compute
    end

    %% Clients
    subgraph "Clients"
        PythonClient["Python Client"]:::client
        Bloom["Neo4j Bloom/Browser"]:::client
    end

    %% Relationships
    Data -->|"neo4j-admin load"| Neo4j
    DockerCompose -->|"provisions"| Neo4j

    Neo4j -->|"bolt/http"| M1
    M1 -->|"writes projections"| Neo4j
    Neo4j -->|"bolt/http"| M2
    M2 -->|"writes analysis"| Neo4j
    Neo4j -->|"bolt/http"| M3
    M3 -->|"writes scores"| Neo4j
    Neo4j -->|"bolt/http"| M4
    M4 -->|"writes scores"| Neo4j

    Demo1 -->|"cypher"| Neo4j
    Demo2 -->|"cypher"| Neo4j
    Demo3 -->|"cypher"| Neo4j
    Demo4 -->|"cypher"| Neo4j

    PythonClient -->|"Bolt driver"| Neo4j
    Bloom -->|"HTTP"| Neo4j

    %% Click Events
    click Data "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/data/fraud-detection-40.dump"
    click DockerCompose "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/docker-compose.yml"
    click Neo4j "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/docker-compose.yml"
    click M1 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/code/cypher/module1_problem_definition.cypher"
    click M2 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/code/cypher/module2_data_analysis.cypher"
    click M3 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/code/cypher/module3_first_party_fraud.cypher"
    click M4 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/code/cypher/module4_second_party_fraud.cypher"
    click Demo1 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/fraud demo/create_first_party_fraud_example.cypher"
    click Demo2 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/fraud demo/visualize_first_party_fraud_example.cypher"
    click Demo3 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/fraud demo/create_second_party_fraud_example.cypher"
    click Demo4 "https://github.com/shubhamdalvi1999/neo4j-graph-fraud-detection/blob/main/fraud demo/visualize_second_party_example.cyper"

    %% Styles
    classDef orchestration fill:#fdebd0,stroke:#d35400,stroke-width:1px;
    classDef storage fill:#d5f5e3,stroke:#27ae60,stroke-width:1px;
    classDef compute fill:#d6eaf8,stroke:#2e86c1,stroke-width:1px;
    classDef client fill:#f9e79f,stroke:#b7950b,stroke-width:1px;
    classDef data fill:#f5b7b1,stroke:#c0392b,stroke-width:1px;
```
