# dhruvpatel6429/veririsk architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvpatel6429/veririsk
- Repository: https://github.com/dhruvpatel6429/veririsk

## Overview

VeriRisk is a DeFi risk-operations platform. Protocol snapshots feed feature engineering and ML risk evaluation; the evaluator persists history and alerts, while APIs and a Next.js console expose monitoring and analysis. Separate branches provide what-if simulation, autonomous defense, threat intelligence, and Stellar-backed prediction proofs. The graph includes the documented major capabilities, but several subsystems were not excerpted; their links are included only where the README or source index supports them.

Main entry points: [`frontend/pages/index.tsx`](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/pages/index.tsx) (Operations Console), [`backend/services/risk_evaluator.py`](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/risk_evaluator.py) (Risk Evaluation), [`backend/scheduler.py`](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/scheduler.py) (Pipeline Scheduler), [`backend/api_server.py`](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/api_server.py) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data and Features"]
  node_fetch["Protocol Ingestion<br/>[data_fetcher.py]"]
  node_protocols["Protocol Catalog<br/>[protocols.py]"]
  node_scheduler["Pipeline Scheduler<br/>[scheduler.py]"]
  node_snapshots["Hourly Snapshots<br/>[hourly_snapshot.py]"]
  node_features["Time-Series Features"]
  node_advanced["Advanced Features"]
  node_storage[("Snapshot Storage<br/>[database.py]")]
end

subgraph group_risk["Risk Intelligence"]
  node_model["Risk Model<br/>[model_server.py]"]
  node_evaluator["Risk Evaluation<br/>[risk_evaluator.py]"]
  node_explain["Explainability"]
  node_history[("Risk History<br/>[risk_history.py]")]
  node_alerts[("Alert Records<br/>[alert.py]")]
end

subgraph group_operations["Operations and Analysis"]
  node_api["REST API<br/>[api_server.py]"]
  node_simulation["Crisis Simulation"]
  node_guardian["Risk Guardian<br/>[risk_guardian.py]"]
  node_defense["Auto Defense<br/>[auto_defense.py]"]
  node_threat["Threat Intelligence"]
  node_config["Runtime Configuration<br/>[config.py]"]
end

subgraph group_proof["Verification"]
  node_chain_submit["Proof Submission<br/>[submit_to_chain.py]"]
  node_stellar["Stellar Adapter<br/>[stellar_adapter.py]"]
  node_contracts{{"Soroban Contracts<br/>[lib.rs]"}}
end

subgraph group_console["Web Console"]
  node_frontend["Operations Console<br/>[index.tsx]"]
  node_polling["Fetch Sync"]
  node_ui_stats["Dashboard Stats<br/>[GlobalStats.tsx]"]
  node_ui_alerts["Alert Feed<br/>[LiveAlertFeed.tsx]"]
  node_ui_defense["Defense Panel"]
  node_ui_transparency["Model Transparency"]
  node_error_ui["Error Fallback<br/>[ErrorFallback.tsx]"]
  node_loading_ui["Loading Skeleton"]
end

node_operators(("Protocol Operators"))

node_operators -->|"monitor risks"| node_frontend
node_frontend -.->|"requests data"| node_api
node_frontend -->|"polls status"| node_polling
node_frontend -->|"renders"| node_ui_stats
node_frontend -->|"renders"| node_ui_alerts
node_frontend -->|"renders"| node_ui_defense
node_frontend -->|"renders"| node_error_ui
node_frontend -->|"renders"| node_loading_ui
node_frontend -.->|"presents"| node_ui_transparency
node_scheduler -->|"schedules fetching"| node_fetch
node_scheduler -->|"schedules snapshots"| node_snapshots
node_scheduler -->|"runs evaluation"| node_evaluator
node_scheduler -->|"runs defense"| node_defense
node_snapshots -->|"uses catalog"| node_protocols
node_snapshots -->|"writes snapshots"| node_storage
node_features -->|"reads history"| node_storage
node_features -->|"reads snapshots"| node_snapshots
node_evaluator -->|"requests predictions"| node_model
node_evaluator -->|"stores assessments"| node_history
node_evaluator -->|"creates alerts"| node_alerts
node_api -->|"routes risk calls"| node_evaluator
node_api -->|"routes simulations"| node_simulation
node_api -->|"requests explanations"| node_explain
node_simulation -->|"scores scenarios"| node_model
node_guardian -->|"investigates risk"| node_evaluator
node_guardian -->|"triggers actions"| node_defense
node_api -.->|"exposes monitoring"| node_threat
node_scheduler -->|"submits predictions"| node_chain_submit
node_chain_submit -.->|"uses adapter"| node_stellar
node_stellar -.->|"writes proofs"| node_contracts
node_config -->|"configures database"| node_storage

click node_frontend "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/pages/index.tsx"
click node_polling "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/hooks/useBackendFetchSync.ts"
click node_ui_stats "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/GlobalStats.tsx"
click node_ui_alerts "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/LiveAlertFeed.tsx"
click node_ui_defense "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/AutoDefensePanel.tsx"
click node_ui_transparency "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/ModelTransparencyPanel.tsx"
click node_api "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/api_server.py"
click node_fetch "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/data_fetcher.py"
click node_protocols "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/protocols.py"
click node_scheduler "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/scheduler.py"
click node_snapshots "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/jobs/hourly_snapshot.py"
click node_features "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/features/basic_timeseries.py"
click node_advanced "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/features/advanced_features.py"
click node_model "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/model_server.py"
click node_evaluator "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/risk_evaluator.py"
click node_explain "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/explainability_service.py"
click node_history "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/db_models/risk_history.py"
click node_alerts "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/db_models/alert.py"
click node_storage "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/database.py"
click node_simulation "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/simulation_service.py"
click node_guardian "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/agent/risk_guardian.py"
click node_defense "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/auto_defense.py"
click node_threat "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/threat_intelligence.py"
click node_chain_submit "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/submit_to_chain.py"
click node_stellar "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/chain/stellar_adapter.py"
click node_contracts "https://github.com/dhruvpatel6429/veririsk/blob/main/contracts/stellar/oracle/src/lib.rs"
click node_config "https://github.com/dhruvpatel6429/veririsk/blob/main/backend/config.py"
click node_error_ui "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/ErrorFallback.tsx"
click node_loading_ui "https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/LoadingSkeleton.tsx"

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_fetch,node_protocols,node_scheduler,node_snapshots,node_features,node_advanced,node_storage toneBlue
class node_model,node_evaluator,node_explain,node_history,node_alerts toneAmber
class node_api,node_simulation,node_guardian,node_defense,node_threat,node_config toneMint
class node_chain_submit,node_stellar,node_contracts toneRose
class node_frontend,node_polling,node_ui_stats,node_ui_alerts,node_ui_defense,node_ui_transparency,node_error_ui,node_loading_ui,node_operators toneIndigo
```

## Components

### Data and Features

- [Protocol Ingestion](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/data_fetcher.py): `backend/data_fetcher.py`
- [Protocol Catalog](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/protocols.py): `backend/protocols.py`
- [Pipeline Scheduler](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/scheduler.py): `backend/scheduler.py`
- [Hourly Snapshots](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/jobs/hourly_snapshot.py): `backend/jobs/hourly_snapshot.py`
- [Time-Series Features](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/features/basic_timeseries.py): `backend/features/basic_timeseries.py`
- [Advanced Features](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/features/advanced_features.py): `backend/features/advanced_features.py`
- [Snapshot Storage](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/database.py): `backend/database.py`

### Risk Intelligence

- [Risk Model](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/model_server.py): `backend/model_server.py`
- [Risk Evaluation](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/risk_evaluator.py): `backend/services/risk_evaluator.py`
- [Explainability](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/explainability_service.py): `backend/services/explainability_service.py`
- [Risk History](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/db_models/risk_history.py): `backend/db_models/risk_history.py`
- [Alert Records](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/db_models/alert.py): `backend/db_models/alert.py`

### Operations and Analysis

- [REST API](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/api_server.py): `backend/api_server.py`
- [Crisis Simulation](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/services/simulation_service.py): `backend/services/simulation_service.py`
- [Risk Guardian](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/agent/risk_guardian.py): `backend/agent/risk_guardian.py`
- [Auto Defense](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/auto_defense.py): `backend/auto_defense.py`
- [Threat Intelligence](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/threat_intelligence.py): `backend/threat_intelligence.py`
- [Runtime Configuration](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/config.py): `backend/config.py`

### Verification

- [Proof Submission](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/submit_to_chain.py): `backend/submit_to_chain.py`
- [Stellar Adapter](https://github.com/dhruvpatel6429/veririsk/blob/main/backend/chain/stellar_adapter.py): `backend/chain/stellar_adapter.py`
- [Soroban Contracts](https://github.com/dhruvpatel6429/veririsk/blob/main/contracts/stellar/oracle/src/lib.rs): `contracts/stellar/oracle/src/lib.rs`

### Web Console

- [Operations Console](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/pages/index.tsx): `frontend/pages/index.tsx`
- [Fetch Sync](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/hooks/useBackendFetchSync.ts): `frontend/hooks/useBackendFetchSync.ts`
- [Dashboard Stats](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/GlobalStats.tsx): `frontend/components/GlobalStats.tsx`
- [Alert Feed](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/LiveAlertFeed.tsx): `frontend/components/LiveAlertFeed.tsx`
- [Defense Panel](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/AutoDefensePanel.tsx): `frontend/components/AutoDefensePanel.tsx`
- [Model Transparency](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/ModelTransparencyPanel.tsx): `frontend/components/ModelTransparencyPanel.tsx`
- [Error Fallback](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/ErrorFallback.tsx): `frontend/components/ErrorFallback.tsx`
- [Loading Skeleton](https://github.com/dhruvpatel6429/veririsk/blob/main/frontend/components/LoadingSkeleton.tsx): `frontend/components/LoadingSkeleton.tsx`

### Other components

- **Protocol Operators**

## Connections

- Protocol Operators → Operations Console: monitor risks (evidence: `README.md`)
- Operations Console → REST API: requests data (evidence: `README.md`)
- Operations Console → Fetch Sync: polls status (evidence: `frontend/pages/index.tsx`)
- Operations Console → Dashboard Stats: renders (evidence: `frontend/pages/index.tsx`)
- Operations Console → Alert Feed: renders (evidence: `frontend/pages/index.tsx`)
- Operations Console → Defense Panel: renders (evidence: `frontend/pages/index.tsx`)
- Operations Console → Error Fallback: renders (evidence: `frontend/pages/index.tsx`)
- Operations Console → Loading Skeleton: renders (evidence: `frontend/pages/index.tsx`)
- Operations Console → Model Transparency: presents (evidence: `README.md`)
- Pipeline Scheduler → Protocol Ingestion: schedules fetching (evidence: `backend/scheduler.py`)
- Pipeline Scheduler → Hourly Snapshots: schedules snapshots (evidence: `backend/scheduler.py`)
- Pipeline Scheduler → Risk Evaluation: runs evaluation (evidence: `backend/scheduler.py`)
- Pipeline Scheduler → Auto Defense: runs defense (evidence: `backend/scheduler.py`)
- Hourly Snapshots → Protocol Catalog: uses catalog (evidence: `backend/jobs/hourly_snapshot.py`)
- Hourly Snapshots → Snapshot Storage: writes snapshots (evidence: `backend/jobs/hourly_snapshot.py`)
- Time-Series Features → Snapshot Storage: reads history (evidence: `backend/features/basic_timeseries.py`)
- Time-Series Features → Hourly Snapshots: reads snapshots (evidence: `backend/features/basic_timeseries.py`)
- Risk Evaluation → Risk Model: requests predictions (evidence: `backend/services/risk_evaluator.py`)
- Risk Evaluation → Risk History: stores assessments (evidence: `backend/services/risk_evaluator.py`)
- Risk Evaluation → Alert Records: creates alerts (evidence: `backend/services/risk_evaluator.py`)
- REST API → Risk Evaluation: routes risk calls
- REST API → Crisis Simulation: routes simulations
- REST API → Explainability: requests explanations
- Crisis Simulation → Risk Model: scores scenarios (evidence: `backend/services/simulation_service.py`)
- Risk Guardian → Risk Evaluation: investigates risk (evidence: `backend/agent/risk_guardian.py`)
- Risk Guardian → Auto Defense: triggers actions (evidence: `backend/agent/risk_guardian.py`)
- REST API → Threat Intelligence: exposes monitoring
- Pipeline Scheduler → Proof Submission: submits predictions (evidence: `backend/scheduler.py`)
- Proof Submission → Stellar Adapter: uses adapter
- Stellar Adapter → Soroban Contracts: writes proofs (evidence: `README.md`)
- Runtime Configuration → Snapshot Storage: configures database (evidence: `backend/database.py`)
