Appearance
Repositories
Four sibling checkouts inside ~/Documents/blazpay/defi-set, plus loose planning documents at that root.
At a glance
| Repo | Stack | Deploy target | Branch |
|---|---|---|---|
bz-agent | TypeScript, LangChain, LangGraph, Express | GCP VM :4000 | main |
bz-backend | Node ESM, Express, MongoDB, Redis, Socket.io | GCP VM :5000 | bishtNew |
defi-dex | React 18, Vite, Tailwind, ethers v5 | Netlify (two sites) | optimized |
swap-sdk | TypeScript, ethers v6, TronWeb | Consumed as a git dependency | tags vX.Y.Z |
ethers v5 and v6 coexist
defi-dex and bz-backend use ethers 5.7; swap-sdk uses ethers 6. They are not API-compatible (ethers.utils.* versus top-level exports, BigNumber versus bigint, providers.JsonRpcProvider versus JsonRpcProvider). When moving code between the SDK and either consumer, expect to rewrite every ethers call.
bz-agent
src/
agent/ graph.ts, node.ts, index.ts, vector.ts,
bzTokenNode.ts, createDappNode.ts,
goOnchainNode.ts, modifyDappNode.ts
template/ one prompt per intent (23 files)
controllers/ agent, chat, store
models/ agent.model.ts, store.model.ts
routes/ agent.ts, store.ts, index.ts
services/ db, feature, redis
utils/ constant.ts (AVAILABLE_INTENTS), models.ts (LLM tiers),
redisCheckPointer.ts, info.ts, logger.ts, utils.ts
validations/ joi schemas
middleware/ auth.ts| Fact | Value |
|---|---|
| Entry | src/index.ts → src/app.ts |
| Dev | npm run dev (tsx watch) |
| Build | npm run build (tsc → build/) |
| Start | npm start |
| Types check | npm run check-types |
| Persistence | MongoDB (@langchain/mongodb), PostgreSQL + PGVector (pg) |
| Checkpointing | Redis (ioredis) |
| Validation | Zod for LLM output, Joi for HTTP input |
Deploys with BUILD=yes — unlike the backend, it is compiled on the VM.
bz-backend
The monolith. Roughly 130 Mongo models, 65 route files and 60+ service directories.
index.js app bootstrap, CORS allowlist, cron start
routes/ 65 files → mounted at /api
v1/ newer surface → mounted at /api/v1
routes/ controllers/ services/ models/
controllers/
defi/ one file per provider + swap, transaction, DCA, autopilot
ai/ legacy swap-ai chat
services/
swap.service.js quote fan-out
executionEngine.js shared quote/probe/submit
dcaCron.js CSIP executor
autopilot*.js cron, engine, prices, sync
portfolio.js Zerion
*-service/ per-module directories
models/ 130+ schemas
utils/
constants.js addresses, signature types, Orderly config
policy.js Autopilot policy toolkit
abi/ contract ABIs, incl. per-chain directories
orderlySigner.js kms.js redis.js
middleware/
walletAuth.js signature auth for mutating Autopilot routes
authMiddleware.js JWT
contract-deployment/
contracts/ Solidity: relayer, dca/, autopilot/, modular/, poker/,
per-chain copies, deprecated/
scripts/ deploy, upgrade, probe, deployment records
test/ autopilot.test.cjs (61 passing)
scripts/ deploy.gcp.sh, seeders, one-off maintenance
postman/ collections
docs/ examples/ gateway/ tasks/ validations/
archive/ new-backend/ microservices-backend/| Fact | Value |
|---|---|
| Entry | index.js |
| Dev | npm run dev (nodemon) |
| Start | npm start |
| Tests | None for the backend itself (npm test exits 1). Contract tests live in contract-deployment/test/ |
| Mounts | /api (legacy), /api/v1 (new), /api/pinata |
| Process manager | PM2, app name bz-backend |
| Cron gate | CRON != 'false' |
routes/ versus v1/routes/
routes/ is the original surface. v1/ holds BlazAI, the dApp builder, audit, safety, wallet cards, training data, feedback and notifications — and has a cleaner routes/controllers/services/models split. New AI-adjacent work goes in v1. Both are live and neither is deprecated.
archive/, new-backend/ and microservices-backend/ are dead weight in the tree
They are not mounted. But because the production deploy is rsync mode, they are copied to the VM on every deploy. Do not treat anything in them as live.
defi-dex
src/
index.tsx 3 KB dispatcher — marketing regex → MarketingApp,
else FullApp; AI shell via VITE_SITE
FullApp.tsx the trading shell
MarketingApp.tsx light tree for prerendered marketing routes
AiApp.tsx the chat shell
providers/AppProviders.tsx shared provider tree
config/site.ts SITE_ID, IS_AI_SITE, CHAT_ROOT, chatPath, isChatPath
routes/ index.tsx, aiRoutes.tsx, path.tsx, RootErrorBoundary.tsx
layouts/ MainLayout, AiLayout, AiContentLayout, MarketingLayout
pages/
defi/ swap, bridge, buy, perpetual, limit, csip, autopilot,
overview, history, home/
seo/ ChainLandingPage, ChainsHub, BridgeRoutePage,
FeatureLandingPage, ComparePage
audit/ AuditReport, AuditCertificate, TokenSafety,
TokenSafetyEmbed, WalletCard
defiLandingPage/ /about
component/
defi/swapAI/ chat: index, BotMessage, ResponseCard, SidebarBlazAi,
actions/, quotes/, portfolio/, Dca/, dapp/, buy/, presale/
defi/csip/ CSIP UI
defi/autopilot/ wizard, list, detail, killswitch
ai/ WalletControl, PaletteTrigger, CommandPalette, pill.ts
SiteFooter.tsx SEOHead.tsx comingsoon/
data/ chainSeo.mjs, bridgeRouteSeo.mjs, featureSeo.mjs,
compareSeo.mjs — framework-free ESM
utils/ trade.ts, autopilotPolicy.ts, chainPreselect.ts,
axios.ts, analytics.ts, swap.ts, functions.ts
apis/ defi.api.ts, ai.api.ts, autopilot.api.ts
state/ Redux — legacy on-chain DEX path
constants/abis/ dca.json, autopilot.json, …
contexts/ hooks/ theme/ types/
scripts/
prerender-seo.mjs 114 static pages + sitemap + llms.txt
generate-og.mjs per-page OG PNGs
rewrite-ai-shell.mjs mandatory for build:ai
check-routes.mjs phase-aware route check
indexnow-submit.mjs
plugins/netlify-plugin-indexnow/
netlify.toml netlify.ai.toml .env.ai
design/bridge-redesign-concept1.html
HERO_ASSETS.md| Script | Does |
|---|---|
npm run dev | Defi shell on :5173 |
npm run dev:ai | AI shell on :5174 |
npm run build | vite build → prerender-seo.mjs → generate-og.mjs |
npm run build:app | vite build only |
npm run build:ai | vite build --mode ai --outDir dist-ai → rewrite-ai-shell.mjs |
npm run preview:ai | Serve dist-ai on :4174 |
npm run check:routes | Route sanity check; -- --cutover for the AI cutover phase |
npm run prerender | Prerender only |
npm run indexnow | Manual IndexNow submission |
npx tsc --noEmit has ~3,300 pre-existing errors from node_modules
vite build is the real gate. Do not chase tsc to zero as part of an unrelated change.
swap-sdk
src/
index.ts TradeManager — registers every aggregator
aggregator.factory.ts Map<name, aggregator>, parallel fan-out
relayer.ts RelayerFactory — MetaTransaction assembly
aggregators/
base.aggregator.ts shared helpers
<Provider>.aggregator.ts × 26
index.ts
enums/aggregator.enum.ts AGGREGATORS
utils/
constants.ts ChainId, ChainName, RELAYER_ADDRESSES,
RELAYER_DEPLOYED_CHAINS, routers, baseUrl
config.ts configure({ openOceanApiKey, unizenApiKey, baseApiUrl })
quote.ts Quote wrapper
axios.ts helper.ts types.ts
jsons/relayerAbi.ts
@types/ aggregator, chain, quote, relayer, globals| Fact | Value |
|---|---|
| Version | 1.12.0 |
| Module type | ESM ("type": "module"), .js extensions in imports |
| Build | tsc → dist/, run automatically by prepare |
| Distribution | Git tags. github:blazpay/swap-sdk#vX.Y.Z |
| Embedded secrets | None. Keys come from configure() |
Bumping the pin requires updating the lockfile too
package-lock.json pins by resolved commit and npm install obeys it even after rm -rf node_modules/swap-sdk. Run npm install github:blazpay/swap-sdk#vX.Y.Z --package-lock-only and commit both files. See swap-sdk releases.
finalContracts
A frozen snapshot of the v1 relayer with its OpenZeppelin dependency tree, plus deployment metadata:
finalContracts/
bsc/BlazpayRelayer.sol + access/ utils/ interfaces/ proxy/
deployed/BlazpayRelayer.deployed.sol
deployed/metadata.json
deployed/creator-tx-hash.txtThis is v1, not what is deployed
The authoritative current source is bz-backend/contract-deployment/contracts/BlazpayRelayer.sol (v2). finalContracts/ is a verification artefact. The v1 source notably requires signer == msg.sender, whereas v2 requires recovered == signer (the platform's TX_SIGNER) — a substantive difference. Read v2.
Root planning documents
Not code, but load-bearing. Read the relevant one before touching its subsystem.
| File | Subject |
|---|---|
AUTOPILOT_AND_COPYTRADE_PLAN.md | Autopilot spec and the copy-trading plan. 57 KB, work in blocks |
AI_SPLIT_PLAN.md | Domain map, 301 table, phases, risks for the AI split |
AI_SITE_SETUP.md | AI shell rationale, testing plan, cutover runbook |
DAPP_BUILDER_ARCHITECTURE.md | Full dApp builder design |
DAPP_BUILDER_PROGRESS.md | Build log |
BLAZPAY_FEATURE_INVENTORY_FOR_MARKETING.md | Master fact sheet — but see its own accuracy notes |
BLAZPAY_PRESS_BRIEF.md | Press positioning |
BlazAI_Current_Features.md, BlazAI_README.md | Older AI feature snapshots |
SYSTEM_ARCHITECTURE_NOTES.md | Early architecture notes |
MIGRATION.md | A migration record |
TOKEN_PAYMENT_ANALYTICS_API.md, TRANSACTION_V2_ANALYTICS_API.md | Analytics API specs |
Dependency graph
bz-agent depends on neither the SDK nor the backend — it is called, and calls nothing back. That is what makes it safe to redeploy independently.