name: backend-agent-runbook description: Run, configure, and verify the Zelf backend API. Use when working on backend setup, local execution, tests, Mongo requirements, route verification, or docs-related backend workflows.
Backend Agent Runbook
Use this skill for practical backend operations in zelf.
Quick start
- Install dependencies with
npm install. - Copy
.env.exampleto.envand provide at leastMONGODB_URI, secrets, and any service keys needed for your area. - Start MongoDB locally.
- Start the API with
npm start.
Port guidance
Core/config.jsfalls back to3000..env.examplesetsPORT=3003.- Several older tests still default to
3000or3050. - Prefer an explicit
PORTwhenever you run the API or tests so the server and test client agree.
Recommended default local workflow:
PORT=3003 npm start
For a test file that expects another port, export that same PORT before starting the server and running the test.
Core commands
- Dev server:
npm start - Unit tests:
npm run test:unit - Integration tests:
npm run test:integration - End-to-end tests:
npm run test:e2e - Focused integration checks:
npm run test:lease,npm run test:search-tag,npm run test:authentication - Ops scripts:
npm run audit:ipfs-pay-balances,npm run repair:blockdag-nft-index,npm run deploy:checkout-avax
Test requirements
- Use Node
24and local MongoDB, followingtests/README.md. - The backend follows a strict no-mocking policy.
- Integration tests hit a live server, usually create a session via
/api/sessions, then call protected routes withAuthorization: Bearer <token>andOrigin: https://test.example.com. - The dedicated test database is
zelf_testing.
By area
General API work
server.jscontrols startup order, JWT handling, and protected vs unprotected route mounting.- Route registration lives in
Routes/unprotected-repositories.jsandRoutes/protected-repositories.js.
Tags, search, and lease flows
- Check
Repositories/Tags/plus related integration tests undertests/integration/. - Use
config/0012589021.jsonwhen a biometric payload is required in tests.
BlockDAG and NFT flows
- Check
Repositories/BlockDAG/, especially the public/protected route split and the smart-contract folder underRepositories/BlockDAG/smart-contracts/. - Relevant maintenance scripts include
npm run repair:blockdag-nft-index.
Docs work
- Public API docs belong in
zelf-documentation/docs/api/. - Public examples must use
https://v3.zelf.world, not localhost.
Maintenance
- When commands, ports, or environment expectations change, update this file and mirror durable high-signal facts in
AGENTS.md.