Skip to content

Repositories

Four sibling checkouts inside ~/Documents/blazpay/defi-set, plus loose planning documents at that root.

At a glance

RepoStackDeploy targetBranch
bz-agentTypeScript, LangChain, LangGraph, ExpressGCP VM :4000main
bz-backendNode ESM, Express, MongoDB, Redis, Socket.ioGCP VM :5000bishtNew
defi-dexReact 18, Vite, Tailwind, ethers v5Netlify (two sites)optimized
swap-sdkTypeScript, ethers v6, TronWebConsumed as a git dependencytags 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
FactValue
Entrysrc/index.tssrc/app.ts
Devnpm run dev (tsx watch)
Buildnpm run build (tsc → build/)
Startnpm start
Types checknpm run check-types
PersistenceMongoDB (@langchain/mongodb), PostgreSQL + PGVector (pg)
CheckpointingRedis (ioredis)
ValidationZod 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/
FactValue
Entryindex.js
Devnpm run dev (nodemon)
Startnpm start
TestsNone for the backend itself (npm test exits 1). Contract tests live in contract-deployment/test/
Mounts/api (legacy), /api/v1 (new), /api/pinata
Process managerPM2, app name bz-backend
Cron gateCRON != '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
ScriptDoes
npm run devDefi shell on :5173
npm run dev:aiAI shell on :5174
npm run buildvite buildprerender-seo.mjsgenerate-og.mjs
npm run build:appvite build only
npm run build:aivite build --mode ai --outDir dist-airewrite-ai-shell.mjs
npm run preview:aiServe dist-ai on :4174
npm run check:routesRoute sanity check; -- --cutover for the AI cutover phase
npm run prerenderPrerender only
npm run indexnowManual 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
FactValue
Version1.12.0
Module typeESM ("type": "module"), .js extensions in imports
Buildtscdist/, run automatically by prepare
DistributionGit tags. github:blazpay/swap-sdk#vX.Y.Z
Embedded secretsNone. 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.txt

This 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.

FileSubject
AUTOPILOT_AND_COPYTRADE_PLAN.mdAutopilot spec and the copy-trading plan. 57 KB, work in blocks
AI_SPLIT_PLAN.mdDomain map, 301 table, phases, risks for the AI split
AI_SITE_SETUP.mdAI shell rationale, testing plan, cutover runbook
DAPP_BUILDER_ARCHITECTURE.mdFull dApp builder design
DAPP_BUILDER_PROGRESS.mdBuild log
BLAZPAY_FEATURE_INVENTORY_FOR_MARKETING.mdMaster fact sheet — but see its own accuracy notes
BLAZPAY_PRESS_BRIEF.mdPress positioning
BlazAI_Current_Features.md, BlazAI_README.mdOlder AI feature snapshots
SYSTEM_ARCHITECTURE_NOTES.mdEarly architecture notes
MIGRATION.mdA migration record
TOKEN_PAYMENT_ANALYTICS_API.md, TRANSACTION_V2_ANALYTICS_API.mdAnalytics 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.

Internal + developer documentation. Usage figures are point-in-time snapshots — re-verify before publishing them.