# yamanop/sih_26 architecture

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

- Interactive diagram: https://gitdiagram.com/yamanop/sih_26
- Repository: https://github.com/yamanop/sih_26

## Overview

ChainSentry is a command-line blockchain wallet-risk pipeline. Day 1 creates or accepts Elliptic++ inputs, simulates network observations, unifies transactions, engineers wallet features, and builds a wallet/transaction/IP graph. Day 2 combines anomaly, supervised, graph-cluster, and network-red-flag scores, then generates SHAP-backed explanations for top-ranked wallets. The README documents optional real-data subsampling and real GeoIP replacement; sampled code confirms the synthetic path and graph/model flow, but not every feature or model implementation detail.

Main entry points: [`src/run_day1.py`](https://github.com/yamanop/sih_26/blob/main/src/run_day1.py) (Day 1 runner), [`src/explain.py`](https://github.com/yamanop/sih_26/blob/main/src/explain.py) (SHAP explanations), [`src/train_models.py`](https://github.com/yamanop/sih_26/blob/main/src/train_models.py) (Risk ensemble), [`src/config.py`](https://github.com/yamanop/sih_26/blob/main/src/config.py) (Raw CSV inputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data inputs"]
  node_synthetic["Synthetic chain data"]
  node_subsample["Real-data subsampler"]
  node_rawfiles["Raw CSV inputs<br/>[config.py]"]
  node_networkgen["Network simulator<br/>[ip_generator.py]"]
  node_networkdata["Network observations<br/>[config.py]"]
end

subgraph group_day1["Day 1 enrichment"]
  node_day1run["Day 1 runner<br/>[run_day1.py]"]
  node_ingest["Ingestion and validation<br/>[ingest.py]"]
  node_unified["Unified transactions<br/>[config.py]"]
  node_features["Wallet features<br/>[features.py]"]
  node_featuretable["Feature table<br/>[config.py]"]
  node_graphbuild["Graph construction<br/>[graph_build.py]"]
  node_walletgraph["Wallet transaction IP graph<br/>[config.py]"]
end

subgraph group_day2["Day 2 risk analysis"]
  node_day2run["Day 2 runner<br/>[run_day2.py]"]
  node_models["Risk ensemble<br/>[train_models.py]"]
  node_explain["SHAP explanations<br/>[explain.py]"]
end

subgraph group_outputs["Risk outputs"]
  node_scores["Ranked risk scores<br/>[config.py]"]
  node_explanations["Wallet explanations<br/>[config.py]"]
end

node_analyst(("Analyst"))
node_realdata["Elliptic++ data"]

node_analyst -->|"starts pipeline"| node_day1run
node_analyst -->|"starts scoring"| node_day2run
node_day1run -->|"runs when needed"| node_synthetic
node_day1run -->|"runs"| node_networkgen
node_day1run -->|"runs"| node_ingest
node_day1run -->|"runs"| node_features
node_day1run -->|"runs"| node_graphbuild
node_synthetic -->|"writes"| node_rawfiles
node_realdata -.->|"supplies"| node_rawfiles
node_realdata -.->|"may be reduced by"| node_subsample
node_subsample -.->|"filters"| node_rawfiles
node_networkgen -->|"reads chain inputs"| node_rawfiles
node_networkgen -->|"writes simulated layer"| node_networkdata
node_ingest -->|"reads"| node_rawfiles
node_ingest -->|"reads"| node_networkdata
node_ingest -->|"writes"| node_unified
node_features -->|"reads"| node_unified
node_features -->|"writes"| node_featuretable
node_graphbuild -->|"reads"| node_unified
node_graphbuild -->|"reads for check"| node_featuretable
node_graphbuild -->|"writes"| node_walletgraph
node_day2run -->|"runs"| node_models
node_day2run -->|"runs after scoring"| node_explain
node_models -->|"reads"| node_featuretable
node_models -->|"reads"| node_walletgraph
node_models -->|"writes"| node_scores
node_explain -->|"reads"| node_featuretable
node_explain -->|"reads"| node_scores
node_explain -->|"loads trained model"| node_models
node_explain -->|"writes"| node_explanations
node_analyst -->|"reviews"| node_scores
node_analyst -->|"reviews"| node_explanations

click node_synthetic "https://github.com/yamanop/sih_26/blob/main/src/synthetic_elliptic_data.py"
click node_subsample "https://github.com/yamanop/sih_26/blob/main/src/subsample_real_data.py"
click node_rawfiles "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_networkgen "https://github.com/yamanop/sih_26/blob/main/src/ip_generator.py"
click node_networkdata "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_day1run "https://github.com/yamanop/sih_26/blob/main/src/run_day1.py"
click node_ingest "https://github.com/yamanop/sih_26/blob/main/src/ingest.py"
click node_unified "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_features "https://github.com/yamanop/sih_26/blob/main/src/features.py"
click node_featuretable "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_graphbuild "https://github.com/yamanop/sih_26/blob/main/src/graph_build.py"
click node_walletgraph "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_day2run "https://github.com/yamanop/sih_26/blob/main/src/run_day2.py"
click node_models "https://github.com/yamanop/sih_26/blob/main/src/train_models.py"
click node_scores "https://github.com/yamanop/sih_26/blob/main/src/config.py"
click node_explain "https://github.com/yamanop/sih_26/blob/main/src/explain.py"
click node_explanations "https://github.com/yamanop/sih_26/blob/main/src/config.py"

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_synthetic,node_subsample,node_rawfiles,node_networkgen,node_networkdata toneBlue
class node_day1run,node_ingest,node_unified,node_features,node_featuretable,node_graphbuild,node_walletgraph toneAmber
class node_day2run,node_models,node_explain toneMint
class node_scores,node_explanations toneRose
class node_analyst,node_realdata toneIndigo
```

## Components

### Data inputs

- [Synthetic chain data](https://github.com/yamanop/sih_26/blob/main/src/synthetic_elliptic_data.py): `src/synthetic_elliptic_data.py`
- [Real-data subsampler](https://github.com/yamanop/sih_26/blob/main/src/subsample_real_data.py): `src/subsample_real_data.py`
- [Raw CSV inputs](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`
- [Network simulator](https://github.com/yamanop/sih_26/blob/main/src/ip_generator.py): `src/ip_generator.py`
- [Network observations](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`

### Day 1 enrichment

- [Day 1 runner](https://github.com/yamanop/sih_26/blob/main/src/run_day1.py): `src/run_day1.py`
- [Ingestion and validation](https://github.com/yamanop/sih_26/blob/main/src/ingest.py): `src/ingest.py`
- [Unified transactions](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`
- [Wallet features](https://github.com/yamanop/sih_26/blob/main/src/features.py): `src/features.py`
- [Feature table](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`
- [Graph construction](https://github.com/yamanop/sih_26/blob/main/src/graph_build.py): `src/graph_build.py`
- [Wallet transaction IP graph](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`

### Day 2 risk analysis

- [Day 2 runner](https://github.com/yamanop/sih_26/blob/main/src/run_day2.py): `src/run_day2.py`
- [Risk ensemble](https://github.com/yamanop/sih_26/blob/main/src/train_models.py): `src/train_models.py`
- [SHAP explanations](https://github.com/yamanop/sih_26/blob/main/src/explain.py): `src/explain.py`

### Risk outputs

- [Ranked risk scores](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`
- [Wallet explanations](https://github.com/yamanop/sih_26/blob/main/src/config.py): `src/config.py`

### Other components

- **Analyst**
- **Elliptic++ data**

## Connections

- Analyst → Day 1 runner: starts pipeline
- Analyst → Day 2 runner: starts scoring
- Day 1 runner → Synthetic chain data: runs when needed
- Day 1 runner → Network simulator: runs
- Day 1 runner → Ingestion and validation: runs
- Day 1 runner → Wallet features: runs
- Day 1 runner → Graph construction: runs
- Synthetic chain data → Raw CSV inputs: writes
- Elliptic++ data → Raw CSV inputs: supplies
- Elliptic++ data → Real-data subsampler: may be reduced by
- Real-data subsampler → Raw CSV inputs: filters
- Network simulator → Raw CSV inputs: reads chain inputs
- Network simulator → Network observations: writes simulated layer
- Ingestion and validation → Raw CSV inputs: reads
- Ingestion and validation → Network observations: reads
- Ingestion and validation → Unified transactions: writes
- Wallet features → Unified transactions: reads
- Wallet features → Feature table: writes
- Graph construction → Unified transactions: reads
- Graph construction → Feature table: reads for check
- Graph construction → Wallet transaction IP graph: writes
- Day 2 runner → Risk ensemble: runs
- Day 2 runner → SHAP explanations: runs after scoring
- Risk ensemble → Feature table: reads
- Risk ensemble → Wallet transaction IP graph: reads
- Risk ensemble → Ranked risk scores: writes
- SHAP explanations → Feature table: reads
- SHAP explanations → Ranked risk scores: reads
- SHAP explanations → Risk ensemble: loads trained model
- SHAP explanations → Wallet explanations: writes
- Analyst → Ranked risk scores: reviews
- Analyst → Wallet explanations: reviews
