DeFi risk and incident monitoring with RAG and agentic workflows.
Goal: a production-grade pipeline that fuses on-chain data and off-chain signals to generate clear, actionable risk briefs and alerts for DeFi protocols. This showcases end-to-end skills across data engineering, LLM + RAG, agent orchestration, and low-latency components.
- Copy
.env.exampleto.envand fill inALCHEMY_API_KEY. - Install core dependencies:
pip install -r requirements-core.txt - Validate fixtures:
python scripts/validate_fixtures.py - Build features:
python scripts/build_features.py
For RAG indexing, install full dependencies: pip install -r requirements-rag.txt.
- Ingest on-chain events from Ethereum mainnet for Aave v3 and Uniswap v3 via Alchemy RPC.
- Ingest off-chain signals from public RSS feeds (governance, security advisories).
- Normalize all signals into a single event schema with event-time semantics.
- Build a feature store in DuckDB with rolling windows and anomaly flags.
- Index documents into Chroma for RAG queries.
- Run a LangGraph workflow that produces:
- Daily protocol risk briefs
- Real-time alert summaries on anomalies
- Expose a read-only FastAPI service and a Typer CLI for queries.
- On-chain: Ethereum mainnet via Alchemy RPC.
- Governance RSS:
- Security advisories RSS:
- Required env:
ALCHEMY_API_KEY - Optional env:
ALCHEMY_RPC_URL - See docs/CONFIG.md for details.
- Fixtures live in
data/fixtures/*.jsonl(on-chain and off-chain samples). - Schema is defined in
src/normalize/schema.py. - Validate fixtures:
pip install -r requirements-core.txtpython scripts/validate_fixtures.py
- Fetch and normalize RSS entries into the canonical event schema.
- Default feeds are in
src/ingest/rss.py. - Details:
docs/INGEST_RSS.md. - Run:
pip install -r requirements-core.txtpython scripts/ingest_rss.py
- Output:
data/ingest/rss_events.jsonl
- Fetch and normalize Ethereum logs via Alchemy.
- Details:
docs/INGEST_ONCHAIN.md. - Run:
pip install -r requirements-core.txtpython scripts/ingest_onchain.py
- Output:
data/ingest/onchain_events.jsonl
- Build rolling-count features from ingested events and flag simple surges.
- Details:
docs/FEATURE_STORE.md. - Run:
pip install -r requirements-core.txtpython scripts/build_features.py
- Outputs:
data/feature_store.duckdb,data/features/*
- FastAPI service that reads local JSONL outputs.
- Details:
docs/API.md. - Run:
pip install -r requirements-core.txtpython scripts/run_api.py
- Build a Chroma vector index from ingested events for retrieval.
- Details:
docs/RAG.md. - Run:
pip install -r requirements-rag.txtpython scripts/build_rag_index.py
- Useful to engineers, analysts, and teams who want transparent, explainable risk context.
- Demonstrates practical LLM + RAG usage with real data pipelines and operational concerns.
- Highlights performance engineering via a C++ aggregation module with Python bindings.
Data Sources -> Ingest -> Normalize -> Feature Store -> Vector Index -> RAG -> Agent -> Outputs
See docs/ARCHITECTURE.md for more detail.
- src/ingest/ Data connectors (on-chain, RSS, advisories)
- src/normalize/ Schema, validation, event-time handling
- src/features/ Rolling metrics, anomaly detection
- src/rag/ Embeddings, retrieval, prompt tooling
- src/agents/ Briefing and alert workflows
- src/api/ REST API (read-only)
- src/cli/ Local CLI for queries
- src/cpp/ High-throughput aggregations
- tests/ Unit + integration tests
- docs/ Design docs and roadmap
- Python 3.11, FastAPI, LangChain, LangGraph, Web3.py
- LLM + embeddings: Llama 3 + BGE (local, via sentence-transformers)
- Vector DB: Chroma (local)
- Storage: DuckDB + Parquet
- C++ core for high-rate aggregations (pybind11)
- Docker, GitHub Actions
- No live trading or capital deployment.
- No proprietary data sources required to run locally.
- No UI dashboard in phase 1 (API + CLI only).
- Phase 0: local fixtures and schema validation
- Phase 1: end-to-end MVP pipeline with API + CLI
- Phase 2: streaming ingestion and C++ accelerator
- Phase 3: optional UI dashboard and multi-chain support