02-rbor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +429 -0
  3. package/bin/rbor.js +3 -0
  4. package/dist/analyzers/file-categorizer.d.ts +5 -0
  5. package/dist/analyzers/file-categorizer.js +269 -0
  6. package/dist/analyzers/file-categorizer.js.map +1 -0
  7. package/dist/analyzers/file-categorizer.test.d.ts +1 -0
  8. package/dist/analyzers/file-categorizer.test.js +155 -0
  9. package/dist/analyzers/file-categorizer.test.js.map +1 -0
  10. package/dist/analyzers/graph-builder.d.ts +4 -0
  11. package/dist/analyzers/graph-builder.js +509 -0
  12. package/dist/analyzers/graph-builder.js.map +1 -0
  13. package/dist/analyzers/import-parser.d.ts +8 -0
  14. package/dist/analyzers/import-parser.js +285 -0
  15. package/dist/analyzers/import-parser.js.map +1 -0
  16. package/dist/analyzers/import-parser.test.d.ts +1 -0
  17. package/dist/analyzers/import-parser.test.js +177 -0
  18. package/dist/analyzers/import-parser.test.js.map +1 -0
  19. package/dist/analyzers/index.d.ts +4 -0
  20. package/dist/analyzers/index.js +28 -0
  21. package/dist/analyzers/index.js.map +1 -0
  22. package/dist/analyzers/output-formatters.d.ts +11 -0
  23. package/dist/analyzers/output-formatters.js +451 -0
  24. package/dist/analyzers/output-formatters.js.map +1 -0
  25. package/dist/analyzers/yo.d.ts +1 -0
  26. package/dist/analyzers/yo.js +10 -0
  27. package/dist/analyzers/yo.js.map +1 -0
  28. package/dist/app/App.d.ts +1 -0
  29. package/dist/app/App.js +6 -0
  30. package/dist/app/App.js.map +1 -0
  31. package/dist/cli.d.ts +5 -0
  32. package/dist/cli.js +167 -0
  33. package/dist/cli.js.map +1 -0
  34. package/dist/commands/analyze-deps.d.ts +12 -0
  35. package/dist/commands/analyze-deps.js +136 -0
  36. package/dist/commands/analyze-deps.js.map +1 -0
  37. package/dist/commands/generate-constant.d.ts +1 -0
  38. package/dist/commands/generate-constant.js +148 -0
  39. package/dist/commands/generate-constant.js.map +1 -0
  40. package/dist/commands/generate-domain.d.ts +2 -0
  41. package/dist/commands/generate-domain.js +87 -0
  42. package/dist/commands/generate-domain.js.map +1 -0
  43. package/dist/commands/generate-endpoint.d.ts +1 -0
  44. package/dist/commands/generate-endpoint.js +124 -0
  45. package/dist/commands/generate-endpoint.js.map +1 -0
  46. package/dist/commands/init.d.ts +8 -0
  47. package/dist/commands/init.js +32 -0
  48. package/dist/commands/init.js.map +1 -0
  49. package/dist/commands/list-domains.d.ts +1 -0
  50. package/dist/commands/list-domains.js +122 -0
  51. package/dist/commands/list-domains.js.map +1 -0
  52. package/dist/commands/validate.d.ts +4 -0
  53. package/dist/commands/validate.js +255 -0
  54. package/dist/commands/validate.js.map +1 -0
  55. package/dist/layouts/MainLayout.d.ts +1 -0
  56. package/dist/layouts/MainLayout.js +6 -0
  57. package/dist/layouts/MainLayout.js.map +1 -0
  58. package/dist/pages/HomePage.d.ts +1 -0
  59. package/dist/pages/HomePage.js +6 -0
  60. package/dist/pages/HomePage.js.map +1 -0
  61. package/dist/templates/barrel/index.d.ts +1 -0
  62. package/dist/templates/barrel/index.js +14 -0
  63. package/dist/templates/barrel/index.js.map +1 -0
  64. package/dist/templates/component/index.d.ts +1 -0
  65. package/dist/templates/component/index.js +6 -0
  66. package/dist/templates/component/index.js.map +1 -0
  67. package/dist/templates/component/main.d.ts +1 -0
  68. package/dist/templates/component/main.js +8 -0
  69. package/dist/templates/component/main.js.map +1 -0
  70. package/dist/templates/hooks/action.d.ts +1 -0
  71. package/dist/templates/hooks/action.js +49 -0
  72. package/dist/templates/hooks/action.js.map +1 -0
  73. package/dist/templates/hooks/controller.d.ts +1 -0
  74. package/dist/templates/hooks/controller.js +41 -0
  75. package/dist/templates/hooks/controller.js.map +1 -0
  76. package/dist/templates/hooks/data.d.ts +1 -0
  77. package/dist/templates/hooks/data.js +38 -0
  78. package/dist/templates/hooks/data.js.map +1 -0
  79. package/dist/templates/hooks/index.d.ts +3 -0
  80. package/dist/templates/hooks/index.js +10 -0
  81. package/dist/templates/hooks/index.js.map +1 -0
  82. package/dist/templates/index.d.ts +10 -0
  83. package/dist/templates/index.js +33 -0
  84. package/dist/templates/index.js.map +1 -0
  85. package/dist/templates/methods/index.d.ts +1 -0
  86. package/dist/templates/methods/index.js +85 -0
  87. package/dist/templates/methods/index.js.map +1 -0
  88. package/dist/templates/schema/index.d.ts +1 -0
  89. package/dist/templates/schema/index.js +40 -0
  90. package/dist/templates/schema/index.js.map +1 -0
  91. package/dist/templates/services/base-service-axios.d.ts +1 -0
  92. package/dist/templates/services/base-service-axios.js +77 -0
  93. package/dist/templates/services/base-service-axios.js.map +1 -0
  94. package/dist/templates/services/base-service-fetch.d.ts +1 -0
  95. package/dist/templates/services/base-service-fetch.js +113 -0
  96. package/dist/templates/services/base-service-fetch.js.map +1 -0
  97. package/dist/templates/services/base-service-ky.d.ts +1 -0
  98. package/dist/templates/services/base-service-ky.js +85 -0
  99. package/dist/templates/services/base-service-ky.js.map +1 -0
  100. package/dist/templates/services/base-service.d.ts +1 -0
  101. package/dist/templates/services/base-service.js +92 -0
  102. package/dist/templates/services/base-service.js.map +1 -0
  103. package/dist/templates/services/domain-service.d.ts +2 -0
  104. package/dist/templates/services/domain-service.js +95 -0
  105. package/dist/templates/services/domain-service.js.map +1 -0
  106. package/dist/templates/services/index.d.ts +7 -0
  107. package/dist/templates/services/index.js +23 -0
  108. package/dist/templates/services/index.js.map +1 -0
  109. package/dist/templates/services/service-factory.d.ts +4 -0
  110. package/dist/templates/services/service-factory.js +68 -0
  111. package/dist/templates/services/service-factory.js.map +1 -0
  112. package/dist/templates/types/index.d.ts +1 -0
  113. package/dist/templates/types/index.js +7 -0
  114. package/dist/templates/types/index.js.map +1 -0
  115. package/dist/templates/utils/build-url.d.ts +1 -0
  116. package/dist/templates/utils/build-url.js +72 -0
  117. package/dist/templates/utils/build-url.js.map +1 -0
  118. package/dist/templates/utils/endpoints.d.ts +2 -0
  119. package/dist/templates/utils/endpoints.js +23 -0
  120. package/dist/templates/utils/endpoints.js.map +1 -0
  121. package/dist/templates/utils/generateURL.d.ts +1 -0
  122. package/dist/templates/utils/generateURL.js +40 -0
  123. package/dist/templates/utils/generateURL.js.map +1 -0
  124. package/dist/templates/utils/index.d.ts +1 -0
  125. package/dist/templates/utils/index.js +7 -0
  126. package/dist/templates/utils/index.js.map +1 -0
  127. package/dist/types/dependency-graph.d.ts +95 -0
  128. package/dist/types/dependency-graph.js +13 -0
  129. package/dist/types/dependency-graph.js.map +1 -0
  130. package/dist/types/index.d.ts +2 -0
  131. package/dist/types/index.js +6 -0
  132. package/dist/types/index.js.map +1 -0
  133. package/dist/utils/config.d.ts +16 -0
  134. package/dist/utils/config.js +145 -0
  135. package/dist/utils/config.js.map +1 -0
  136. package/dist/utils/create-file.d.ts +13 -0
  137. package/dist/utils/create-file.js +159 -0
  138. package/dist/utils/create-file.js.map +1 -0
  139. package/dist/utils/dependency-installer.d.ts +5 -0
  140. package/dist/utils/dependency-installer.js +95 -0
  141. package/dist/utils/dependency-installer.js.map +1 -0
  142. package/dist/utils/file-finder.d.ts +6 -0
  143. package/dist/utils/file-finder.js +80 -0
  144. package/dist/utils/file-finder.js.map +1 -0
  145. package/dist/utils/naming.d.ts +11 -0
  146. package/dist/utils/naming.js +46 -0
  147. package/dist/utils/naming.js.map +1 -0
  148. package/dist/utils/naming.test.d.ts +1 -0
  149. package/dist/utils/naming.test.js +106 -0
  150. package/dist/utils/naming.test.js.map +1 -0
  151. package/dist/utils/service-factory-updater.d.ts +2 -0
  152. package/dist/utils/service-factory-updater.js +87 -0
  153. package/dist/utils/service-factory-updater.js.map +1 -0
  154. package/package.json +95 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 02-davinci-01
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,429 @@
1
+ # 02-rBOR CLI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/02-rbor.svg)](https://www.npmjs.com/package/02-rbor)
4
+ [![CI](https://github.com/02-davinci-01/02-rbor/workflows/CI/badge.svg)](https://github.com/02-davinci-01/02-rbor/actions)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ > **Scaffold Clean Architecture-inspired React features with dependency graph analysis**
8
+
9
+ A 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.
10
+
11
+ ## 🤔 What is rBOR?
12
+
13
+ rBOR 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.
14
+
15
+ The 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.
16
+
17
+ Each domain follows a strict **downward dependency rule**:
18
+
19
+ ```
20
+ Component → Hook → Method → Service → Infrastructure
21
+ (UI) (wiring) (logic) (HTTP) (shared base)
22
+ ```
23
+
24
+ - Upper layers can import from lower layers, never the reverse.
25
+ - Methods are pure async functions — no React, no hooks, no state. Just data in, data out.
26
+ - Services create the raw API call object. Methods consume it. Hooks wire them together. Components render the result.
27
+ - Domains never import from each other. Shared code goes in `infrastructure/`.
28
+
29
+ ## 📦 Installation
30
+
31
+ ```bash
32
+ npm install -g 02-rbor
33
+ ```
34
+
35
+ Or use with npx:
36
+
37
+ ```bash
38
+ npx 02-rbor domain auth
39
+ ```
40
+
41
+ ## 🚀 Quick Start
42
+
43
+ ### 1. Initialize your project
44
+
45
+ ```bash
46
+ rbor init
47
+ ```
48
+
49
+ This creates a `.rborrc.json` configuration file with your project defaults.
50
+
51
+ ### 2. Generate your first domain
52
+
53
+ ```bash
54
+ # Interactive mode — prompts for name and HTTP client
55
+ rbor domain
56
+
57
+ # Or pass the name directly
58
+ rbor domain user --http axios
59
+ ```
60
+
61
+ This generates a complete domain structure:
62
+
63
+ ```
64
+ domains/user/
65
+ ├── index.tsx # Barrel export (public API)
66
+ ├── __test__/ # Test directory
67
+ ├── components/
68
+ │ └── User.tsx # Main component
69
+ ├── hooks/
70
+ │ ├── useUser.ts # Controller hook (creates service, wires methods)
71
+ │ ├── useUserData.ts # Data hook (React Query)
72
+ │ └── useUserAction.ts # Action hook (mutations)
73
+ ├── methods/
74
+ │ └── user-logic.ts # Pure async functions (React-independent)
75
+ ├── schema/
76
+ │ └── user-schema.ts # Validation schema (zod)
77
+ ├── services/
78
+ │ └── user-service.ts # Domain service (HTTP layer)
79
+ ├── types/
80
+ │ └── user-types.ts # TypeScript types
81
+ └── utils/
82
+ ├── constant/
83
+ │ ├── user-constants.ts
84
+ │ └── user-endpoints.ts
85
+ └── helper/
86
+ └── user-helpers.ts
87
+ ```
88
+
89
+ #### What each folder does
90
+
91
+ | Folder | Purpose | Rules |
92
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | **`components/`** | React UI. Renders data, handles user interaction. | Can import from `hooks/`. Nothing else in the domain. |
94
+ | **`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. |
95
+ | **`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. |
96
+ | **`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/`. |
97
+ | **`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. |
98
+ | **`types/`** | TypeScript interfaces and types for this domain. | Pure type definitions. |
99
+ | **`utils/constant/`** | Endpoint paths and domain-specific constants (timeouts, config values, feature flags). | Pure values — no logic. |
100
+ | **`utils/helper/`** | Domain-specific utility functions (formatters, transformers, parsers). | Pure functions — no React, no service calls. |
101
+ | **`__test__/`** | Tests for this domain. | Mirrors the folder structure above. |
102
+ | **`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. |
103
+
104
+ #### How data flows
105
+
106
+ ```
107
+ ┌─────────────┐ ┌──────────┐ ┌────────────┐ ┌─────────────┐ ┌──────────────────┐
108
+ │ Component │────▶│ Hook │────▶│ Method │────▶│ Service │────▶│ Infrastructure │
109
+ │ (User.tsx) │ │(useUser) │ │(user-logic)│ │(UserService)│ │ (BaseService) │
110
+ └─────────────┘ └──────────┘ └────────────┘ └─────────────┘ └──────────────────┘
111
+ UI wiring pure logic HTTP calls axios instance
112
+ renders creates receives extends interceptors
113
+ data service & service as BaseService base URL
114
+ passes to 1st param ▲ timeout
115
+ methods │
116
+ ServiceFactory.create()
117
+ ```
118
+
119
+ The **ServiceFactory** is the single entry point for creating service instances. When the hook calls `ServiceFactory.create('USER')`, it instantiates `UserService`, which inherits from `BaseService` — that's where the axios instance, interceptors, base URL, and timeout live. The service object gets passed down to your methods, which use it to make API calls.
120
+
121
+ ### 3. Add endpoints and constants
122
+
123
+ ```bash
124
+ cd domains/user
125
+ rbor endpoint users/:id/profile # → USERS_ID_PROFILE
126
+ rbor constant timeout=3000 # → TIMEOUT = 3000
127
+ ```
128
+
129
+ ### 4. Analyze dependencies
130
+
131
+ ```bash
132
+ # Who imports this file?
133
+ rbor deps domains/user/components/User.tsx -d reverse -f svg -o deps.svg
134
+
135
+ # What does this file import?
136
+ rbor deps src/app/App.tsx -d forward -f tree
137
+ ```
138
+
139
+ ### 5. Validate architecture
140
+
141
+ ```bash
142
+ rbor validate
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 📚 Commands
148
+
149
+ | Command | Description |
150
+ | --------------------------- | ------------------------------------------------ |
151
+ | `rbor init` | Initialize `.rborrc.json` configuration |
152
+ | `rbor domain [name]` | Generate a domain (interactive if no name given) |
153
+ | `rbor endpoint <path>` | Add an endpoint to the current domain |
154
+ | `rbor constant <key=value>` | Add a constant to the current domain |
155
+ | `rbor list` | List all domains with metadata |
156
+ | `rbor validate` | Validate architecture rules |
157
+ | `rbor deps <path>` | Analyze dependency graph |
158
+ | `rbor davinci` | Credits |
159
+
160
+ ---
161
+
162
+ ### `rbor init`
163
+
164
+ Initialize rBOR configuration in your project.
165
+
166
+ ```bash
167
+ rbor init [options]
168
+
169
+ Options:
170
+ --http <client> HTTP client (axios, fetch, ky)
171
+ --domains-path <path> Path to domains folder
172
+ --infrastructure-path <path> Path to infrastructure folder
173
+ --force Overwrite existing config
174
+ ```
175
+
176
+ Creates `.rborrc.json`:
177
+
178
+ ```json
179
+ {
180
+ "http": "axios",
181
+ "domainsPath": "domains",
182
+ "infrastructurePath": "infrastructure",
183
+ "schema": { "library": "zod" }
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ### `rbor domain [name]`
190
+
191
+ Generate a new domain with the full 02-rBOR structure.
192
+
193
+ ```bash
194
+ # Interactive mode (prompts for name, HTTP client, confirmation)
195
+ rbor domain
196
+
197
+ # Direct mode
198
+ rbor domain auth
199
+ rbor domain products --http ky
200
+ ```
201
+
202
+ **What it generates:**
203
+
204
+ - ✅ Component with TypeScript + JSX
205
+ - ✅ Three-hook pattern (controller, data, action)
206
+ - ✅ Pure domain logic (methods receive service, stay React-free)
207
+ - ✅ Service layer with HTTP client integration
208
+ - ✅ Validation schemas (zod)
209
+ - ✅ Type definitions
210
+ - ✅ Constants and endpoint files
211
+ - ✅ Barrel export (index.tsx)
212
+
213
+ **Hook pattern:**
214
+
215
+ Three hooks are generated per domain:
216
+
217
+ - **`use<Domain>`** — Controller hook. Creates a service object and wires up all methods:
218
+ - **`use<Domain>Data`** — Data hook. Fetches server state using React Query (commented scaffold).
219
+ - **`use<Domain>Action`** — Action hook. Mutation actions via React Query (commented scaffold).
220
+
221
+ The controller hook wires up services and methods:
222
+
223
+ ```ts
224
+ export const useUser = () => {
225
+ const service = ServiceFactory.create('USER') as UserService;
226
+
227
+ return {
228
+ getList: () => getUserList(service),
229
+ getById: (id: string) => getUserById(service, id),
230
+ create: (data: unknown) => createUser(service, data),
231
+ update: (id: string, data: unknown) => updateUser(service, id, data),
232
+ remove: (id: string) => deleteUser(service, id),
233
+ };
234
+ };
235
+ ```
236
+
237
+ > **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.
238
+
239
+ ---
240
+
241
+ ### `rbor endpoint <path>`
242
+
243
+ Add an API endpoint constant to an existing domain. Run from inside `domains/<domain>/`.
244
+
245
+ ```bash
246
+ rbor endpoint users/:id/profile
247
+ ```
248
+
249
+ Generates ALL_CAPS keys and appends to `utils/constant/<domain>-endpoints.ts`:
250
+
251
+ ```ts
252
+ export const AUTH_ENDPOINTS = {
253
+ LOGIN: '/login',
254
+ USERS_ID_PROFILE: '/users/:id/profile',
255
+ } as const;
256
+ ```
257
+
258
+ ---
259
+
260
+ ### `rbor constant <key=value>`
261
+
262
+ Add a constant to the current domain's constants file. Run from inside `domains/<domain>/`.
263
+
264
+ ```bash
265
+ rbor constant timeout=3000 # → export const TIMEOUT = 3000;
266
+ rbor constant maxRetries=5 # → export const MAX_RETRIES = 5;
267
+ rbor constant api-url=https://x # → export const API_URL = 'https://x';
268
+ rbor constant debug=true # → export const DEBUG = true;
269
+ ```
270
+
271
+ Auto-detects value types — numbers and booleans stay unquoted, strings get wrapped in quotes.
272
+
273
+ ---
274
+
275
+ ### `rbor list`
276
+
277
+ List all domains with metadata.
278
+
279
+ ```bash
280
+ rbor list # or: rbor ls
281
+ ```
282
+
283
+ ---
284
+
285
+ ### `rbor validate`
286
+
287
+ Enforce 02-rBOR architectural rules.
288
+
289
+ ```bash
290
+ rbor validate # or: rbor lint
291
+ rbor validate --strict # treat warnings as errors
292
+ ```
293
+
294
+ **What it checks:**
295
+
296
+ - ❌ **No cross-domain imports** — Domains must not import from each other
297
+ - ❌ **Downward-only dependencies** — Components → Hooks → Methods → Services
298
+ - ❌ **No React in methods layer** — Pure logic must be framework-free
299
+ - ⚠️ **Barrel exports** — Every domain should have an index.tsx
300
+ - ⚠️ **Circular dependencies** — Warns about import cycles
301
+
302
+ ---
303
+
304
+ ### `rbor deps <path>`
305
+
306
+ Analyze dependency graphs for files or directories.
307
+
308
+ ```bash
309
+ rbor deps <path> [options]
310
+
311
+ Options:
312
+ -d, --direction <dir> forward | reverse (default: forward)
313
+ -f, --format <fmt> json | summary | tree | dot | svg (default: summary)
314
+ -o, --output <file> Write output to file
315
+ --depth <n> Maximum traversal depth (default: 10)
316
+ --include-external Include npm packages
317
+ --include-tests Include test files
318
+ ```
319
+
320
+ **Examples:**
321
+
322
+ ```bash
323
+ # Tree view of what a file imports
324
+ rbor deps src/App.tsx -f tree
325
+
326
+ # SVG graph of who imports a file (opens in VS Code)
327
+ rbor deps domains/auth/components/Auth.tsx -d reverse -f svg -o deps.svg
328
+
329
+ # JSON output for tooling
330
+ rbor deps domains/auth -f json -o deps.json
331
+ ```
332
+
333
+ **Circular dependency detection:**
334
+
335
+ When circular dependencies are found, the SVG/DOT output highlights them:
336
+
337
+ - 🔴 **Red borders** on nodes involved in cycles
338
+ - 🔴 **Red edges** with "⚠ circular" labels
339
+ - 📋 **Legend box** showing the cycle count
340
+
341
+ The tree and summary formats also report circular dependencies inline.
342
+
343
+ ---
344
+
345
+ ## ⚙️ Configuration
346
+
347
+ ### `.rborrc.json`
348
+
349
+ ```json
350
+ {
351
+ "http": "axios",
352
+ "domainsPath": "domains",
353
+ "infrastructurePath": "infrastructure",
354
+ "schema": { "library": "zod" }
355
+ }
356
+ ```
357
+
358
+ | Option | Description | Values |
359
+ | -------------------- | ------------------------- | ---------------------- |
360
+ | `http` | Default HTTP client | `axios`, `fetch`, `ky` |
361
+ | `domainsPath` | Where to generate domains | Any path |
362
+ | `infrastructurePath` | Shared infrastructure dir | Any path |
363
+ | `schema.library` | Validation library | `zod`, `yup`, `none` |
364
+
365
+ CLI flags always override config values.
366
+
367
+ ---
368
+
369
+ ## 🏗️ Architecture Philosophy
370
+
371
+ **02-rBOR** enforces:
372
+
373
+ 1. **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'`.
374
+ 2. **Downward Dependencies** — Complexity flows down: Component → Hook → Method → Service → Infrastructure. Upper layers can import from lower, never the reverse.
375
+ 3. **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.
376
+ 4. **No Cross-Domain Imports** — `domains/auth` must never import from `domains/user`. Shared logic goes in `infrastructure/`.
377
+ 5. **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.
378
+
379
+ ### Infrastructure (shared across all domains)
380
+
381
+ ```
382
+ infrastructure/
383
+ ├── BaseService.ts # Abstract class — creates axios instance, interceptors, base CRUD methods
384
+ ├── ServiceFactory.ts # Factory — maps domain keys to service classes (auto-updated by CLI)
385
+ └── generateURL.ts # URL builder — replaces :params and appends ?query strings
386
+ ```
387
+
388
+ - **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.
389
+ - **ServiceFactory** — A static factory that maps string keys (`'USER'`, `'AUTH'`) to their service class. The CLI auto-updates this file every time you generate a new domain.
390
+ - **generateURL** — Utility for URL parameter substitution (`/users/:id` → `/users/42`) and query string building.
391
+
392
+ ---
393
+
394
+ ## 🧪 Testing
395
+
396
+ ```bash
397
+ npm test # Run all tests
398
+ npm run test:watch # Watch mode
399
+ npm run test:coverage # Coverage report
400
+ ```
401
+
402
+ ---
403
+
404
+ ## 💡 Examples
405
+
406
+ ```bash
407
+ # Full domain setup
408
+ rbor domain auth --http axios
409
+ cd domains/auth
410
+ rbor endpoint auth/login
411
+ rbor endpoint auth/logout
412
+ rbor endpoint auth/refresh
413
+ rbor constant session-timeout=1800000
414
+
415
+ # Analyze and validate
416
+ rbor validate --strict
417
+ rbor deps domains/auth -d forward -f svg -o auth-deps.svg
418
+ rbor list
419
+ ```
420
+
421
+ ---
422
+
423
+ ## 📄 License
424
+
425
+ MIT © [02-davinci-01](https://github.com/02-davinci-01)
426
+
427
+ ---
428
+
429
+ **rendered to reality by [02-davinci-01](https://02-davinci-01.vercel.app)**
package/bin/rbor.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/cli.js');
@@ -0,0 +1,5 @@
1
+ import type { InternalFileCategory, ExternalPackageCategory, NodeType } from '../types/dependency-graph';
2
+ export declare function categorizeInternalFile(filePath: string): InternalFileCategory;
3
+ export declare function categorizeExternalPackage(packageName: string): ExternalPackageCategory;
4
+ export declare function determineNodeType(importPath: string, isRelative: boolean, isDynamic: boolean, isBuiltin: boolean): NodeType;
5
+ export declare function isEntryFile(filePath: string): boolean;