# mwasifanwar/cryptograph architecture

> Architecture diagram of the GitHub repository mwasifanwar/cryptograph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mwasifanwar/cryptograph
- Repository: https://github.com/mwasifanwar/cryptograph

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack, data-driven analytics platform named “cryptograph.”
- Its core function is to ingest raw blockchain data, construct transaction graphs, extract features, run a graph neural network (GNN) and anomaly-detection models, and present results via a web interface (templates + static assets).

##### File structure
- Top-level modules:
- data: blockchain_loader.py, graph_builder.py – responsible for fetching and structuring raw data.
- features: feature_engineer.py – computing node/edge features for GNN input.
- analysis: pattern_analyzer.py, risk_assessor.py – orchestrating detection logic on model outputs.
- models: gnn_models.py, anomaly_detector.py – definition and execution of machine-learning models.
- api: app.py – Flask (or similar) app exposing REST endpoints for the front end.
- static + templates: UI layer with HTML, CSS, JS.
- config: settings.py – configuration of endpoints, thresholds, feature toggles.
- utils: helper functions (blockchain_utils.py, visualization_utils.py).
- main.py – likely CLI entrypoint or pipeline orchestrator.

##### README
- Confirms GNN-based money-laundering/fraud detection in blockchain transactions and smart contracts.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Entities
    ExtBlockchain["Blockchain Node"]:::external
    EndUser["End User"]:::external

    %% Data & ML Pipeline
    subgraph "Data & ML Pipeline"
        Ingestion["Data Ingestion Service"]:::ingestion
        GraphBuilder["Graph Construction Module"]:::ingestion
        GraphStore["Graph Store"]:::datastore
        FeatureEng["Feature Engineering Service"]:::feature
        FeatureStore["Feature Store"]:::datastore
        PatternAnalyzer["Pattern Analyzer"]:::feature
        RiskAssessor["Risk Assessor"]:::feature
        GNNModels["GNN Models"]:::ml
        AnomalyDetector["Anomaly Detector"]:::ml
    end

    %% Web/API Layer
    subgraph "Web/API Layer"
        API["API / Web Server"]:::api
        Base["Base Template"]:::api
        Index["Index Page"]:::api
        Style["CSS (style.css)"]:::api
        MainJS["JS (main.js)"]:::api
    end

    %% Supporting Services
    subgraph "Supporting Services"
        Config["Configuration Service"]:::util
        UtilsChain["Blockchain Helpers"]:::util
        UtilsVis["Visualization Helpers"]:::util
        Orchestrator["Pipeline Orchestrator"]:::util
    end

    %% Data & ML Flow
    ExtBlockchain --> Ingestion
    Ingestion --> GraphBuilder
    GraphBuilder --> GraphStore
    GraphStore --> FeatureEng
    FeatureEng --> FeatureStore
    FeatureStore --> PatternAnalyzer
    FeatureStore --> RiskAssessor
    PatternAnalyzer --> GNNModels
    GNNModels -->|returns scores| PatternAnalyzer
    RiskAssessor --> AnomalyDetector
    AnomalyDetector -->|returns alerts| RiskAssessor
    PatternAnalyzer --> API
    RiskAssessor --> API

    %% Web/API Flow
    API --> Base
    API --> Index
    API --> Style
    API --> MainJS
    Base --> EndUser
    Index --> EndUser
    Style --> EndUser
    MainJS --> EndUser

    %% Supporting
    Orchestrator --> Ingestion
    Config -.-> Ingestion
    Config -.-> GraphBuilder
    Config -.-> FeatureEng
    Config -.-> PatternAnalyzer
    Config -.-> RiskAssessor
    Config -.-> GNNModels
    Config -.-> AnomalyDetector
    Config -.-> API
    UtilsChain -.-> Ingestion
    UtilsChain -.-> GraphBuilder
    UtilsVis -.-> GraphBuilder
    UtilsVis -.-> FeatureEng
    UtilsVis -.-> PatternAnalyzer
    UtilsVis -.-> RiskAssessor

    %% Click Events
    click Ingestion "https://github.com/mwasifanwar/cryptograph/blob/main/data/blockchain_loader.py"
    click GraphBuilder "https://github.com/mwasifanwar/cryptograph/blob/main/data/graph_builder.py"
    click FeatureEng "https://github.com/mwasifanwar/cryptograph/blob/main/features/feature_engineer.py"
    click PatternAnalyzer "https://github.com/mwasifanwar/cryptograph/blob/main/analysis/pattern_analyzer.py"
    click RiskAssessor "https://github.com/mwasifanwar/cryptograph/blob/main/analysis/risk_assessor.py"
    click GNNModels "https://github.com/mwasifanwar/cryptograph/blob/main/models/gnn_models.py"
    click AnomalyDetector "https://github.com/mwasifanwar/cryptograph/blob/main/models/anomaly_detector.py"
    click API "https://github.com/mwasifanwar/cryptograph/blob/main/api/app.py"
    click Base "https://github.com/mwasifanwar/cryptograph/blob/main/templates/base.html"
    click Index "https://github.com/mwasifanwar/cryptograph/blob/main/templates/index.html"
    click Style "https://github.com/mwasifanwar/cryptograph/blob/main/static/css/style.css"
    click MainJS "https://github.com/mwasifanwar/cryptograph/blob/main/static/js/main.js"
    click Config "https://github.com/mwasifanwar/cryptograph/blob/main/config/settings.py"
    click UtilsChain "https://github.com/mwasifanwar/cryptograph/blob/main/utils/blockchain_utils.py"
    click UtilsVis "https://github.com/mwasifanwar/cryptograph/blob/main/utils/visualization_utils.py"
    click Orchestrator "https://github.com/mwasifanwar/cryptograph/blob/main/main.py"

    %% Styles
    classDef ingestion fill:#cce5ff,stroke:#004085,color:#004085;
    classDef feature fill:#d4edda,stroke:#155724,color:#155724;
    classDef ml fill:#fff3cd,stroke:#856404,color:#856404;
    classDef api fill:#f5c6cb,stroke:#721c24,color:#721c24;
    classDef datastore fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef util fill:#f8f9fa,stroke:#6c757d,color:#6c757d;
    classDef external fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
```
