# vakeer56/exploitx architecture

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

- Interactive diagram: https://gitdiagram.com/vakeer56/exploitx
- Repository: https://github.com/vakeer56/exploitx

## Overview

#### Purpose and Runtime Entry Points
ExploitX is a MERN financial-crime investigation platform for tracing illicit cryptocurrency movement, scoring risk, estimating interception windows, and producing investigator-facing outputs. Express starts from `backend/server.js`, composes middleware/routes in `backend/src/app.js`, and serves `/api`. The primary React/Vite client boots at `frontend/src/main.jsx` and routes/views are composed in `frontend/src/App.jsx`.

#### Persistence and Case State
MongoDB is the production system of record for transactions, graph edges, investigations, scam/bridge intelligence, console consensus state, synthetic cases, and copilot plans. Database definitions and driver initialization are in `backend/src/db/definitions.js` and `backend/src/db/index.js`; `backend/src/db/memoryDriver.js` is an explicitly non-persistent demo/test alternative. Initial/demo data is seeded through `backend/src/seed/seed.js` and `demo/seed_data.json`.

#### Investigation Pipeline
`POST /api/investigate/:txHash` enters through `backend/src/routes/investigate.js` and orchestrates the pipeline in `backend/src/services/pipeline.js`:
1. acquire/store transaction evidence;
2. expand transaction relationships;
3. evaluate risk signals;
4. compute the golden interception window;
5. produce evidence-grounded narration;
6. persist the completed investigation for later reports.
This is the main control boundary between HTTP/API handling and forensic domain engines.

#### Chain Intake and Graph Expansion
Ingestion hashes and stores incoming evidence in `backend/src/ingestion/hashAndStore.js`. Live and synthetic chain sources are abstracted behind adapters: `backend/src/adapters/liveChainRouter.js`, `backend/src/adapters/explorerAdapter.js`, and `backend/src/adapters/syntheticCaseAdapter.js`. Provider implementations include Etherscan, public RPC, and Solana under `backend/src/adapters/providers/`. `backend/src/engines/graphEngine.js` traverses persisted directed edges subject to graph/fan-out configuration, while `backend/src/adapters/bridgeAdapter.js` and `backend/src/graph/mixerIndex.js` identify cross-chain and mixer boundaries.

#### Detection, Timing, and Async Follow-up
`backend/src/engines/detectionEngine.js` applies weighted behavioral rules, including scam intelligence, rapid fan-out, structuring, bridge exits, and other configured indicators. `backend/src/engines/raceEngine.js` estimates probabilistic settlement/interception windows. Long-running deep tracing and revictimization monitoring are separated from request work through `backend/src/queues/deepTraceQueue.js`, `backend/src/workers/deepTraceWorker.js`, `backend/src/queues/revictimizationQueue.js`, and `backend/src/workers/revictimizationWorker.js`.

#### Governance, Access, and Audit
Consensus-based changes to detection weights are handled by `backend/src/console/analystConsole.js` and persisted via `backend/src/console/consoleRepository.js`; API exposure is in `backend/src/routes/console.js`. Authorization is attribute/policy oriented: `backend/src/security/middleware.js`, `backend/src/security/policyEngine.js`, and the OPA policy `policies/access.rego`. Authentication, case-read resolution, cross-jurisdiction grants, rank enforcement, and audit logging form a security boundary under `backend/src/security/`.

#### Narration, Copilot, and Reporting
Narration combines deterministic facts/templates with an optional self-hosted Ollama phi3 model: `backend/src/engines/narrationLayer.js`, `backend/src/narration/llamaClient.js`, and `backend/src/narration/narrationFacts.js`. Failure or timeout falls back locally rather than calling third-party AI. The analyst-approved query-plan flow is isolated in `backend/src/copilot/investigationCopilot.js` and `backend/src/routes/copilot.js`. Investigation evidence becomes case packets, PDFs, prosecutor briefs, and victim advisories through `backend/src/reporting/casePacket.js`, `backend/src/reporting/pdfReport.js`, and `backend/src/reporting/prosecutorBriefGenerator.js`.

#### External Boundaries and Deployment
Material services are MongoDB, optional local/controlled Ollama, and blockchain/scam-data providers represented by `backend/src/adapters/providers/` and `backend/src/adapters/scamDbAdapter.js`; circuit breakers protect provider access in `backend/src/adapters/circuitBreakers.js`. Law-enforcement workflow integrations are adapterized in `backend/src/integrations/ncrpIntakeAdapter.js`, `backend/src/integrations/cctnsCaseLinkAdapter.js`, and `backend/src/integrations/fiuFreezeAdapter.js`. Container topology is defined by `backend/Dockerfile` and `docker-compose.yml`.

Main entry points: [`backend/src/services/pipeline.js`](https://github.com/vakeer56/exploitx/blob/main/backend/src/services/pipeline.js) (Investigation pipeline), [`backend/src/db/index.js`](https://github.com/vakeer56/exploitx/blob/main/backend/src/db/index.js) (MongoDB case store), [`backend/src/ingestion/hashAndStore.js`](https://github.com/vakeer56/exploitx/blob/main/backend/src/ingestion/hashAndStore.js) (Evidence hashing & storage), [`backend/src/engines/graphEngine.js`](https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/graphEngine.js) (Relationship expansion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Investigator Client"]
  node_react_client["React/Vite client<br/>web client<br/>[main.jsx]"]
  node_client_routes["Investigation views<br/>React routes<br/>[App.jsx]"]
end

subgraph group_api["API &amp; Security"]
  node_express_server["Express API<br/>HTTP server<br/>[server.js]"]
  node_app_composition["App routes &amp; middleware<br/>Express composition<br/>[app.js]"]
  node_security_boundary{{"Policy authorization<br/>security middleware<br/>[middleware.js]"}}
  node_investigate_route["Investigation endpoint<br/>API route<br/>[investigate.js]"]
end

subgraph group_forensics["Forensic Pipeline"]
  node_pipeline{{"Investigation pipeline<br/>orchestrator<br/>[pipeline.js]"}}
  node_evidence_ingestion["Evidence hashing &amp; storage<br/>ingestion service<br/>[hashAndStore.js]"]
  node_chain_adapters["Chain source adapters<br/>adapter layer<br/>[liveChainRouter.js]"]
  node_graph_engine["Relationship expansion<br/>graph engine<br/>[graphEngine.js]"]
  node_boundary_intelligence["Bridge &amp; mixer detection<br/>graph intelligence<br/>[bridgeAdapter.js]"]
  node_detection_engine["Risk scoring<br/>detection engine<br/>[detectionEngine.js]"]
  node_race_engine["Interception window<br/>timing engine<br/>[raceEngine.js]"]
  node_narration_layer["Evidence narration<br/>narration engine<br/>[narrationLayer.js]"]
end

subgraph group_operations["Async, Governance &amp; Outputs"]
  node_async_workers["Deep trace &amp; monitoring<br/>background workers<br/>[deepTraceWorker.js]"]
  node_analyst_console["Detection-weight consensus<br/>governance console<br/>[analystConsole.js]"]
  node_copilot["Approved query plans<br/>analyst copilot"]
  node_reporting["Case packets &amp; briefs<br/>reporting service<br/>[casePacket.js]"]
end

subgraph group_external["Data &amp; External Services"]
  node_mongodb[("MongoDB case store<br/>system of record<br/>[index.js]")]
  node_provider_services["Blockchain &amp; scam providers<br/>external providers"]
  node_ollama["Local Ollama phi3<br/>optional model service<br/>[llamaClient.js]"]
  node_law_enforcement["Law-enforcement systems<br/>workflow integrations"]
end

node_react_client -->|"renders"| node_client_routes
node_client_routes -->|"/api requests"| node_express_server
node_express_server -->|"composes"| node_app_composition
node_app_composition -->|"applies"| node_security_boundary
node_security_boundary -->|"authorizes"| node_investigate_route
node_investigate_route -->|"POST investigate"| node_pipeline
node_pipeline -->|"acquires evidence"| node_evidence_ingestion
node_evidence_ingestion -->|"fetches chain data"| node_chain_adapters
node_chain_adapters -->|"queries"| node_provider_services
node_evidence_ingestion -->|"stores hashed evidence"| node_mongodb
node_pipeline -->|"expands relationships"| node_graph_engine
node_graph_engine -->|"reads persisted edges"| node_mongodb
node_graph_engine -->|"checks boundaries"| node_boundary_intelligence
node_pipeline -->|"evaluates risk"| node_detection_engine
node_detection_engine -->|"uses intelligence"| node_mongodb
node_pipeline -->|"estimates window"| node_race_engine
node_pipeline -->|"builds narrative"| node_narration_layer
node_narration_layer -.->|"optional generation"| node_ollama
node_pipeline -->|"persists investigation"| node_mongodb
node_pipeline -.->|"queues follow-up"| node_async_workers
node_async_workers -->|"updates cases"| node_mongodb
node_analyst_console -->|"governs weights"| node_detection_engine
node_analyst_console -->|"persists consensus"| node_mongodb
node_copilot -->|"stores approved plans"| node_mongodb
node_reporting -->|"reads investigation evidence"| node_mongodb
node_reporting -->|"supports workflow"| node_law_enforcement

click node_react_client "https://github.com/vakeer56/exploitx/blob/main/frontend/src/main.jsx"
click node_client_routes "https://github.com/vakeer56/exploitx/blob/main/frontend/src/App.jsx"
click node_express_server "https://github.com/vakeer56/exploitx/blob/main/backend/server.js"
click node_app_composition "https://github.com/vakeer56/exploitx/blob/main/backend/src/app.js"
click node_security_boundary "https://github.com/vakeer56/exploitx/blob/main/backend/src/security/middleware.js"
click node_investigate_route "https://github.com/vakeer56/exploitx/blob/main/backend/src/routes/investigate.js"
click node_pipeline "https://github.com/vakeer56/exploitx/blob/main/backend/src/services/pipeline.js"
click node_evidence_ingestion "https://github.com/vakeer56/exploitx/blob/main/backend/src/ingestion/hashAndStore.js"
click node_chain_adapters "https://github.com/vakeer56/exploitx/blob/main/backend/src/adapters/liveChainRouter.js"
click node_graph_engine "https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/graphEngine.js"
click node_boundary_intelligence "https://github.com/vakeer56/exploitx/blob/main/backend/src/adapters/bridgeAdapter.js"
click node_detection_engine "https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/detectionEngine.js"
click node_race_engine "https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/raceEngine.js"
click node_narration_layer "https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/narrationLayer.js"
click node_mongodb "https://github.com/vakeer56/exploitx/blob/main/backend/src/db/index.js"
click node_ollama "https://github.com/vakeer56/exploitx/blob/main/backend/src/narration/llamaClient.js"
click node_async_workers "https://github.com/vakeer56/exploitx/blob/main/backend/src/workers/deepTraceWorker.js"
click node_analyst_console "https://github.com/vakeer56/exploitx/blob/main/backend/src/console/analystConsole.js"
click node_copilot "https://github.com/vakeer56/exploitx/blob/main/backend/src/copilot/investigationCopilot.js"
click node_reporting "https://github.com/vakeer56/exploitx/blob/main/backend/src/reporting/casePacket.js"
click node_law_enforcement "https://github.com/vakeer56/exploitx/blob/main/backend/src/integrations/fiuFreezeAdapter.js"

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_react_client,node_client_routes toneBlue
class node_express_server,node_app_composition,node_security_boundary,node_investigate_route toneAmber
class node_pipeline,node_evidence_ingestion,node_chain_adapters,node_graph_engine,node_boundary_intelligence,node_detection_engine,node_race_engine,node_narration_layer toneMint
class node_async_workers,node_analyst_console,node_copilot,node_reporting toneRose
class node_mongodb,node_provider_services,node_ollama,node_law_enforcement toneIndigo
```

## Components

### Investigator Client

- [React/Vite client](https://github.com/vakeer56/exploitx/blob/main/frontend/src/main.jsx): web client · `frontend/src/main.jsx`
- [Investigation views](https://github.com/vakeer56/exploitx/blob/main/frontend/src/App.jsx): React routes · `frontend/src/App.jsx`

### API & Security

- [Express API](https://github.com/vakeer56/exploitx/blob/main/backend/server.js): HTTP server · Serves the /api boundary. · `backend/server.js`
- [App routes & middleware](https://github.com/vakeer56/exploitx/blob/main/backend/src/app.js): Express composition · `backend/src/app.js`
- [Policy authorization](https://github.com/vakeer56/exploitx/blob/main/backend/src/security/middleware.js): security middleware · Enforces attributes, grants, rank, and audit. · `backend/src/security/middleware.js`
- [Investigation endpoint](https://github.com/vakeer56/exploitx/blob/main/backend/src/routes/investigate.js): API route · `backend/src/routes/investigate.js`

### Forensic Pipeline

- [Investigation pipeline](https://github.com/vakeer56/exploitx/blob/main/backend/src/services/pipeline.js): orchestrator · Coordinates acquisition through persisted investigation. · `backend/src/services/pipeline.js`
- [Evidence hashing & storage](https://github.com/vakeer56/exploitx/blob/main/backend/src/ingestion/hashAndStore.js): ingestion service · `backend/src/ingestion/hashAndStore.js`
- [Chain source adapters](https://github.com/vakeer56/exploitx/blob/main/backend/src/adapters/liveChainRouter.js): adapter layer · Routes live and synthetic chain evidence. · `backend/src/adapters/liveChainRouter.js`
- [Relationship expansion](https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/graphEngine.js): graph engine · Traverses directed edges within fan-out limits. · `backend/src/engines/graphEngine.js`
- [Bridge & mixer detection](https://github.com/vakeer56/exploitx/blob/main/backend/src/adapters/bridgeAdapter.js): graph intelligence · `backend/src/adapters/bridgeAdapter.js`
- [Risk scoring](https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/detectionEngine.js): detection engine · Applies weighted behavioral and scam signals. · `backend/src/engines/detectionEngine.js`
- [Interception window](https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/raceEngine.js): timing engine · `backend/src/engines/raceEngine.js`
- [Evidence narration](https://github.com/vakeer56/exploitx/blob/main/backend/src/engines/narrationLayer.js): narration engine · Uses local deterministic fallback on model failure. · `backend/src/engines/narrationLayer.js`

### Async, Governance & Outputs

- [Deep trace & monitoring](https://github.com/vakeer56/exploitx/blob/main/backend/src/workers/deepTraceWorker.js): background workers · Separates long-running tracing and revictimization monitoring. · `backend/src/workers/deepTraceWorker.js`
- [Detection-weight consensus](https://github.com/vakeer56/exploitx/blob/main/backend/src/console/analystConsole.js): governance console · `backend/src/console/analystConsole.js`
- [Approved query plans](https://github.com/vakeer56/exploitx/blob/main/backend/src/copilot/investigationCopilot.js): analyst copilot · `backend/src/copilot/investigationCopilot.js`
- [Case packets & briefs](https://github.com/vakeer56/exploitx/blob/main/backend/src/reporting/casePacket.js): reporting service · `backend/src/reporting/casePacket.js`

### Data & External Services

- [MongoDB case store](https://github.com/vakeer56/exploitx/blob/main/backend/src/db/index.js): system of record · Stores evidence, graphs, cases, intelligence, and plans. · `backend/src/db/index.js`
- **Blockchain & scam providers**: external providers · Provider adapters are circuit-breaker protected.
- [Local Ollama phi3](https://github.com/vakeer56/exploitx/blob/main/backend/src/narration/llamaClient.js): optional model service · `backend/src/narration/llamaClient.js`
- [Law-enforcement systems](https://github.com/vakeer56/exploitx/blob/main/backend/src/integrations/fiuFreezeAdapter.js): workflow integrations · `backend/src/integrations/fiuFreezeAdapter.js`

## Connections

- React/Vite client → Investigation views: renders
- Investigation views → Express API: /api requests
- Express API → App routes & middleware: composes
- App routes & middleware → Policy authorization: applies
- Policy authorization → Investigation endpoint: authorizes
- Investigation endpoint → Investigation pipeline: POST investigate
- Investigation pipeline → Evidence hashing & storage: acquires evidence
- Evidence hashing & storage → Chain source adapters: fetches chain data
- Chain source adapters → Blockchain & scam providers: queries
- Evidence hashing & storage → MongoDB case store: stores hashed evidence
- Investigation pipeline → Relationship expansion: expands relationships
- Relationship expansion → MongoDB case store: reads persisted edges
- Relationship expansion → Bridge & mixer detection: checks boundaries
- Investigation pipeline → Risk scoring: evaluates risk
- Risk scoring → MongoDB case store: uses intelligence
- Investigation pipeline → Interception window: estimates window
- Investigation pipeline → Evidence narration: builds narrative
- Evidence narration → Local Ollama phi3: optional generation
- Investigation pipeline → MongoDB case store: persists investigation
- Investigation pipeline → Deep trace & monitoring: queues follow-up
- Deep trace & monitoring → MongoDB case store: updates cases
- Detection-weight consensus → Risk scoring: governs weights
- Detection-weight consensus → MongoDB case store: persists consensus
- Approved query plans → MongoDB case store: stores approved plans
- Case packets & briefs → MongoDB case store: reads investigation evidence
- Case packets & briefs → Law-enforcement systems: supports workflow
