N0DEX SDK
N0DEX is a typed SDK for producing backend project artifacts. It validates a prompt, normalizes features and integrations, composes generator modules, returns an in-memory file graph, then exports that graph to disk when you are ready.
01
Overview
Describe an app, game, or platform and generate APIs, database schemas, auth, realtime systems, and integrations from one prompt. The generated output is inspectable TypeScript, not a black box runtime.
02
Install
Install the package from npm, then import the SDK.
npm i @n0dex/n0dex03
Quick Start
Create a client, describe the backend you want, inspect the result, then export the generated file graph.
import { N0DEX } from "@n0dex/nodex";
const n0dex = new N0DEX({
apiKey: process.env.N0DEX_API_KEY,
model: process.env.N0DEX_MODEL ?? "gpt-4o-mini",
outputDir: "./generated"
});
const backend = await n0dex.generate({
name: "snow-survival-game",
stack: "node-ts",
database: "postgres",
features: [
"auth",
"inventory",
"leaderboard",
"daily-rewards",
"websocket",
"quests",
"marketplace"
],
integrations: ["express", "prisma", "postgresql", "websocket", "solana-wallet"],
prompt: "Build a multiplayer winter survival game backend with wallet auth, items, storms, rewards, and leaderboards."
});
console.log(backend.metadata);
await backend.export("./generated/snow-survival-game", { overwrite: true });04
Core Concepts
Generation returns a deterministic file graph. The SDK does not write during generate(...); it writes only when you call backend.export(...) or n0dex.export(...).
interface GeneratedFile {
path: string;
content: string;
}
interface GeneratedBackend {
name: string;
files: GeneratedFile[];
metadata: GenerationMetadata;
summary: string;
export(targetPath: string, options?: ExportOptions): Promise<ExportResult>;
}05
Generation Pipeline
N0DEX keeps generation predictable by validating input, normalizing names and features, inferring integrations, then attaching metadata to the returned backend graph.
GenerateOptions
-> validatePrompt(prompt)
-> normalize backend name to kebab-case
-> normalize features
-> infer integrations from features
-> create backend template file graph
-> attach metadata
-> return GeneratedBackend
-> export file graph to target pathFeature inference maps database to Prisma and PostgreSQL, websocket to WebSocket support,wallet-auth to Solana wallet scaffolding, and always includes Express.
06
API Reference
Use the constructor to configure local or hosted generation flows. Use generate(options) for a full backend.
interface N0DEXConfig {
apiKey?: string;
model?: string;
outputDir?: string;
baseUrl?: string;
timeoutMs?: number;
dryRun?: boolean;
}
interface GenerateOptions {
name: string;
stack: "node-ts";
database?: "postgres" | "mysql" | "sqlite" | "mongodb" | "supabase" | "none";
features?: BackendFeature[];
integrations?: IntegrationProvider[];
prompt: string;
outputDir?: string;
packageManager?: "npm" | "pnpm" | "yarn" | "bun";
}Supported backend features
07
Focused Generators
Use focused generators when you want isolated modules instead of a complete backend graph.
n0dex.generateRoutes({
resources: ["players", "matches"],
includeCrud: true
});
n0dex.generateDatabase({
provider: "postgres",
features: ["auth", "inventory", "leaderboard"]
});
n0dex.generateAuth({
providers: ["email", "wallet"],
jwt: true,
roles: ["admin", "player"]
});
n0dex.generateWebSocket({
channels: ["presence", "match-events"],
heartbeatMs: 30000,
authRequired: true
});
n0dex.generateGameBackend({
modules: ["inventory", "leaderboard", "quests", "marketplace", "daily-rewards"],
realtime: true,
economy: true
});08
Export
Export writes files relative to the selected root, creates parent directories recursively, rejects path traversal, and respects overwrite policy.
await backend.export("./generated/my-backend", {
overwrite: true,
includeReadme: true
});
interface ExportResult {
path: string;
filesWritten: string[];
}09
Prompt Validation
validatePrompt(prompt) checks required prompt presence, useful length, maximum length, security-sensitive wording such as hardcoded secrets or disabled auth, and whether backend concepts are present.
Invalid prompts throw PromptValidationError fromgenerate(...) with validation details.
10
Integrations
N0DEX exposes a typed integration registry throughgetIntegration and integrations.
| Provider | Package | Environment | Purpose |
|---|---|---|---|
| express | express | PORT | HTTP routing, middleware, controllers |
| postgresql | pg | DATABASE_URL | Relational persistence |
| prisma | prisma | DATABASE_URL | Schema, migrations, typed client |
| supabase | @supabase/supabase-js | SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY | Hosted Postgres and platform services |
| websocket | ws | none | Realtime events and presence |
| solana-wallet | @solana/web3.js | SOLANA_CLUSTER | Wallet signature authentication scaffold |
11
Generated Output
Generated servers boot Express with helmet, cors, JSON middleware, health checks, auth routes, game routes, optional WebSocket support, Prisma, and JWT bearer validation.
generated/my-backend/
src/
routes/
auth.routes.ts
game.routes.ts
index.ts
controllers/
auth.controller.ts
game.controller.ts
services/
auth.service.ts
database/
client.ts
middleware/
require-auth.ts
websocket/
server.ts
integrations/
solana.ts
modules/
auth/
inventory/
leaderboard/
quests/
marketplace/
server.ts
prisma/
schema.prisma
package.json
tsconfig.json
.env.example
README.md12
Environment
Use SDK variables for generation and generated backend variables for the exported server.
N0DEX_API_KEY=
N0DEX_MODEL=gpt-4o-mini
N0DEX_OUTPUT_DIR=./generated
OPENAI_API_KEY=
PORT=4000
DATABASE_URL=postgresql://user:password@localhost:5432/app
JWT_SECRET=change-me
SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
SOLANA_CLUSTER=devnet13
Error Handling
The SDK exposes N0DEXError as the base class,PromptValidationError for invalid generation prompts, and ExportError for unsafe or invalid export operations.
import { ExportError, N0DEXError, PromptValidationError } from "@n0dex/nodex";
try {
await n0dex.generate({
name: "x",
stack: "node-ts",
prompt: ""
});
} catch (error) {
if (error instanceof PromptValidationError) {
console.error(error.details);
}
}14
Development
The SDK uses strict TypeScript, ESM NodeNext output, declarations, Vitest, and a build-before-publish flow.
npm install
npm run build
npm test
npm audit