{"_id":"02-rbor","_rev":"4-57e48b114b1cfd0053b0fd4c487ed8f9","name":"02-rbor","dist-tags":{"latest":"0.2.2"},"versions":{"0.1.0":{"name":"02-rbor","version":"0.1.0","keywords":["cli","rbor","react","architecture","scaffolding","clean-architecture","dependency-graph","frontend","domain-driven"],"author":{"name":"02-davinci-01"},"license":"MIT","_id":"02-rbor@0.1.0","maintainers":[{"name":"02-davinci-01","email":"02davinci01@gmail.com"}],"homepage":"https://github.com/02-davinci-01/02-rbor#readme","bugs":{"url":"https://github.com/02-davinci-01/02-rbor/issues"},"bin":{"rbor":"bin/rbor.js"},"dist":{"shasum":"823ef8d021515a066e3af2560d767656096455b6","tarball":"https://registry.npmjs.org/02-rbor/-/02-rbor-0.1.0.tgz","fileCount":154,"integrity":"sha512-JEpeQ+B0kOvpvl/2tCMXynkFVNMWoDp1nqDyoVLIUm+XyIVWGNmjzlB8SVcNdN5uDooWaojYLK4gbBIvQnbRCw==","signatures":[{"sig":"MEUCIQD2VeiS5WvRa7pcrUvHYFx9swf63bOb76jl0KCH9A7MrwIgd1m4Q3NAWmP10kLGxecnNTb9H519NZ6t0IZkb0JwlDM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":354367},"main":"dist/cli.js","types":"dist/cli.d.ts","engines":{"node":">=18"},"gitHead":"e983afb4781e4301c0123bd65d32fb40fdb8bb90","scripts":{"lint":"eslint src --ext .ts,.tsx","test":"vitest run","build":"tsc","format":"prettier --write \"src/**/*.{ts,tsx,json,md}\"","prepare":"husky","test:ui":"vitest --ui","lint:fix":"eslint src --ext .ts,.tsx --fix","typecheck":"tsc --noEmit","test:watch":"vitest","format:check":"prettier --check \"src/**/*.{ts,tsx,json,md}\"","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build && npm run lint && npm test"},"_npmUser":{"name":"02-davinci-01","email":"02davinci01@gmail.com"},"repository":{"url":"git+https://github.com/02-davinci-01/02-rbor.git","type":"git"},"_npmVersion":"10.9.3","description":"CLI tool for scaffolding opinionated, Clean Architecture-inspired React frontends with dependency graph analysis","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_nodeVersion":"22.20.0","dependencies":{"commander":"^11.1.0","@viz-js/viz":"^3.24.0"},"_hasShrinkwrap":false,"devDependencies":{"ky":"^1.14.3","axios":"^1.13.2","husky":"^9.1.7","eslint":"^9.39.2","vitest":"^2.1.9","prettier":"^3.8.1","@vitest/ui":"^2.1.9","typescript":"^5.3.0","@types/node":"^20.10.0","lint-staged":"^16.2.7","@vitest/coverage-v8":"^2.0.0","eslint-config-prettier":"^10.1.8","@typescript-eslint/parser":"^8.55.0","@typescript-eslint/eslint-plugin":"^8.55.0"},"peerDependencies":{"ky":">=1.0.0","axios":">=1.0.0"},"peerDependenciesMeta":{"ky":{"optional":true},"axios":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/02-rbor_0.1.0_1771419970974_0.29260759121013447","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"02-rbor","version":"0.2.0","keywords":["cli","rbor","react","architecture","scaffolding","clean-architecture","dependency-graph","frontend","domain-driven"],"author":{"name":"02-davinci-01"},"license":"MIT","_id":"02-rbor@0.2.0","maintainers":[{"name":"02-davinci-01","email":"02davinci01@gmail.com"}],"homepage":"https://github.com/02-davinci-01/02-rbor#readme","bugs":{"url":"https://github.com/02-davinci-01/02-rbor/issues"},"bin":{"rbor":"bin/rbor.js"},"dist":{"shasum":"cf3ac655cc2ac3cc9a4ab29192ef99e1046f42d2","tarball":"https://registry.npmjs.org/02-rbor/-/02-rbor-0.2.0.tgz","fileCount":154,"integrity":"sha512-TeGKnh3FaF8yLiy09g/AH9l1IoXmMB+/8+CCG3ELWRWGMcKN4f1bSoYIyJ1l801jyvgjxiJnxtJXJpF+rv1Mpw==","signatures":[{"sig":"MEUCIQCrbizL03+wVIG1xh4QNtzJISZYjOB44IdzfK/poU3whQIgZj2+yzMTTsaTM2W0nrlZcLRb0Y5utsIGKa4xnyo58ms=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":367426},"main":"dist/cli.js","types":"dist/cli.d.ts","engines":{"node":">=18"},"gitHead":"f77d3a47d3b903efc8c222f6528988b06b16e69e","scripts":{"lint":"eslint src --ext .ts,.tsx","test":"vitest run","build":"tsc","format":"prettier --write \"src/**/*.{ts,tsx,json,md}\"","prepare":"husky","test:ui":"vitest --ui","lint:fix":"eslint src --ext .ts,.tsx --fix","typecheck":"tsc --noEmit","test:watch":"vitest","format:check":"prettier --check \"src/**/*.{ts,tsx,json,md}\"","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build && npm run lint && npm test"},"_npmUser":{"name":"02-davinci-01","email":"02davinci01@gmail.com"},"repository":{"url":"git+https://github.com/02-davinci-01/02-rbor.git","type":"git"},"_npmVersion":"10.9.3","description":"CLI tool for scaffolding opinionated, Clean Architecture-inspired React frontends with dependency graph analysis","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_nodeVersion":"22.20.0","dependencies":{"commander":"^11.1.0","@viz-js/viz":"^3.24.0"},"_hasShrinkwrap":false,"devDependencies":{"ky":"^1.14.3","axios":"^1.13.2","husky":"^9.1.7","eslint":"^9.39.2","vitest":"^2.1.9","prettier":"^3.8.1","@vitest/ui":"^2.1.9","typescript":"^5.3.0","@types/node":"^20.10.0","lint-staged":"^16.2.7","@vitest/coverage-v8":"^2.0.0","eslint-config-prettier":"^10.1.8","@typescript-eslint/parser":"^8.55.0","@typescript-eslint/eslint-plugin":"^8.55.0"},"peerDependencies":{"ky":">=1.0.0","axios":">=1.0.0"},"peerDependenciesMeta":{"ky":{"optional":true},"axios":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/02-rbor_0.2.0_1771585399431_0.6333736850614766","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"02-rbor","version":"0.2.1","keywords":["cli","rbor","react","architecture","scaffolding","clean-architecture","dependency-graph","frontend","domain-driven"],"author":{"name":"02-davinci-01"},"license":"MIT","_id":"02-rbor@0.2.1","maintainers":[{"name":"02-davinci-01","email":"02davinci01@gmail.com"}],"homepage":"https://github.com/02-davinci-01/02-rbor#readme","bugs":{"url":"https://github.com/02-davinci-01/02-rbor/issues"},"bin":{"rbor":"bin/rbor.js"},"dist":{"shasum":"cab8e4ff996a37f4490f83e97c640b294848fe87","tarball":"https://registry.npmjs.org/02-rbor/-/02-rbor-0.2.1.tgz","fileCount":154,"integrity":"sha512-Rd3TvM4R7BaKwUhAuoip0nJxri+Pjg78Pjy97MxFSTncfzPSA4mDbVKyiAb0FNuVHCsPs4Yv2nUOYhwXYM136Q==","signatures":[{"sig":"MEYCIQCA9MXJTOxINbISI1kvqq5MJgLcC/4FYW1a7voEBUaM9AIhAMGqkNniJgDn/aIcothDhAphNdmSm/0rF42IDldY31iR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":369205},"main":"dist/cli.js","types":"dist/cli.d.ts","engines":{"node":">=18"},"gitHead":"71c4603141fbe5929cf95de8018579011cbf6b9a","scripts":{"lint":"eslint src --ext .ts,.tsx","test":"vitest run","build":"tsc","format":"prettier --write \"src/**/*.{ts,tsx,json,md}\"","prepare":"husky","test:ui":"vitest --ui","lint:fix":"eslint src --ext .ts,.tsx --fix","typecheck":"tsc --noEmit","test:watch":"vitest","format:check":"prettier --check \"src/**/*.{ts,tsx,json,md}\"","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build && npm run lint && npm test"},"_npmUser":{"name":"02-davinci-01","email":"02davinci01@gmail.com"},"repository":{"url":"git+https://github.com/02-davinci-01/02-rbor.git","type":"git"},"_npmVersion":"10.9.3","description":"CLI tool for scaffolding opinionated, Clean Architecture-inspired React frontends with dependency graph analysis","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_nodeVersion":"22.20.0","dependencies":{"commander":"^11.1.0","@viz-js/viz":"^3.24.0"},"_hasShrinkwrap":false,"devDependencies":{"ky":"^1.14.3","axios":"^1.13.2","husky":"^9.1.7","eslint":"^9.39.2","vitest":"^2.1.9","prettier":"^3.8.1","@vitest/ui":"^2.1.9","typescript":"^5.3.0","@types/node":"^20.10.0","lint-staged":"^16.2.7","@vitest/coverage-v8":"^2.0.0","eslint-config-prettier":"^10.1.8","@typescript-eslint/parser":"^8.55.0","@typescript-eslint/eslint-plugin":"^8.55.0"},"peerDependencies":{"ky":">=1.0.0","axios":">=1.0.0"},"peerDependenciesMeta":{"ky":{"optional":true},"axios":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/02-rbor_0.2.1_1771586491959_0.08528149765767346","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"02-rbor","version":"0.2.2","description":"CLI tool for scaffolding opinionated, Clean Architecture-inspired React frontends with dependency graph analysis","bin":{"rbor":"bin/rbor.js"},"main":"dist/cli.js","types":"dist/cli.d.ts","scripts":{"build":"tsc","test":"vitest run","test:watch":"vitest","test:ui":"vitest --ui","test:coverage":"vitest run --coverage","lint":"eslint src --ext .ts,.tsx","lint:fix":"eslint src --ext .ts,.tsx --fix","format":"prettier --write \"src/**/*.{ts,tsx,json,md}\"","format:check":"prettier --check \"src/**/*.{ts,tsx,json,md}\"","typecheck":"tsc --noEmit","prepare":"husky","prepublishOnly":"npm run build && npm run lint && npm test"},"dependencies":{"@viz-js/viz":"^3.24.0","commander":"^11.1.0"},"peerDependencies":{"axios":">=1.0.0","ky":">=1.0.0"},"peerDependenciesMeta":{"axios":{"optional":true},"ky":{"optional":true}},"devDependencies":{"@types/node":"^20.10.0","@typescript-eslint/eslint-plugin":"^8.55.0","@typescript-eslint/parser":"^8.55.0","@vitest/coverage-v8":"^2.0.0","@vitest/ui":"^2.1.9","axios":"^1.13.2","eslint":"^9.39.2","eslint-config-prettier":"^10.1.8","husky":"^9.1.7","ky":"^1.14.3","lint-staged":"^16.2.7","prettier":"^3.8.1","typescript":"^5.3.0","vitest":"^2.1.9"},"engines":{"node":">=18"},"keywords":["cli","rbor","react","architecture","scaffolding","clean-architecture","dependency-graph","frontend","domain-driven"],"author":{"name":"02-davinci-01"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/02-davinci-01/02-rbor.git"},"bugs":{"url":"https://github.com/02-davinci-01/02-rbor/issues"},"homepage":"https://github.com/02-davinci-01/02-rbor#readme","lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_id":"02-rbor@0.2.2","gitHead":"8912f0b4025bbb351921ff1a6bcd30840c9e3f0b","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-V+Gq9WZxdrxASMM1cmiqkQw82vGtXaE/wP+4UdU+PkiFlfsC9MiwmyqOE+WwC2ydxkhcI8YRtu3CqnCFlR4bug==","shasum":"210191a7305d9b9c851c8e40f2a97ed9afce6973","tarball":"https://registry.npmjs.org/02-rbor/-/02-rbor-0.2.2.tgz","fileCount":154,"unpackedSize":369166,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCHmJAdocau+h8s3WZ5HRFfNuxzu8bStObYlojqq1lhLAIgLsikDbiPSqC3ELFiVpxURBvnZk5QRgL03g9GZq1nlc8="}]},"_npmUser":{"name":"02-davinci-01","email":"02davinci01@gmail.com"},"directories":{},"maintainers":[{"name":"02-davinci-01","email":"02davinci01@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/02-rbor_0.2.2_1771586673276_0.3091653866200803"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T13:06:10.973Z","modified":"2026-02-20T11:24:33.554Z","0.1.0":"2026-02-18T13:06:11.170Z","0.2.0":"2026-02-20T11:03:19.587Z","0.2.1":"2026-02-20T11:21:32.292Z","0.2.2":"2026-02-20T11:24:33.436Z"},"bugs":{"url":"https://github.com/02-davinci-01/02-rbor/issues"},"author":{"name":"02-davinci-01"},"license":"MIT","homepage":"https://github.com/02-davinci-01/02-rbor#readme","keywords":["cli","rbor","react","architecture","scaffolding","clean-architecture","dependency-graph","frontend","domain-driven"],"repository":{"type":"git","url":"git+https://github.com/02-davinci-01/02-rbor.git"},"description":"CLI tool for scaffolding opinionated, Clean Architecture-inspired React frontends with dependency graph analysis","maintainers":[{"name":"02-davinci-01","email":"02davinci01@gmail.com"}],"readme":"# 02-rBOR CLI\n\n[![npm version](https://img.shields.io/npm/v/02-rbor.svg)](https://www.npmjs.com/package/02-rbor)\n[![CI](https://github.com/02-davinci-01/02-rbor/workflows/CI/badge.svg)](https://github.com/02-davinci-01/02-rbor/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n> **recusrive Branching Orchestration Rendering**\n\nA CLI tool for building frontend applications following the **02-rBOR** architecture pattern. Generate domain-driven feature modules with proper layering, enforce architectural rules, and analyze dependency graphs — with SVG visualization out of the box.\n\n## 🤔 What is rBOR?\n\nrBOR is an opinionated folder architecture for React apps. Instead of organizing by file type (`components/`, `hooks/`, `services/` at the root), rBOR organizes by **domain** — each feature gets its own self-contained folder with every layer it needs.\n\nThe idea: a `user` feature shouldn't scatter its files across 6 different top-level folders. Everything related to `user` lives under `domains/user/`, with a single barrel export (`index.tsx`) as the public API.\n\nEach domain follows a strict **downward dependency rule** inspired by the [Dependency Inversion Principle](https://en.wikipedia.org/wiki/Dependency_inversion_principle):\n\n```\n  ┌─────────────────────────────┐\n  │  Page (route)               │  composes components\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Component (UI)             │  renders data from hooks\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Hook — data / action       │  React Query fetching & mutations\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Hook — controller          │  creates service, wires methods\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Method (pure logic)        │  receives service as 1st param\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Service (HTTP layer)       │  extends BaseService\n  └──────────────┬──────────────┘\n                 ▼\n  ┌─────────────────────────────┐\n  │  Infrastructure (shared)    │  BaseService, ServiceFactory\n  └─────────────────────────────┘\n```\n\n**Control flows upward** — each layer orchestrates the layer below it.  \n**Dependencies flow downward** — lower layers are completely independent of what consumes them.\n\nThis means:\n\n- `Infrastructure` (BaseService, ServiceFactory) knows nothing about any domain.\n- `Service` extends BaseService — depends only on infrastructure.\n- `Method` receives a service object as its first argument — depends only on services.\n- `Hook (controller)` creates the service via ServiceFactory, passes it to methods — depends on methods & infrastructure.\n- `Hook (data/action)` consumes the controller hook for fetching or mutations — depends on the controller.\n- `Component` renders data from hooks — depends only on hooks.\n- `Page` composes components — depends only on components.\n\nLower layers never import from higher layers. This keeps your business logic testable, your services reusable, and your UI replaceable.\n\n## 📦 Installation\n\n```bash\nnpm install -g 02-rbor\n```\n\n```bash\nrbor init\nrbor domain <domain-name>\n```\n\n> **Tip:** If you prefer not to install globally, use `npx` — it works without any install:\n>\n> ```bash\n> npx 02-rbor init\n> npx 02-rbor domain <domain-name>\n> ```\n>\n> All commands work with `npx 02-rbor <command>`, for example:\n>\n> ```bash\n> npx 02-rbor domain user\n> npx 02-rbor validate\n> npx 02-rbor deps domains/user -f svg\n> ```\n\n## 🚀 Quick Start\n\n### 1. Initialize your project\n\n```bash\nrbor init\n```\n\nThis creates a `.rborrc.json` configuration file with your project defaults.\n\n### 2. Generate your first domain\n\n```bash\n# Interactive mode — prompts for name and HTTP client\nrbor domain\n\n# Or pass the name directly\nrbor domain user --http axios\n```\n\nThis generates a complete domain structure:\n\n```\ndomains/user/\n├── index.tsx              # Barrel export (public API)\n├── __test__/              # Test directory\n├── components/\n│   └── User.tsx           # Main component\n├── hooks/\n│   ├── useUser.ts         # Controller hook (creates service, wires methods)\n│   ├── useUserData.ts     # Data hook (React Query)\n│   └── useUserAction.ts   # Action hook (mutations)\n├── methods/\n│   └── user-logic.ts      # Pure async functions (React-independent)\n├── schema/\n│   └── user-schema.ts     # Validation schema (zod)\n├── services/\n│   └── user-service.ts    # Domain service (HTTP layer)\n├── types/\n│   └── user-types.ts      # TypeScript types\n└── utils/\n    ├── constant/\n    │   ├── user-constants.ts\n    │   └── user-endpoints.ts\n    └── helper/\n        └── user-helpers.ts\n```\n\n#### What each folder does\n\n| Folder                | Purpose                                                                                                                                                     | Rules                                                                                                                                                      |\n| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **`components/`**     | React UI. Renders data, handles user interaction.                                                                                                           | Can import from `hooks/`. Nothing else in the domain.                                                                                                      |\n| **`hooks/`**          | Wiring layer. Connects React to your domain logic.                                                                                                          | `useUser` creates the service object and passes it to methods. `useUserData` and `useUserAction` provide React Query scaffolds for fetching and mutations. |\n| **`methods/`**        | Pure business logic. Every function receives the service as its first argument — no React, no hooks, no global state.                                       | Can import from `services/` and `utils/`. Must stay framework-free so it's easy to test and reuse.                                                         |\n| **`services/`**       | HTTP layer. Extends `BaseService` to get an axios (or fetch/ky) instance. Exposes typed `get`, `post`, `put`, `delete` methods with URL param substitution. | Can import from `infrastructure/` and `utils/`.                                                                                                            |\n| **`schema/`**         | Validation schemas (zod by default). Define the shape of your domain data for form validation, API response parsing, etc.                                   | Pure data definitions — no side effects.                                                                                                                   |\n| **`types/`**          | TypeScript interfaces and types for this domain.                                                                                                            | Pure type definitions.                                                                                                                                     |\n| **`utils/constant/`** | Endpoint paths and domain-specific constants (timeouts, config values, feature flags).                                                                      | Pure values — no logic.                                                                                                                                    |\n| **`utils/helper/`**   | Domain-specific utility functions (formatters, transformers, parsers).                                                                                      | Pure functions — no React, no service calls.                                                                                                               |\n| **`__test__/`**       | Tests for this domain.                                                                                                                                      | Mirrors the folder structure above.                                                                                                                        |\n| **`index.tsx`**       | Barrel export — the **only** file other parts of your app should import from.                                                                               | Re-exports the component and anything else that's part of the public API.                                                                                  |\n\n#### How data flows\n\n```\n  ┌──────────────────────────────┐\n  │  Component  (User.tsx)       │  UI — renders data\n  └──────────────┬───────────────┘\n                 │ uses hooks\n                 ▼\n  ┌──────────────────────────────┐\n  │  useUserData / useUserAction │  React Query — fetching & mutations\n  └──────────────┬───────────────┘\n                 │ consumes controller\n                 ▼\n  ┌──────────────────────────────┐\n  │  useUser  (controller hook)  │  creates service, wires methods\n  │                              │  ServiceFactory.create('USER')\n  └───────┬──────────────┬───────┘\n          │              │\n          ▼              ▼\n  ┌──────────────┐  ┌────────────────────┐\n  │  user-logic  │  │  ServiceFactory    │\n  │  (methods)   │  │  (infrastructure)  │\n  └──────┬───────┘  └────────────────────┘\n         │ calls service\n         ▼\n  ┌──────────────────────────────┐\n  │  UserService                 │  extends BaseService\n  │  self-registers with Factory │\n  └──────────────┬───────────────┘\n                 │\n                 ▼\n  ┌──────────────────────────────┐\n  │  BaseService                 │  axios instance, interceptors,\n  │  (infrastructure)            │  base URL, timeout\n  └──────────────────────────────┘\n```\n\n**Dependency Inversion in practice:**\n\n- Lower layers are **stable abstractions** — they define contracts (BaseService, ServiceFactory registry) that don't change when features change.\n- Higher layers are **volatile details** — UI, state management, and wiring change frequently.\n- Each layer only depends on the layer directly below it, never sideways or upward.\n- ServiceFactory never imports domain services — each service self-registers via `ServiceFactory.register()` at the bottom of its file. The controller hook triggers registration by importing the service file.\n- `hook-data` and `hook-action` are **independent siblings** — both depend on the controller hook, but never on each other.\n\n### 3. Add endpoints and constants\n\n```bash\ncd domains/user\nrbor endpoint users/:id/profile    # → USERS_ID_PROFILE\nrbor constant timeout=3000         # → TIMEOUT = 3000\n```\n\n### 4. Analyze dependencies\n\n```bash\n# Who imports this file?\nrbor deps domains/user/components/User.tsx -d reverse -f svg -o deps.svg\n\n# What does this file import?\nrbor deps src/app/App.tsx -d forward -f tree\n```\n\n### 5. Validate architecture\n\n```bash\nrbor validate\n```\n\n---\n\n## 📚 Commands\n\n| Command                     | Description                                      |\n| --------------------------- | ------------------------------------------------ |\n| `rbor init`                 | Initialize `.rborrc.json` configuration          |\n| `rbor domain [name]`        | Generate a domain (interactive if no name given) |\n| `rbor endpoint <path>`      | Add an endpoint to the current domain            |\n| `rbor constant <key=value>` | Add a constant to the current domain             |\n| `rbor list`                 | List all domains with metadata                   |\n| `rbor validate`             | Validate architecture rules                      |\n| `rbor deps <path>`          | Analyze dependency graph                         |\n| `rbor davinci`              | Credits                                          |\n\n---\n\n### `rbor init`\n\nInitialize rBOR configuration in your project.\n\n```bash\nrbor init [options]\n\nOptions:\n  --http <client>               HTTP client (axios, fetch, ky)\n  --domains-path <path>         Path to domains folder\n  --infrastructure-path <path>  Path to infrastructure folder\n  --force                       Overwrite existing config\n```\n\nCreates `.rborrc.json`:\n\n```json\n{\n  \"http\": \"axios\",\n  \"domainsPath\": \"domains\",\n  \"infrastructurePath\": \"infrastructure\",\n  \"schema\": { \"library\": \"zod\" }\n}\n```\n\n---\n\n### `rbor domain [name]`\n\nGenerate a new domain with the full 02-rBOR structure.\n\n```bash\n# Interactive mode (prompts for name, HTTP client, confirmation)\nrbor domain\n\n# Direct mode\nrbor domain auth\nrbor domain products --http ky\n```\n\n**What it generates:**\n\n- ✅ Component with TypeScript + JSX\n- ✅ Three-hook pattern (controller, data, action)\n- ✅ Pure domain logic (methods receive service, stay React-free)\n- ✅ Service layer with HTTP client integration\n- ✅ Validation schemas (zod)\n- ✅ Type definitions\n- ✅ Constants and endpoint files\n- ✅ Barrel export (index.tsx)\n\n**Hook pattern:**\n\nThree hooks are generated per domain:\n\n- **`use<Domain>`** — Controller hook. Creates a service object and wires up all methods:\n- **`use<Domain>Data`** — Data hook. Fetches server state using React Query (commented scaffold).\n- **`use<Domain>Action`** — Action hook. Mutation actions via React Query (commented scaffold).\n\nThe controller hook wires up services and methods:\n\n```ts\nexport const useUser = () => {\n  const service = ServiceFactory.create('USER') as UserService;\n\n  return {\n    getList: () => getUserList(service),\n    getById: (id: string) => getUserById(service, id),\n    create: (data: unknown) => createUser(service, data),\n    update: (id: string, data: unknown) => updateUser(service, id, data),\n    remove: (id: string) => deleteUser(service, id),\n  };\n};\n```\n\n> **Note:** If you need access to the Redux store or other global state, access it in the hook and pass values down to your methods. Methods should remain pure async functions.\n\n---\n\n### `rbor endpoint <path>`\n\nAdd an API endpoint constant to an existing domain. Run from inside `domains/<domain>/`.\n\n```bash\nrbor endpoint users/:id/profile\n```\n\nGenerates ALL_CAPS keys and appends to `utils/constant/<domain>-endpoints.ts`:\n\n```ts\nexport const AUTH_ENDPOINTS = {\n  LOGIN: '/login',\n  USERS_ID_PROFILE: '/users/:id/profile',\n} as const;\n```\n\n---\n\n### `rbor constant <key=value>`\n\nAdd a constant to the current domain's constants file. Run from inside `domains/<domain>/`.\n\n```bash\nrbor constant timeout=3000        # → export const TIMEOUT = 3000;\nrbor constant maxRetries=5        # → export const MAX_RETRIES = 5;\nrbor constant api-url=https://x   # → export const API_URL = 'https://x';\nrbor constant debug=true          # → export const DEBUG = true;\n```\n\nAuto-detects value types — numbers and booleans stay unquoted, strings get wrapped in quotes.\n\n---\n\n### `rbor list`\n\nList all domains with metadata.\n\n```bash\nrbor list    # or: rbor ls\n```\n\n---\n\n### `rbor validate`\n\nEnforce 02-rBOR architectural rules.\n\n```bash\nrbor validate          # or: rbor lint\nrbor validate --strict # treat warnings as errors\n```\n\n**What it checks:**\n\n- ❌ **No cross-domain imports** — Domains must not import from each other\n- ❌ **Downward-only dependencies** — Page → Component → Hook (data/action) → Hook (controller) → Method → Service → Infrastructure\n- ❌ **Sibling isolation** — `hook-data` and `hook-action` must be independent (no importing each other)\n- ❌ **No React in methods layer** — Pure logic must be framework-free\n- ⚠️ **Barrel exports** — Every domain should have an index.tsx\n- ⚠️ **Circular dependencies** — Warns about import cycles\n\n---\n\n### `rbor deps <path>`\n\nAnalyze dependency graphs for any file or directory. Traces imports forward (what does this file use?) or reverse (who imports this file?) and renders the result in five different formats — from quick terminal summaries to full SVG diagrams you can open in a browser.\n\n```bash\nrbor deps <path> [options]\n```\n\n#### Flags\n\n| Flag                  | Short | Description                                            | Default                         |\n| --------------------- | ----- | ------------------------------------------------------ | ------------------------------- |\n| `--direction <dir>`   | `-d`  | `forward` (imports) or `reverse` (importers)           | `forward`                       |\n| `--format <fmt>`      | `-f`  | Output format: `summary`, `tree`, `json`, `dot`, `svg` | `summary`                       |\n| `--output <file>`     | `-o`  | Write output to a file instead of stdout               | _(stdout)_                      |\n| `--depth <n>`         |       | Maximum traversal depth                                | `10`                            |\n| `--include-external`  |       | Include external npm packages in the graph             | `false`                         |\n| `--include-tests`     |       | Include test files (`*.test.*`, `*.spec.*`)            | `false`                         |\n| `--include-types`     |       | Include type-only imports (`import type { ... }`)      | `true`                          |\n| `--aliases <mapping>` |       | Path aliases, e.g. `\"@/=src/,@utils/=src/utils/\"`      | _(auto-detected from tsconfig)_ |\n\n> **Alias auto-detection:** If your project has a `tsconfig.json` with `compilerOptions.paths`, aliases are read automatically. Use `--aliases` to add extras or override.\n\n#### Direction\n\n**`--direction forward`** (default) — \"What does this file import?\"\n\n```\n          ┌──────────┐\n          │ App.tsx  │\n          │ (entry)  │\n          └────┬─────┘\n               │\n     ┌─────────┼──────────┐\n     ▼         ▼          ▼\n router.ts  store.ts  utils.ts\n```\n\n**`--direction reverse`** — \"Who imports this file?\"\n\n```\n Layout.tsx  Main.tsx  test.tsx\n     │         │          │\n     └─────────┼──────────┘\n               ▼\n          ┌──────────┐\n          │ App.tsx  │\n          │ (target) │\n          └──────────┘\n```\n\nUse `forward` to understand what a file depends on. Use `reverse` to see a file's consumers — useful for gauging blast radius before a refactor.\n\n#### Output Formats\n\n**`summary`** (default) — Grouped table view in the terminal. Shows imports and importers categorized by file type, plus stats.\n\n```\n═══════════════════════════════════════════════════════════════\n  FILE SUMMARY: useUser.ts\n  Path: domains/user/hooks/useUser.ts\n═══════════════════════════════════════════════════════════════\n\n📥 IMPORTS (what this file depends on)\n  🔨 method        user-logic.ts\n  🏗️ infrastructure ServiceFactory.ts\n  📝 type          user-types.ts\n\n📤 IMPORTED BY (what depends on this file)\n  📊 hook-data     useUserData.ts\n  ⚡ hook-action   useUserAction.ts\n\n📊 STATS\n  Nodes: 5  │  Edges: 4  │  Circular: 0\n═══════════════════════════════════════════════════════════════\n```\n\n**`tree`** — ASCII tree in the terminal. Respects `--depth` to control how deep the traversal goes.\n\n```\n📦 domains/user/hooks/useUser.ts\n├── 🔨 domains/user/methods/user-logic.ts\n│   └── ⚙️ domains/user/services/user-service.ts\n│       └── 🏗️ infrastructure/BaseService.ts\n├── 🏗️ infrastructure/ServiceFactory.ts\n└── 📝 domains/user/types/user-types.ts\n```\n\n**`json`** — Full structured output. Contains `nodes`, `edges`, `metadata`, and `stats`. Pipe to `jq` or consume in scripts.\n\n```bash\nrbor deps domains/user -f json | jq '.stats'\nrbor deps domains/user -f json -o deps.json\n```\n\n```json\n{\n  \"nodes\": [\n    { \"id\": \"domains/user/hooks/useUser.ts\", \"type\": \"internal\", \"category\": \"hook-controller\" }\n  ],\n  \"edges\": [\n    {\n      \"source\": \"domains/user/hooks/useUser.ts\",\n      \"target\": \"domains/user/methods/user-logic.ts\",\n      \"importType\": \"static\"\n    }\n  ],\n  \"metadata\": { \"direction\": \"forward\", \"circularDependencies\": [] },\n  \"stats\": { \"nodeCount\": 5, \"edgeCount\": 4 }\n}\n```\n\n**`dot`** — [Graphviz DOT](https://graphviz.org/) format. Use if you have Graphviz installed locally or want to paste into an online viewer.\n\n```bash\nrbor deps domains/user -f dot -o deps.dot\ndot -Tpng deps.dot -o deps.png          # render with Graphviz\n```\n\n**`svg`** — Renders the DOT graph to an SVG image using `@viz-js/viz` (bundled, no external install needed). This is the richest format — color-coded nodes, labeled edges, and circular dependency highlighting.\n\n```bash\nrbor deps domains/user -f svg -o deps.svg\n# Open deps.svg in your browser or VS Code\n```\n\nSVG/DOT node colors:\n\n```\n  ┌────────────────────────────┐\n  │  🟣 Entry point (purple)   │\n  │  🔵 Internal file (blue)   │\n  │  🟢 External package (green)│\n  │  🟡 Dynamic import (amber) │\n  │  ⚪ Built-in module (grey) │\n  └────────────────────────────┘\n```\n\n#### Circular Dependency Detection\n\nAll formats detect and report circular imports. In SVG/DOT output they're visually highlighted:\n\n```\n  Normal edge:              Circular edge:\n\n  ┌────────┐                ┌────────┐\n  │  A.ts  │                │  A.ts  │ (red border)\n  └───┬────┘                └───┬────┘\n      │                         │\n      ▼                         ▼ ⚠ circular (red edge)\n  ┌────────┐                ┌────────┐\n  │  B.ts  │                │  B.ts  │ (red border)\n  └────────┘                └────────┘\n\n  🔴 Red borders — nodes involved in a cycle\n  🔴 Red edges   — the circular import itself, labeled \"⚠ circular\"\n  📋 Legend box   — appears in the bottom-left with the cycle count\n```\n\nThe `summary` and `tree` formats print `(circular)` inline when a cycle is encountered.\n\n#### Recipes\n\n```bash\n# Quick overview of a domain's internal structure\nrbor deps domains/auth -f tree --depth 3\n\n# Full SVG graph saved to file\nrbor deps domains/auth -f svg -o auth-deps.svg\n\n# Reverse lookup: who depends on this service?\nrbor deps domains/auth/services/auth-service.ts -d reverse -f tree\n\n# Include npm packages in the graph\nrbor deps src/App.tsx -f svg --include-external -o full-deps.svg\n\n# Shallow analysis (immediate imports only)\nrbor deps domains/auth/hooks/useAuth.ts -f summary --depth 1\n\n# JSON for scripting / CI pipelines\nrbor deps domains/auth -f json -o deps.json\n\n# Custom aliases (on top of tsconfig auto-detection)\nrbor deps src/App.tsx --aliases \"@shared/=src/shared/,@lib/=lib/\"\n```\n\n---\n\n## ⚙️ Configuration\n\n### `.rborrc.json`\n\n```json\n{\n  \"http\": \"axios\",\n  \"domainsPath\": \"domains\",\n  \"infrastructurePath\": \"infrastructure\",\n  \"schema\": { \"library\": \"zod\" }\n}\n```\n\n| Option               | Description               | Values                 |\n| -------------------- | ------------------------- | ---------------------- |\n| `http`               | Default HTTP client       | `axios`, `fetch`, `ky` |\n| `domainsPath`        | Where to generate domains | Any path               |\n| `infrastructurePath` | Shared infrastructure dir | Any path               |\n| `schema.library`     | Validation library        | `zod`, `yup`, `none`   |\n\nCLI flags always override config values.\n\n---\n\n## 🏗️ Architecture Philosophy\n\n**02-rBOR** is built on the **Dependency Inversion Principle** — higher layers control the flow, lower layers remain independent abstractions.\n\n### The Layer Model\n\n```\nLayer 0  │  type, schema, constant, config, util     ← importable by anyone (pure data)\nLayer 1  │  infrastructure (BaseService, Factory)     ← independent, no domain knowledge\nLayer 2  │  service (extends BaseService)             ← depends only on infrastructure\nLayer 3  │  method (pure async functions)             ← depends on service, no React\nLayer 4  │  hook-controller (useUser)                 ← wires service + methods\nLayer 5  │  hook-data / hook-action                   ← consumes controller, independent siblings\nLayer 6  │  component (User.tsx)                      ← renders from hooks\nLayer 7  │  page (route)                              ← composes components\n```\n\nEach layer can import from the **same layer or below**, never above. `hook-data` and `hook-action` are at the same level but must stay independent — both consume the controller, neither consumes the other.\n\n### Why this works\n\n1. **Feature Containerization** — Each domain is self-contained with a single barrel export. The rest of the app imports `from 'domains/user'`, never `from 'domains/user/services/user-service'`.\n2. **Downward Dependencies** — Complexity flows down: Page → Component → Hook → Method → Service → Infrastructure. Upper layers orchestrate lower layers, never the reverse.\n3. **Layer Separation** — React stays in the component and hook layers. Methods are pure async functions that receive a service object and return data. You can unit test them without rendering anything.\n4. **No Cross-Domain Imports** — `domains/auth` must never import from `domains/user`. Shared logic goes in `infrastructure/`.\n5. **Service as a Parameter** — Methods don't create their own HTTP clients. They receive the service object from the hook, making them easy to mock and test.\n6. **Sibling Isolation** — `useUserData` (fetching) and `useUserAction` (mutations) are independent. They both depend on `useUser` (the controller), but never on each other. This prevents tangled state flows between reads and writes.\n\n### Infrastructure (shared across all domains)\n\n```\ninfrastructure/\n├── BaseService.ts       # Abstract class — creates axios instance, interceptors, base CRUD methods\n├── ServiceFactory.ts    # Registry-based factory — services self-register, factory never imports domain code\n└── generateURL.ts       # URL builder — replaces :params and appends ?query strings\n```\n\n- **BaseService** — Every domain service extends this. It creates an axios instance with configured `baseURL`, `timeout`, and request/response interceptors. Exposes `protected` `get`, `post`, `put`, `delete` methods that all domain services inherit.\n- **ServiceFactory** — A registry-based factory. Each domain service calls `ServiceFactory.register('KEY', () => new DomainService())` at the bottom of its own file. The factory never imports domain code — it just stores creators and instantiates on demand via `ServiceFactory.create('KEY')`. This keeps infrastructure fully independent (Dependency Inversion).\n- **generateURL** — Utility for URL parameter substitution (`/users/:id` → `/users/42`) and query string building.\n\n---\n\n## 🧪 Testing\n\n```bash\nnpm test              # Run all tests\nnpm run test:watch    # Watch mode\nnpm run test:coverage # Coverage report\n```\n\n---\n\n## 💡 Examples\n\n```bash\n# Full domain setup\nrbor domain auth --http axios\ncd domains/auth\nrbor endpoint auth/login\nrbor endpoint auth/logout\nrbor endpoint auth/refresh\nrbor constant session-timeout=1800000\n\n# Generate more domains\nrbor domain user\nrbor domain products --http ky\n\n# Analyze and validate\nrbor validate --strict\nrbor deps domains/auth -d forward -f svg -o auth-deps.svg\nrbor list\n```\n\n---\n\n## 📄 License\n\nMIT © [02-davinci-01](https://github.com/02-davinci-01)\n\n---\n\n**rendered to reality by [02-davinci-01](https://02-davinci-01.vercel.app)**\n","readmeFilename":"README.md"}