How kirtan011/wexa-ai works
Purpose and entry points
This is a Next.js App Router investigator tool for discovering financial-fraud rings in a Neo4j-compatible graph database. The primary UI entry points are the search/dashboard page at app/page.tsx, account investigation detail at app/account/[id]/page.tsx, and ring dashboard at app/rings/page.tsx. Root layout and global styling are defined in app/layout.tsx and app/globals.css.
Presentation and client data orchestration
Pages compose focused dashboard, account, and graph components while client hooks fetch API-backed data and manage loading/error states. The account detail view presents account metadata, risk, graph connections, and AI insight; the rings view summarizes detected clusters.
• hooks/useDashboard.ts
• hooks/useAccountAnalysis.ts
• components/NetworkGraph.tsx
• components/AccountInfoPanel.tsx
• components/InsightPanel.tsx
NetworkGraph.tsx is the browser-only visualization boundary for react-force-graph-2d; it must avoid server rendering because it depends on Canvas/browser APIs.
HTTP API boundary
Route handlers isolate UI code from database and analysis implementation. They expose account lookup, graph analysis, ring discovery, and search endpoints:
• app/api/account/[id]/route.ts
• app/api/analyze/[id]/route.ts
• app/api/rings/route.ts
• app/api/search/route.ts
The expected flow is client page/hook → /api/* route → query or analyzer service → typed response. This is the main trust boundary: browser clients do not send Cypher directly.
Graph persistence and deterministic investigation
CognoDB Cloud is accessed as a Neo4j-compatible Bolt/openCypher graph through the official neo4j-driver. The driver is a singleton/pool boundary; graph reads use parameterized Cypher and predictable success/error result shapes.
• lib/db.ts
• lib/queries.ts
• types/index.ts
The graph models Accounts linked to Devices, IP addresses, Phone Numbers, and Transactions. Core investigations traverse shared identity/infrastructure edges, find high-fan-out attributes, trace directed transaction chains, and retrieve account neighborhoods. Query depth and result limits bound potentially expensive graph exploration.
Analysis and explainability stage
The analysis endpoint obtains factual graph evidence through deterministic queries, then delegates pattern interpretation to the analyzer layer rather than allowing an LLM to query the database. This preserves the separation between data retrieval and narrative fraud explanation.
• lib/analyzer.ts
• app/api/analyze/[id]/route.ts
• components/InsightPanel.tsx
The AI-facing boundary should receive only structured, retrieved evidence. External AI service credentials/runtime details are not represented in the supplied tree, but the README identifies Gemini as the interpretation provider.
Ring discovery and investigator workflow
An investigator searches an account, opens its detail route, reviews direct account facts and a multi-hop connected network, then requests an evidence-based explanation. Separately, the rings dashboard surfaces clusters discovered from shared devices, IPs, or phone numbers.
• components/SearchBar.tsx
• app/account/[id]/page.tsx
• app/rings/page.tsx
• components/RingCard.tsx
Runtime, deployment, and data provisioning
The application runs on Node.js 18+ with Next.js, TypeScript, and Tailwind CSS; it is designed for Vercel deployment and requires CognoDB URI/user/password environment variables. Sample graph data—including synthetic hidden rings—is generated outside request handling by:
• scripts/seed.ts
• lib/db.ts
Main entry points: queries.ts Graph queries · [id]/page.tsx Account investigation · app/page.tsx Search dashboard · useDashboard.ts Dashboard data hook
Components 21
Investigator UI
- Root layout
app/layout.tsx - Search dashboard
app/page.tsx - Account investigation · Shows account facts, network evidence, and AI insight.
app/account/[id]/page.tsx - Ring dashboard
app/rings/page.tsx - Dashboard data hook
hooks/useDashboard.ts - Account analysis hook
hooks/useAccountAnalysis.ts - Search bar
components/SearchBar.tsx - Network graph · Canvas-based react-force-graph view excluded from server rendering.
components/NetworkGraph.tsx - Account info panel
components/AccountInfoPanel.tsx - Insight panel
components/InsightPanel.tsx - Ring card
components/RingCard.tsx
HTTP API
Browser clients access graph data only through route handlers.
- Account lookup API
app/api/account/[id]/route.ts - Analysis API · Retrieves evidence before requesting interpretation.
app/api/analyze/[id]/route.ts - Ring discovery API
app/api/rings/route.ts - Search API
app/api/search/route.ts
Investigation Services
- Graph queries · Parameterized, bounded traversals for neighborhoods, chains, and shared attributes.
lib/queries.ts - Evidence analyzer · Converts structured graph evidence into fraud-pattern interpretation.
lib/analyzer.ts - Neo4j driver singleton · Pooled Bolt/openCypher connection boundary.
lib/db.ts - Synthetic graph seed · Generates sample data and hidden fraud rings outside request handling.
scripts/seed.ts
Data and AI
- CognoDB Cloud · Accounts connect to devices, IPs, phones, and transactions.
- Gemini · Receives retrieved structured evidence, not database access.
Connections 21
- Root layout → Search dashboard: wraps
- Search dashboard → Search bar: composes
- Search dashboard → Dashboard data hook: loads data
- Account investigation → Account analysis hook: loads investigation
- Account investigation → Account info panel: renders facts
- Account investigation → Network graph: renders network
- Account investigation → Insight panel: renders explanation
- Ring dashboard → Ring card: renders clusters
- Dashboard data hook → Search API: searches
- Dashboard data hook → Ring discovery API: loads rings
- Account analysis hook → Account lookup API: loads account and network
- Account analysis hook → Analysis API: requests explanation
- Account lookup API → Graph queries: retrieves evidence
- Search API → Graph queries: searches accounts
- Ring discovery API → Graph queries: finds shared-attribute clusters
- Analysis API → Graph queries: retrieves factual evidence
- Analysis API → Evidence analyzer: interprets evidence
- Graph queries → Neo4j driver singleton: executes Cypher
- Neo4j driver singleton → CognoDB Cloud: Bolt/openCypher
- Evidence analyzer → Gemini: structured evidence
- Synthetic graph seed → Neo4j driver singleton: provisions graph