Skip to content

TheAhsanFarabi/dispatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dispatch

Visual API scenario runner with a chaos fuzzer, auth lifecycle simulator, and contract drift detector

Next.js TypeScript Zustand License

Features Β· Getting started Β· How it works Β· Deploy Β· Roadmap


What is Dispatch?

Dispatch is a browser-based API testing tool built with Next.js. Instead of a flat list of requests, you build visual scenario graphs β€” nodes wired together with edges, where each node is an HTTP request. Data flows between nodes automatically: a token captured from login feeds into the Authorization header of the next request without any manual scripting.

On top of that, Dispatch ships three primitives that Postman doesn't have:

  • Chaos fuzzer β€” auto-generates malformed payloads and classifies anomalies
  • Auth lifecycle simulator β€” tests the full token lifecycle including concurrent refresh races and post-logout token reuse
  • Contract drift detector β€” snapshots your API's response schema and alerts when it silently changes

Features

Scenario flow builder

  • Drag-and-drop canvas β€” add Request nodes, wire them together
  • Branching execution β€” if a node fails, its entire downstream branch halts. Sibling branches continue independently
  • Variable extraction β€” pull values from any response using JSONPath ($.token, $.data[0].id, $..email) and inject them into subsequent requests as {{varName}}
  • 6 assertion operators β€” eq, neq, contains, exists, gt, lt
  • Abort mid-run β€” stop any in-flight scenario instantly
  • Single-node fire β€” run just the selected node against current environment variables
  • Scenarios persist to localStorage β€” no account required

Chaos fuzzer

8 mutation strategies fired against your endpoint:

Strategy What it probes
Null fields Crashes from unguarded null access
Empty strings Missing server-side validation
Boundary numbers Integer overflow, off-by-one bugs
XSS strings Reflected XSS, unsanitized echo
SQL injection ' OR 1=1--, UNION SELECT, DROP TABLE
Type confusion String where number expected, vice versa
Extra fields Mass assignment β€” admin: true, role: "superuser"
Missing fields Unhandled missing required fields

Anomalies classified: unexpected 2xx on malformed input, stack trace leaks in 500 bodies, server errors, slow responses (>5s).

Auth lifecycle simulator

Runs 7 phases against your auth endpoints:

  1. Login β€” captures access + refresh tokens
  2. Use valid token β€” hits a protected resource
  3. Invalid token β€” expects 401/403; flags if server returns 200
  4. Refresh token β€” exchanges refresh token for new access token
  5. Concurrent refresh race β€” fires two refresh requests simultaneously via Promise.all; classifies whether the API enforces single-use
  6. Logout β€” invalidates the session
  7. Post-logout reuse β€” tries the old token after logout; flags as SECURITY RISK if it still works

Contract drift detector

  • Captures a full field-level schema snapshot of any response (paths, types, nullable flags, nested objects, arrays)
  • Snapshots persist to localStorage across sessions
  • Drift report classifies every change: field added, field removed, type changed, nullable changed
  • Run after every deploy to catch silent breaking changes

Getting started

Prerequisites

  • Node.js 18+
  • npm

Local development

# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/dispatch.git
cd dispatch

# 2. Install dependencies
npm install

# 3. Start the dev server
npm run dev

Open http://localhost:3000.

Quick start

  1. Click Load example in the topbar β€” this loads a 3-node JSONPlaceholder scenario
  2. Hit Run scenario β€” watch nodes turn green as they execute
  3. Click any node β†’ inspect the Response tab to see the live response
  4. Select a POST node β†’ open the Fuzzer tab β†’ pick strategies β†’ Run fuzzer

How it works

Project structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ page.tsx                 # Root β€” composes Topbar + Sidebar + Canvas + Inspector
β”‚   β”œβ”€β”€ globals.css              # Dark theme, IBM Plex Sans / JetBrains Mono
β”‚   └── api/
β”‚       β”œβ”€β”€ proxy/route.ts       # Server-side proxy β€” all requests route through here (no CORS)
β”‚       └── scenarios/route.ts   # Stub route (persistence is localStorage-based)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Topbar.tsx               # Run, Stop, Save, Load example, Clear
β”‚   β”œβ”€β”€ sidebar/Sidebar.tsx      # Node palette, environment display, tips
β”‚   β”œβ”€β”€ canvas/
β”‚   β”‚   β”œβ”€β”€ Canvas.tsx           # Drop zone, drag, port wiring, mouse events
β”‚   β”‚   β”œβ”€β”€ FlowNodeCard.tsx     # Individual node β€” method badge, ports, status dot
β”‚   β”‚   └── EdgeLayer.tsx        # SVG bezier edges with status colours + arrow markers
β”‚   └── inspector/
β”‚       β”œβ”€β”€ Inspector.tsx        # 6-tab shell: Config Β· Response Β· Fuzzer Β· Contract Β· Auth Β· Log
β”‚       β”œβ”€β”€ ConfigTab.tsx        # Method, URL, headers, body, extracts, assertions
β”‚       β”œβ”€β”€ ResponseTab.tsx      # Status pill, assertion results, response body
β”‚       β”œβ”€β”€ FuzzerTab.tsx        # Strategy picker, progress, anomaly results
β”‚       β”œβ”€β”€ ContractTab.tsx      # Capture baseline, schema viewer, drift report
β”‚       β”œβ”€β”€ AuthTab.tsx          # Auth config form, 7-phase lifecycle runner
β”‚       └── LogTab.tsx           # Timestamped run log
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ executor.ts              # Shared executeNode() β€” single source of truth for run logic
β”‚   β”œβ”€β”€ fuzzer.ts                # Mutation generators + anomaly classifier
β”‚   β”œβ”€β”€ auth.ts                  # 7-phase auth lifecycle runner
β”‚   β”œβ”€β”€ contract.ts              # Schema inference, snapshot persistence, drift diff
β”‚   └── jsonpath.ts              # jsonpath-plus wrapper with bare-path normalisation
β”œβ”€β”€ store/
β”‚   └── flow.ts                  # Zustand + Immer + persist β€” all state + BFS runner
└── types/
    └── index.ts                 # Shared TypeScript interfaces

Execution model

The scenario runner uses BFS (breadth-first search) with a topological node ordering:

  • Root nodes (no incoming edges) are queued first
  • Each node is executed in order; extracted variables are merged into shared environment immediately
  • If a node fails its assertions, its downstream branch is halted β€” but sibling branches continue
  • A currentRunId guard prevents overlapping runs if the user hits Run twice

Proxy route

All HTTP requests are routed through /api/proxy (a Next.js Route Handler). This runs server-side, so there are no CORS restrictions β€” you can test any API regardless of its CORS policy.

Variable system

Use {{varName}} in any URL, header value, or body. Variables are resolved at execution time from the shared environment. Extraction uses jsonpath-plus β€” full JSONPath including bracket notation, wildcards, and recursive descent:

$.token              β†’ top-level field
$.data[0].id         β†’ first element of array
$.items[*].email     β†’ all emails in array (returns array)
$..name              β†’ recursive descent

Usage guide

Building a scenario

  1. Add nodes β€” drag from the left sidebar onto the canvas, or double-click a node type
  2. Wire nodes β€” hover a node's right port (β—‹), click and drag to another node
  3. Configure β€” click any node, edit in the Config tab: method, URL, headers, body
  4. Extract variables β€” in Config tab, add an extract: name the variable, write the JSONPath. E.g. key token, path $.token
  5. Use variables β€” in downstream nodes, write {{token}} anywhere in the URL, headers, or body
  6. Add assertions β€” click "add assertion" in Config: choose a path, operator, and expected value
  7. Run β€” hit Run scenario in the topbar

Using the fuzzer

  1. Select a POST/PUT/PATCH node that has a JSON body configured
  2. Open the Fuzzer tab
  3. Select strategies (start with Null fields + Missing fields + Type confusion)
  4. Click Run fuzzer
  5. Switch filter to Anomalies only β€” investigate any flagged results

Using the auth simulator

  1. Open the Auth tab (no node needs to be selected)
  2. Fill in your Login URL and login body JSON
  3. Set the Token JSONPath to wherever the token lives in your login response
  4. Fill in a Protected URL that requires auth
  5. Optionally fill Refresh URL and Logout URL
  6. Click Run auth lifecycle
  7. Watch each phase β€” red phases indicate failures worth investigating

Capturing a contract baseline

  1. Select a node and run it so it has a live response
  2. Open the Contract tab
  3. Click Capture baseline β€” the full response schema is saved
  4. Later (after a deploy, after a PR merges) β€” run the node again, then click Check drift
  5. Any field-level changes surface in the drift report

Comparison with Postman

Dispatch Postman
Visual flow canvas βœ… ❌ Flat list
Branching halt on failure βœ… ❌
Chaos fuzzer βœ… 8 strategies ❌
Auth lifecycle simulator βœ… 7 phases + race test ❌
Contract drift detection βœ… Field-level ❌
Full JSONPath support βœ… jsonpath-plus βœ…
No install / no account βœ… ❌ Requires account
Team collaboration ❌ βœ…
Pre/post scripts ❌ βœ… JS sandbox
CI/CD CLI ❌ planned βœ… Newman
Mock servers ❌ βœ…

Roadmap

  • CLI runner (dispatch run scenario.json) for CI/CD pipelines
  • Export scenarios as JSON / import from Postman collections
  • Vercel KV integration for cloud persistence and sharing
  • Time-travel debugger β€” replay any past run against the current API
  • Collaborative live canvas (Figma-style cursor presence)
  • OpenAPI spec import β†’ auto-generate scenario from spec

Tech stack


License

MIT β€” see LICENSE for details.


Built with Next.js Β· Deployed on Vercel

About

API Senario Runner

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors