How mustafamerchant21/anomalyiq works
Purpose and Entry Points
AnomalyIQ is a full-stack fraud/anomaly intelligence demo that combines ML, deterministic rules, relationship-graph analysis, and explanations into investigation workflows. The backend API starts in backend/main.py; the browser application is served from frontend/index.html and initialized through frontend/js/app.js.
Backend Orchestration Pipeline
backend/pipeline.py is the likely coordination boundary for turning uploaded or submitted records into scored results. It composes preprocessing, model/signal stages, aggregation, and explanations rather than exposing those concerns directly to the UI. API request/response and lifecycle concerns belong in backend/main.py.
Data Preparation and Signal Generation
Input normalization and feature preparation are separated in backend/preprocessor.py, providing a boundary between variable source datasets and downstream detection logic. ML-oriented anomaly detection is supported by the Python stack declared in backend/requirements.txt, including scikit-learn and TensorFlow per the project description. Demo data can be generated through backend/demo_generator.py.
Risk Decision Layer
backend/rule_engine.py produces interpretable rule-based fraud indicators, while backend/risk_aggregator.py combines rule, model, and graph-derived signals into an overall risk result. This separation is architecture-defining: individual detectors retain their own evidence, and aggregation creates the common score used by dashboards, prediction, and investigations.
Relationship and Investigation Analysis
backend/graph_engine.py handles account/transaction relationship analysis, including fraud-ring or cluster-oriented intelligence. NetworkX is a material runtime dependency for this stage. Its graph results are a separate evidence source feeding the aggregate risk and investigation-facing views.
Explainability and State
backend/explainer.py converts risk evidence into human-readable insights or narratives for analysts. backend/session_manager.py maintains session-scoped workflow state, allowing multi-step interactions such as upload, training/testing, prediction, and investigation without embedding UI state into detection engines.
Frontend Workflows and Visualization
The vanilla-JavaScript frontend calls backend APIs through frontend/js/api.js. Feature modules map to major analyst workflows: ingestion/training in frontend/js/upload.js, scoring in frontend/js/predictor.js, scenario analysis in frontend/js/simulator.js, and case exploration in frontend/js/investigation.js. Dashboard and audit presentations reside in frontend/js/dashboard.js and frontend/js/audit.js; Chart.js supports charts and Three.js supports graph/3D visualization such as frontend/js/globe.js.
Runtime Boundaries
The application has a Python/FastAPI service boundary (backend/main.py) and a static browser-client boundary (frontend/index.html). No persistent database, message broker, cloud deployment target, or third-party operational service is represented in the supplied tree. Client-side PDF/report capability is indicated by jsPDF in the README; detection and graph computation execute in the backend Python runtime.
Main entry points: app.js Client Bootstrap · main.py FastAPI Service · preprocessor.py Preprocessor · pipeline.py Analysis Pipeline
Components 19
Browser Client
Static analyst application and workflow modules.
- Static Web App
frontend/index.html - Client Bootstrap
frontend/js/app.js - API Client
frontend/js/api.js - Ingestion & Training
frontend/js/upload.js - Scoring
frontend/js/predictor.js - Scenario Analysis
frontend/js/simulator.js - Case Exploration
frontend/js/investigation.js - Dashboard & Audit
frontend/js/dashboard.js - Graph Visualization
frontend/js/globe.js
Python API
FastAPI entry point and session workflow boundary.
- FastAPI Service · Owns API lifecycle and request/response handling.
backend/main.py - Session Manager · Maintains state across analyst workflow steps.
backend/session_manager.py
Risk Analysis Pipeline
Backend preparation, evidence generation, and decision stages.
- Analysis Pipeline · Coordinates preparation, evidence stages, risk, and explanations.
backend/pipeline.py - Preprocessor
backend/preprocessor.py - ML Anomaly Detection · Uses the scikit-learn and TensorFlow backend stack.
backend/requirements.txt - Rule Engine
backend/rule_engine.py - Relationship Analysis · Finds relationship clusters and fraud-ring evidence using NetworkX.
backend/graph_engine.py - Risk Aggregator · Combines detector evidence into the shared risk result.
backend/risk_aggregator.py - Explainer
backend/explainer.py - Demo Data Generator
backend/demo_generator.py
Connections 22
- Static Web App → Client Bootstrap: loads
- Client Bootstrap → API Client: initializes
- Client Bootstrap → Ingestion & Training: hosts
- Client Bootstrap → Scoring: hosts
- Client Bootstrap → Scenario Analysis: hosts
- Client Bootstrap → Case Exploration: hosts
- Client Bootstrap → Dashboard & Audit: hosts
- Case Exploration → Graph Visualization: visualizes relationships
- API Client → FastAPI Service: HTTP API calls
- FastAPI Service → Session Manager: manages workflow state
- FastAPI Service → Analysis Pipeline: submits records
- Demo Data Generator → Analysis Pipeline: supplies sample records
- Analysis Pipeline → Preprocessor: prepares input
- Preprocessor → ML Anomaly Detection: features
- Preprocessor → Rule Engine: normalized records
- Preprocessor → Relationship Analysis: relationship data
- ML Anomaly Detection → Risk Aggregator: anomaly evidence
- Rule Engine → Risk Aggregator: rule evidence
- Relationship Analysis → Risk Aggregator: graph evidence
- Risk Aggregator → Explainer: risk evidence
- Analysis Pipeline → FastAPI Service: scores and explanations
- FastAPI Service → API Client: workflow results