How ashutoshmishra52/bitforensics works
Purpose and Entry Points
BitForensics is an offline Bitcoin-forensics workstation: it ingests transaction/network datasets, enriches and correlates records, detects suspicious activity, persists alerts, and serves a browser dashboard. Runtime entry points are run.py and backend/main.py; the Node development launcher is scripts/dev.js. The static client is served from frontend/dist/index.html.
API and Application Orchestration
FastAPI in backend/main.py owns the operational workflow and public API: ingest, analysis, alert retrieval, graph retrieval, stats, GeoIP download, and exports. It is the boundary between the static browser client and all backend processing. The frontend calls these APIs from bundled browser assets such as frontend/dist/assets/app.js and visualizes relationship data with frontend/dist/assets/graph.js.
Ingestion and Normalization
backend/ingest/parser.py accepts CSV, JSON, and XML transaction/network feeds, maps common source-field aliases to a normalized transaction shape, and prepares records for storage and analysis. Shared typed/domain representations are defined in backend/models/schemas.py. Sample source feeds under data/samples/ support offline demonstrations and local evaluation.
Persistence and Alert Archiving
SQLite is the primary local persistence layer, implemented through SQLAlchemy setup and data access in backend/database/db.py. Alert data can additionally be archived to an optional PostgreSQL instance via backend/database/postgres_alerts.py; docker-compose.yml supplies the local infrastructure path. This separates normal offline operation from optional cross-store archival.
Enrichment and Correlation
GeoIP enrichment resolves country and ASN context from IP data through backend/geo/lookup.py, with database acquisition handled by backend/geo/download.py. The bundled offline GeoIP source is data/geoip.csv. backend/correlation/engine.py joins network metadata, address/transaction behavior, and enrichment signals to produce evidence usable by detection and investigation.
Analysis and Alert Generation
The analysis stage in backend/ml/analyzer.py derives features and applies anomaly detection using packaged scikit-learn artifacts: data/models/feature_scaler.joblib and data/models/isolation_forest.joblib. Deterministic suspicious-pattern logic and explainable indicators are separated into backend/ml/red_flags.py and backend/ml/typology.py. Their combined output is ranked alert data rather than a definitive attribution decision.
Investigation Graph and Outputs
backend/graph/builder.py transforms transactions, addresses, and correlated entities into node/link graph data for the Link Graph interface. The API then exposes alerts and graph results to the static UI, while export endpoints generate retained investigation artifacts under the local data area. Packaging paths (packaging/desktop_app.py, packaging/launch_bitforensics.py) wrap the same local server/UI model for desktop distribution across supported operating systems.
Main entry points: main.py FastAPI Orchestrator · db.py SQLite Store · parser.py Feed Parser · index.html Static Dashboard
Components 20
Browser Client
- Static Dashboard
frontend/dist/index.html - API Client Bundle
frontend/dist/assets/app.js - Link Graph View
frontend/dist/assets/graph.js
Backend Workflow
- FastAPI Orchestrator · Owns ingest, analysis, investigation, GeoIP, and export workflows.
backend/main.py - Feed Parser · Normalizes CSV, JSON, and XML feeds into transaction records.
backend/ingest/parser.py - Domain Schemas
backend/models/schemas.py - GeoIP Acquisition
backend/geo/download.py - GeoIP Lookup · Adds country and ASN context from IP data.
backend/geo/lookup.py - Correlation Engine · Joins transaction, address, network, and enrichment signals.
backend/correlation/engine.py - Anomaly Analyzer · Derives features and scores records with packaged models.
backend/ml/analyzer.py - Red Flags & Typologies · Produces explainable suspicious-pattern indicators.
backend/ml/red_flags.py - Investigation Graph Builder
backend/graph/builder.py
Local Data & Stores
- SQLite Store · Default offline store managed through SQLAlchemy.
backend/database/db.py - PostgreSQL Alert Archive
backend/database/postgres_alerts.py - Sample Feeds
- Offline GeoIP Data
data/geoip.csv - ML Artifacts · Feature scaler and isolation forest artifacts.
data/models/isolation_forest.joblib
Launch & Distribution
- Desktop Packaging · Wraps the local server and static UI for desktop distribution.
packaging/desktop_app.py - Runtime Entry
run.py - Node Dev Launcher
scripts/dev.js
Connections 25
- Static Dashboard → API Client Bundle: loads
- API Client Bundle → FastAPI Orchestrator: calls APIs
- Link Graph View → FastAPI Orchestrator: retrieves graph data
- FastAPI Orchestrator → Feed Parser: ingests feeds
- Sample Feeds → Feed Parser: source data
- Feed Parser → Domain Schemas: maps to
- Feed Parser → SQLite Store: stores normalized records
- FastAPI Orchestrator → GeoIP Acquisition: downloads GeoIP
- GeoIP Acquisition → Offline GeoIP Data: acquires
- SQLite Store → GeoIP Lookup: supplies IP records
- Offline GeoIP Data → GeoIP Lookup: lookup source
- GeoIP Lookup → Correlation Engine: enrichment context
- SQLite Store → Correlation Engine: transaction and network data
- Correlation Engine → Anomaly Analyzer: correlated evidence
- ML Artifacts → Anomaly Analyzer: scores with
- Anomaly Analyzer → Red Flags & Typologies: analysis signals
- Red Flags & Typologies → SQLite Store: ranked alerts
- SQLite Store → PostgreSQL Alert Archive: optional alert archive
- SQLite Store → Investigation Graph Builder: investigation entities
- Investigation Graph Builder → FastAPI Orchestrator: node/link results
- FastAPI Orchestrator → Static Dashboard: alerts, stats, exports
- Runtime Entry → FastAPI Orchestrator: starts
- Node Dev Launcher → FastAPI Orchestrator: starts development runtime
- Desktop Packaging → Runtime Entry: packages launcher
- Desktop Packaging → Static Dashboard: bundles local UI