honotan 0.4.0 → 0.6.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.
- package/README.md +81 -549
- package/dist/index.mjs +2221 -225
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,599 +1,144 @@
|
|
|
1
1
|
# Honotan CLI
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
## Philosophy
|
|
6
|
-
|
|
7
|
-
Honotan CLI is built on the belief that **monorepos** and **hexagonal architecture** are the foundation of scalable, maintainable backend systems. This CLI helps you:
|
|
8
|
-
|
|
9
|
-
- 🏗️ **Build monorepos from day one** – Start with proper structure, not technical debt
|
|
10
|
-
- 🎯 **Focus on domain logic** – Hexagonal architecture keeps your business logic pure and testable
|
|
11
|
-
- 🔌 **Swap implementations freely** – Ports & adapters let you change databases, frameworks, or protocols without touching core logic
|
|
12
|
-
- 🌐 **Polyglot-ready** – Generate APIs in multiple languages (TypeScript, Go) with consistent architecture
|
|
13
|
-
- 📦 **Organized by domain** – Each API module is self-contained with clear boundaries
|
|
3
|
+
**Scaffold production-ready monorepos with hexagonal architecture** – opinionated, Bun-native, TypeScript-first.
|
|
14
4
|
|
|
15
5
|
## Features
|
|
16
6
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
- `packages/` – Shared libraries and utilities
|
|
23
|
-
- Workspace management (bun, yarn, npm)
|
|
24
|
-
- Consistent tooling across all packages
|
|
25
|
-
|
|
26
|
-
### Hexagonal Architecture (Primary Pattern)
|
|
27
|
-
|
|
28
|
-
Every generated API follows clean hexagonal principles:
|
|
29
|
-
|
|
30
|
-
- **Domain Layer** – Pure business entities and logic
|
|
31
|
-
- **Application Layer** – Use cases and port interfaces
|
|
32
|
-
- **Adapters Layer**
|
|
33
|
-
- **Inbound**: HTTP, WebSocket, CLI, GraphQL
|
|
34
|
-
- **Outbound**: Databases, Cache, Message Queues, External APIs
|
|
35
|
-
- **Dependency Injection** – Composition roots wire everything together
|
|
36
|
-
|
|
37
|
-
### Multi-Language Support
|
|
38
|
-
|
|
39
|
-
Generate production-ready APIs in:
|
|
40
|
-
|
|
41
|
-
- **TypeScript/Node.js** – Hono, Express, Fastify
|
|
42
|
-
- **Go** – Chi router with modern Go practices
|
|
43
|
-
- _More languages coming soon_
|
|
44
|
-
|
|
45
|
-
### Full-Stack Ready
|
|
46
|
-
|
|
47
|
-
Optional client generation with:
|
|
48
|
-
|
|
49
|
-
- **TanStack Router** – File-based routing for React
|
|
50
|
-
- **TanStack Query** – Server state management
|
|
51
|
-
- **TanStack Store** – Client state management
|
|
52
|
-
- **Tailwind CSS** – Modern styling
|
|
7
|
+
- **Monorepo generator** – complete `apps/` + `packages/` workspace with Turborepo
|
|
8
|
+
- **Hexagonal API scaffolding** – domain, application, and adapter layers with dependency injection
|
|
9
|
+
- **Full-stack optional** – TanStack Router + React web app with shadcn components
|
|
10
|
+
- **Infra packages à la carte** – pick only what you need
|
|
11
|
+
- **Polyglot** – TypeScript (Hono) and Go (Chi) API support
|
|
53
12
|
|
|
54
13
|
## Installation
|
|
55
14
|
|
|
56
|
-
Install globally with your preferred package manager:
|
|
57
|
-
|
|
58
15
|
```bash
|
|
59
|
-
# Using npm
|
|
60
|
-
npm install -g honotan
|
|
61
|
-
|
|
62
|
-
# Using bun (recommended for monorepos)
|
|
63
16
|
bun add -g honotan
|
|
64
|
-
|
|
65
|
-
# Using bun
|
|
66
|
-
bun add -g honotan
|
|
67
|
-
|
|
68
|
-
# Using yarn
|
|
69
|
-
yarn global add honotan
|
|
70
17
|
```
|
|
71
18
|
|
|
72
19
|
## Quick Start
|
|
73
20
|
|
|
74
|
-
**Create your first monorepo API in 2 minutes:**
|
|
75
|
-
|
|
76
21
|
```bash
|
|
77
|
-
#
|
|
22
|
+
# Generate a full monorepo
|
|
78
23
|
honotan generate monorepo
|
|
79
24
|
|
|
80
|
-
#
|
|
81
|
-
cd my-api-platform
|
|
82
|
-
|
|
83
|
-
# 3. Generate your first API
|
|
25
|
+
# Add a hexagonal API resource inside your project
|
|
84
26
|
honotan generate api
|
|
85
27
|
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
# 5. Run tests
|
|
90
|
-
bun test
|
|
91
|
-
|
|
92
|
-
# 6. Start development server
|
|
93
|
-
bun dev
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**That's it!** You now have a production-ready monorepo with hexagonal architecture.
|
|
97
|
-
|
|
98
|
-
## Local Development
|
|
99
|
-
|
|
100
|
-
To install and work on this project locally:
|
|
101
|
-
|
|
102
|
-
### 1. Clone the Repository
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
git clone https://github.com/rifkyputra/honotan-cli.git
|
|
106
|
-
cd honotan
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### 2. Install Dependencies
|
|
110
|
-
|
|
111
|
-
Using Bun (recommended):
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
bun install
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Or using npm:
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
npm install
|
|
28
|
+
# Generate a standalone client app
|
|
29
|
+
honotan generate client
|
|
121
30
|
```
|
|
122
31
|
|
|
123
|
-
|
|
32
|
+
## Monorepo Generator
|
|
124
33
|
|
|
125
34
|
```bash
|
|
126
|
-
|
|
127
|
-
# or
|
|
128
|
-
npm run build
|
|
35
|
+
honotan generate monorepo
|
|
129
36
|
```
|
|
130
37
|
|
|
131
|
-
|
|
38
|
+
Interactive prompts let you choose:
|
|
132
39
|
|
|
133
|
-
|
|
40
|
+
- **API framework** – Hono (default) or Go
|
|
41
|
+
- **Client** – TanStack Router (React)
|
|
42
|
+
- **Infrastructure packages** – any combination of the packages below
|
|
134
43
|
|
|
135
|
-
|
|
136
|
-
npm link
|
|
137
|
-
# or
|
|
138
|
-
bun link
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Now you can run `honotan` from anywhere on your system.
|
|
142
|
-
|
|
143
|
-
### 5. Development Mode
|
|
44
|
+
### Always generated
|
|
144
45
|
|
|
145
|
-
|
|
46
|
+
| Path | Purpose |
|
|
47
|
+
| ------ | ------- |
|
|
48
|
+
| `packages/config` | Shared TypeScript base config |
|
|
49
|
+
| `packages/env` | Validated env vars (`@t3-oss/env-core` + Zod) |
|
|
50
|
+
| `apps/server` | API server with a `hello` example resource |
|
|
146
51
|
|
|
147
|
-
|
|
148
|
-
bun run dev
|
|
149
|
-
# or
|
|
150
|
-
npm run dev
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### 6. Type Checking
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
bun run check-types
|
|
157
|
-
# or
|
|
158
|
-
npm run check-types
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 7. Running Tests
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
bun test
|
|
165
|
-
# or
|
|
166
|
-
npm test
|
|
167
|
-
```
|
|
52
|
+
### Optional infrastructure packages
|
|
168
53
|
|
|
169
|
-
|
|
54
|
+
| Flag | Package | Stack |
|
|
55
|
+
| ---- | ------- | ----- |
|
|
56
|
+
| `db` | `packages/db` | PostgreSQL via `Bun.sql` |
|
|
57
|
+
| `db-turso` | `packages/db` | SQLite/Turso via Drizzle + `@libsql/client` |
|
|
58
|
+
| `cache` | `packages/cache` | Redis via `Bun.redis` |
|
|
59
|
+
| `event-driven` | `packages/event-driven` | RabbitMQ via `amqplib` |
|
|
60
|
+
| `auth` | `packages/auth` | `better-auth` (drizzle adapter when db-turso, native pg otherwise) |
|
|
61
|
+
| `s3` | `packages/s3` | S3-compatible object storage via `aws4fetch` (Cloudflare R2, AWS S3, MinIO) |
|
|
62
|
+
| `pwa` | – | `vite-plugin-pwa` support in the web app |
|
|
170
63
|
|
|
171
|
-
|
|
172
|
-
honotan generate monorepo
|
|
173
|
-
```
|
|
64
|
+
### Client app (`apps/web`)
|
|
174
65
|
|
|
175
|
-
|
|
66
|
+
Generated when TanStack Router is selected:
|
|
176
67
|
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
68
|
+
- Vite + React + TypeScript
|
|
69
|
+
- TailwindCSS v4 (`@tailwindcss/vite` – no config files needed)
|
|
70
|
+
- TanStack Router `^1.141.1`
|
|
71
|
+
- shadcn components (button, dropdown, skeleton, sonner)
|
|
72
|
+
- Theme toggle (light / dark)
|
|
73
|
+
- Auth-aware header + user menu when `auth` is enabled
|
|
183
74
|
|
|
184
|
-
|
|
75
|
+
## Hexagonal API Generator
|
|
185
76
|
|
|
186
77
|
```bash
|
|
187
78
|
honotan generate api
|
|
188
79
|
```
|
|
189
80
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
1. Choose your programming language (TypeScript, Go)
|
|
193
|
-
2. Select an API framework (Hono, Express, Fastify, Chi)
|
|
194
|
-
3. Enter a resource name (e.g., "product", "user", "order")
|
|
195
|
-
4. Select inbound adapters (HTTP, WebSocket, GraphQL)
|
|
196
|
-
5. Select outbound adapters (In-Memory, Database, Cache, Message Queue)
|
|
197
|
-
6. Specify output directory (default: monorepo structure)
|
|
198
|
-
|
|
199
|
-
**Generated Structure** (Hexagonal):
|
|
81
|
+
Generates a self-contained resource module inside `apps/server/src/<name>/`:
|
|
200
82
|
|
|
201
83
|
```
|
|
202
84
|
src/product/
|
|
203
85
|
├── domain/
|
|
204
|
-
│
|
|
86
|
+
│ ├── entities/ # Business models
|
|
87
|
+
│ └── ports/
|
|
88
|
+
│ ├── in/ # Use case interfaces
|
|
89
|
+
│ └── out/ # Repository interfaces
|
|
205
90
|
├── application/
|
|
206
|
-
│
|
|
207
|
-
│ │ ├── in/ # Use case interfaces
|
|
208
|
-
│ │ └── out/ # Repository interfaces
|
|
209
|
-
│ └── use-cases/ # Business logic implementation
|
|
91
|
+
│ └── use-cases/ # Business logic + tests
|
|
210
92
|
├── adapters/
|
|
211
|
-
│ ├── in/
|
|
212
|
-
│
|
|
213
|
-
|
|
214
|
-
│ ├── persistence/ # Database implementations
|
|
215
|
-
│ └── cache/ # Caching implementations
|
|
216
|
-
└── composition/ # Dependency injection
|
|
93
|
+
│ ├── in/http/ # Routes, controllers, validation
|
|
94
|
+
│ └── out/persistence/ # Repository implementations
|
|
95
|
+
└── index.ts # Composition root
|
|
217
96
|
```
|
|
218
97
|
|
|
219
|
-
|
|
98
|
+
Supported frameworks: **Hono**, **Go (Chi)**
|
|
99
|
+
Inbound adapters: **HTTP**, **WebSocket**
|
|
100
|
+
Outbound adapters: **In-Memory**, **Database**, **Cache**
|
|
220
101
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
honotan generate api
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Follow the interactive prompts to:
|
|
228
|
-
|
|
229
|
-
1. Select an API framework (Hono, Express, Fastify, or Go)
|
|
230
|
-
2. Enter a resource name (e.g., "product", "user")
|
|
231
|
-
3. Select inbound and outbound adapters
|
|
232
|
-
4. Specify output directory
|
|
233
|
-
|
|
234
|
-
### Generate a Client Project
|
|
102
|
+
## Client Generator
|
|
235
103
|
|
|
236
104
|
```bash
|
|
237
105
|
honotan generate client
|
|
238
106
|
```
|
|
239
107
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
1. Enter a resource/project name
|
|
243
|
-
2. Specify output directory (default: "apps/<resource-name>")
|
|
244
|
-
3. Get a fully configured project ready to run
|
|
245
|
-
|
|
246
|
-
**What You Get:**
|
|
247
|
-
|
|
248
|
-
- ✅ Complete Vite + React + TypeScript setup
|
|
249
|
-
- ✅ TanStack Router with file-based routing
|
|
250
|
-
- ✅ TanStack Query for server data fetching
|
|
251
|
-
- ✅ TanStack Store for client-side state management
|
|
252
|
-
- ✅ Tailwind CSS for styling
|
|
253
|
-
- ✅ Headless UI components
|
|
254
|
-
- ✅ Heroicons for beautiful icons
|
|
255
|
-
- ✅ Counter example (TanStack Store)
|
|
256
|
-
- ✅ Fetch /hello example (TanStack Query)
|
|
257
|
-
- ✅ All configuration files
|
|
258
|
-
- ✅ Ready to run with `npm install && npm run dev`
|
|
259
|
-
|
|
260
|
-
### Client Structure (TanStack Router + Query + Store)
|
|
261
|
-
|
|
262
|
-
Following the official TanStack Router conventions:
|
|
263
|
-
|
|
264
|
-
```
|
|
265
|
-
apps/<resource-name>/
|
|
266
|
-
├── package.json
|
|
267
|
-
├── vite.config.ts
|
|
268
|
-
├── tailwind.config.js # Tailwind CSS configuration
|
|
269
|
-
├── postcss.config.js # PostCSS configuration
|
|
270
|
-
├── tsconfig.json
|
|
271
|
-
├── index.html
|
|
272
|
-
└── src/
|
|
273
|
-
├── main.tsx # App entry point
|
|
274
|
-
├── index.css # Tailwind CSS imports
|
|
275
|
-
├── routeTree.gen.ts # Auto-generated by TanStack Router
|
|
276
|
-
├── lib/
|
|
277
|
-
│ ├── query-client.ts # TanStack Query client
|
|
278
|
-
│ └── counter-store.ts # TanStack Store state
|
|
279
|
-
└── routes/
|
|
280
|
-
├── __root.tsx # Root layout with Headless UI navigation
|
|
281
|
-
├── index.tsx # Home with counter & fetch examples
|
|
282
|
-
└── about.tsx # About page
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
**Key Features:**
|
|
108
|
+
Generates a standalone TanStack Router + React app (outside the monorepo structure).
|
|
286
109
|
|
|
287
|
-
|
|
288
|
-
- **Server data fetching**: TanStack Query for caching, background updates, and optimistic UI
|
|
289
|
-
- **Client-side state**: TanStack Store for simple global state management
|
|
290
|
-
- **Modern UI**: Tailwind CSS + Headless UI for accessible, beautiful components
|
|
291
|
-
- **Icons**: Heroicons for scalable SVG icons
|
|
292
|
-
- **Counter example**: Inc/dec/reset demonstrating TanStack Store with Headless UI buttons
|
|
293
|
-
- **Fetch example**: Call /hello endpoint demonstrating TanStack Query
|
|
294
|
-
- **Clean structure**: Minimal setup, easy to understand
|
|
110
|
+
## Environment Variables
|
|
295
111
|
|
|
296
|
-
|
|
112
|
+
Each generated project includes `.env.example`. Variables added per package:
|
|
297
113
|
|
|
298
|
-
|
|
114
|
+
| Package | Variables |
|
|
115
|
+
| ------- | --------- |
|
|
116
|
+
| `db` | `DATABASE_URL` |
|
|
117
|
+
| `db-turso` | `DATABASE_URL`, `DATABASE_AUTH_TOKEN` |
|
|
118
|
+
| `cache` | `REDIS_URL` |
|
|
119
|
+
| `event-driven` | `RABBITMQ_URL` |
|
|
120
|
+
| `auth` | `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL` |
|
|
121
|
+
| `s3` | `S3_ENDPOINT`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_BUCKET` |
|
|
299
122
|
|
|
300
|
-
|
|
301
|
-
- `vite.config.ts` - Vite with TanStack Router plugin
|
|
302
|
-
- `tailwind.config.js` - Tailwind CSS configuration
|
|
303
|
-
- `postcss.config.js` - PostCSS with Tailwind and Autoprefixer
|
|
304
|
-
- `tsconfig.json` - TypeScript configuration
|
|
305
|
-
- `index.html` - Entry HTML
|
|
306
|
-
- `.gitignore` - Git ignore patterns
|
|
307
|
-
|
|
308
|
-
**Application Code:**
|
|
309
|
-
Create a Full Monorepo
|
|
310
|
-
|
|
311
|
-
```bash
|
|
312
|
-
$ honotan generate monorepo
|
|
313
|
-
|
|
314
|
-
? Project name: my-api-platform
|
|
315
|
-
? Package manager: bun
|
|
316
|
-
? Include example API: Yes
|
|
317
|
-
|
|
318
|
-
✅ Monorepo created: my-api-platform/
|
|
319
|
-
├── apps/
|
|
320
|
-
├── packages/
|
|
321
|
-
├── bun-workspace.yaml
|
|
322
|
-
├── package.json
|
|
323
|
-
└── turbo.json
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
### Generate an E-Commerce API (TypeScript + Hono)
|
|
327
|
-
|
|
328
|
-
```bash
|
|
329
|
-
$ honotan generate api
|
|
330
|
-
|
|
331
|
-
? Language: TypeScript
|
|
332
|
-
? Architecture pattern: Hexagonal (Ports & Adapters)
|
|
333
|
-
? API Framework: Hono
|
|
334
|
-
? Resource name: product
|
|
335
|
-
? Select inbound adapters: HTTP, WebSocket
|
|
336
|
-
? Select outbound adapters: Database, Cache, In-Memory Repository
|
|
337
|
-
? Output directory: apps/product-api
|
|
338
|
-
|
|
339
|
-
✅ Generated complete hexagonal API with:
|
|
340
|
-
✓ Domain entities (Product)
|
|
341
|
-
✓ Use case ports (in/out)
|
|
342
|
-
✓ Business logic with tests
|
|
343
|
-
✓ HTTP REST endpoints
|
|
344
|
-
✓ WebSocket handlers
|
|
345
|
-
✓ PostgreSQL repository
|
|
346
|
-
✓ Redis cache layer
|
|
347
|
-
✓ In-memory repository for testing
|
|
348
|
-
✓ Request validation (Valibot)
|
|
349
|
-
✓ Comprehensive test suite
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Generate a Microservice (Go + Chi)
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
$ honotan generate api
|
|
356
|
-
|
|
357
|
-
? Language: Go
|
|
358
|
-
? Architecture pattern: Hexagonal (Ports & Adapters)
|
|
359
|
-
? API Framework: Chi
|
|
360
|
-
? Resource name: order
|
|
361
|
-
? Select inbound adapters: HTTP
|
|
362
|
-
? Select outbound adapters: Database, Cache
|
|
363
|
-
? Output directory: apps/order-service
|
|
364
|
-
|
|
365
|
-
✅ Generated production-ready Go service with:
|
|
366
|
-
✓ Domain entities
|
|
367
|
-
✓ Use case interfaces & implementations
|
|
368
|
-
✓ Chi HTTP handlers with middleware
|
|
369
|
-
✓ PostgreSQL repository
|
|
370
|
-
✓ Redis caching
|
|
371
|
-
✓ go-playground/validator
|
|
372
|
-
✓ Comprehensive tests
|
|
373
|
-
✓ Dockerfile & docker-compose
|
|
374
|
-
✓ Makefile for workflows
|
|
375
|
-
✓ Documentation
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
#### clean
|
|
379
|
-
|
|
380
|
-
Deeply cleans the project by removing build artifacts and dependencies (`node_modules`, `dist`, `.turbo`, etc.) across the monorepo.
|
|
381
|
-
|
|
382
|
-
```bash
|
|
383
|
-
honotan util clean
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
Use this when you need a fresh start or are experiencing dependency/caching issues.
|
|
387
|
-
|
|
388
|
-
## Examples
|
|
389
|
-
|
|
390
|
-
### Generate an API Product Resource (Hexagonal)
|
|
123
|
+
## Local Development
|
|
391
124
|
|
|
392
125
|
```bash
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
? Architecture pattern: Hexagonal (Ports & Adapters)
|
|
397
|
-
? API Framework: Hono
|
|
398
|
-
? Resource name: product
|
|
399
|
-
? Select inbound adapters: HTTP
|
|
400
|
-
? Select outbound adapters: In-Memory Repository, Database
|
|
401
|
-
? Output directory: src
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
This generates a complete product API module with:
|
|
405
|
-
|
|
406
|
-
- Domain entities and ports
|
|
407
|
-
- Use case implementation with tests
|
|
408
|
-
- HTTP routes and controllers
|
|
409
|
-
- In-memory and database repositories
|
|
410
|
-
- Validation schemas
|
|
411
|
-
|
|
412
|
-
## Why Honotan CLI?
|
|
413
|
-
|
|
414
|
-
### vs. Manual Setup
|
|
415
|
-
|
|
416
|
-
| Manual | Honotan CLI |
|
|
417
|
-
|--------|-------------|
|
|
418
|
-
| ⏱️ Hours of boilerplate | ⚡ 2 minutes to production-ready code |
|
|
419
|
-
| 🤷 Inconsistent patterns | 🎯 Best practices built-in |
|
|
420
|
-
| 📚 Read docs for each tool | 🚀 Opinionated, proven setup |
|
|
421
|
-
| 🐛 Common mistakes | ✅ Battle-tested architecture |
|
|
422
|
-
|
|
423
|
-
### vs. Other Generators
|
|
424
|
-
|
|
425
|
-
| Feature | Honotan | Others |
|
|
426
|
-
|---------|---------|--------|
|
|
427
|
-
| Hexagonal Architecture | ✅ Core focus | ❌ Rarely supported |
|
|
428
|
-
| Monorepo-first | ✅ Built-in | ⚠️ Afterthought |
|
|
429
|
-
| Multi-language | ✅ TS, Go, more coming | ❌ Single language |
|
|
430
|
-
| Production-ready | ✅ Tests, Docker, CI/CD | ⚠️ Minimal setup |
|
|
431
|
-
| Swappable adapters | ✅ Ports & adapters | ❌ Tight coupling |
|
|
432
|
-
|
|
433
|
-
### Who Should Use This?
|
|
434
|
-
|
|
435
|
-
**✅ Great fit:**
|
|
436
|
-
|
|
437
|
-
- Teams building multiple microservices
|
|
438
|
-
- Projects requiring long-term maintainability
|
|
439
|
-
- Developers learning clean architecture
|
|
440
|
-
- Companies with polyglot requirements
|
|
441
|
-
- Anyone who values testability
|
|
442
|
-
|
|
443
|
-
**⚠️ Might be overkill for:**
|
|
444
|
-
|
|
445
|
-
- Simple CRUD scripts
|
|
446
|
-
- One-off utilities
|
|
447
|
-
- Projects with < 3 endpoints
|
|
448
|
-
|
|
449
|
-
## Why Monorepos?
|
|
450
|
-
|
|
451
|
-
**Traditional multi-repo challenges:**
|
|
452
|
-
|
|
453
|
-
- ❌ Duplicated boilerplate across services
|
|
454
|
-
- ❌ Version hell with shared dependencies
|
|
455
|
-
- ❌ Difficult to refactor across services
|
|
456
|
-
- ❌ Inconsistent tooling and patterns
|
|
457
|
-
|
|
458
|
-
**Honotan monorepo benefits:**
|
|
459
|
-
|
|
460
|
-
- ✅ **Single source of truth** – One repo for all services
|
|
461
|
-
- ✅ **Shared libraries** – Reuse domain models, utilities, and types
|
|
462
|
-
- ✅ **Atomic changes** – Refactor across multiple services safely
|
|
463
|
-
- ✅ **Consistent tooling** – Same linting, testing, and CI/CD everywhere
|
|
464
|
-
- ✅ **Better discoverability** – See all services and dependencies at once
|
|
465
|
-
- ✅ **Simplified onboarding** – One clone, one install
|
|
466
|
-
|
|
467
|
-
## Why Hexagonal Architecture?
|
|
468
|
-
|
|
469
|
-
**The hexagonal pattern (ports & adapters) ensures:**
|
|
470
|
-
|
|
471
|
-
1. **Domain purity** – Business logic has zero framework dependencies
|
|
472
|
-
2. **Testability** – Test use cases without HTTP servers or databases
|
|
473
|
-
3. **Flexibility** – Swap Redis for Memcached without touching business code
|
|
474
|
-
4. **Framework-agnostic** – Migrate from Hono to Fastify by changing adapters only
|
|
475
|
-
5. **Clear boundaries** – Ports define contracts, adapters implement them
|
|
476
|
-
6. **Long-term maintainability** – Your domain logic outlives any framework
|
|
477
|
-
|
|
478
|
-
**Example**: Change from PostgreSQL to MongoDB? Just replace the adapter. Your domain and use cases remain untouched.
|
|
479
|
-
|
|
480
|
-
## Technologies Used
|
|
481
|
-
|
|
482
|
-
### TypeScript Stack
|
|
483
|
-
|
|
484
|
-
- **Frameworks**: Hono, Express, Fastify
|
|
485
|
-
- **Validation**: Valibot, Zod
|
|
486
|
-
- **Testing**: Vitest, Bun Test
|
|
487
|
-
- **ORM**: Drizzle, Prisma _(coming soon)_
|
|
488
|
-
|
|
489
|
-
### Go Stack
|
|
490
|
-
|
|
491
|
-
- **Framework**: Chi router
|
|
492
|
-
- **Validation**: go-playground/validator
|
|
493
|
-
- **Testing**: testify
|
|
494
|
-
- **Database**: database/sql, GORM _(coming soon)_
|
|
495
|
-
- **Cache**: go-redis
|
|
496
|
-
|
|
497
|
-
### Client Stack
|
|
498
|
-
|
|
499
|
-
- **Router**: TanStack Router
|
|
500
|
-
- **State**: TanStack Query + TanStack Store
|
|
501
|
-
- **UI**: Tailwind CSS + Headless UI
|
|
502
|
-
- **Icons**: Heroicons
|
|
503
|
-
|
|
504
|
-
### Monorepo Tools
|
|
126
|
+
git clone https://github.com/rifkyputra/honotan-cli.git
|
|
127
|
+
cd honotan-cli
|
|
128
|
+
bun install
|
|
505
129
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
- **Versioning**: Changesets _(coming soon)_
|
|
130
|
+
# Run tests (generate projects into .generated/ and assert on output files)
|
|
131
|
+
bun test
|
|
509
132
|
|
|
510
|
-
|
|
133
|
+
# Type check
|
|
134
|
+
bun run check-types
|
|
511
135
|
|
|
512
|
-
|
|
136
|
+
# Build
|
|
137
|
+
bun run build
|
|
513
138
|
|
|
139
|
+
# Link globally for manual testing
|
|
140
|
+
bun link
|
|
514
141
|
```
|
|
515
|
-
┌─────────────────────────────────────────┐
|
|
516
|
-
│ Inbound Adapters │
|
|
517
|
-
│ (HTTP, WebSocket, GraphQL, CLI) │
|
|
518
|
-
└──────────────┬──────────────────────────┘
|
|
519
|
-
│
|
|
520
|
-
┌──────────────▼──────────────────────────┐
|
|
521
|
-
│ Application Layer (Ports) │
|
|
522
|
-
│ ┌─────────────────────────────────┐ │
|
|
523
|
-
│ │ Domain Layer (Entities) │ │
|
|
524
|
-
│ └─────────────────────────────────┘ │
|
|
525
|
-
└──────────────┬──────────────────────────┘
|
|
526
|
-
│
|
|
527
|
-
┌──────────────▼──────────────────────────┐
|
|
528
|
-
│ Outbound Adapters │
|
|
529
|
-
│ (Database, Cache, Message Queue) │
|
|
530
|
-
└─────────────────────────────────────────┘
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
**Layers:**
|
|
534
|
-
|
|
535
|
-
- **Domain** – Pure business entities and rules
|
|
536
|
-
- **Application** – Use cases coordinating domain logic
|
|
537
|
-
- **Adapters** – Infrastructure implementations
|
|
538
|
-
- **Composition** – Wiring dependencies together
|
|
539
|
-
|
|
540
|
-
**What you get:**
|
|
541
|
-
|
|
542
|
-
- Complete React + TypeScript + Vite project
|
|
543
|
-
- TanStack Router for routing
|
|
544
|
-
- TanStack Store for state management
|
|
545
|
-
- Counter and fetch examples
|
|
546
|
-
- Ready to run immediately
|
|
547
|
-
|
|
548
|
-
## Technologies Used
|
|
549
|
-
|
|
550
|
-
- **API Frameworks**: Hono (Express and Fastify coming soon)
|
|
551
|
-
- **Client**: TanStack Router + TanStack Query + TanStack Store (React)
|
|
552
|
-
- **UI**: Tailwind CSS + Headless UI + Heroicons
|
|
553
|
-
- **Validation**: Zod
|
|
554
|
-
- **Testing**: Vitest
|
|
555
|
-
- **TypeScript**: Full type safety
|
|
556
|
-
|
|
557
|
-
## Architecture Patterns
|
|
558
|
-
|
|
559
|
-
### API Pattern
|
|
560
|
-
|
|
561
|
-
#### Hexagonal (Ports & Adapters)
|
|
562
|
-
|
|
563
|
-
Clean separation between domain, application, and infrastructure layers:
|
|
564
|
-
|
|
565
|
-
- **Domain**: Business entities and port interfaces
|
|
566
|
-
- **Application**: Use cases implementing business logic
|
|
567
|
-
- **Adapters**: Framework-specific implementations (routes, repositories)
|
|
568
|
-
|
|
569
|
-
### Client Pattern
|
|
570
|
-
|
|
571
|
-
The client generation follows the **official TanStack Router pattern**:
|
|
572
|
-
|
|
573
|
-
- **File-based routing**: Routes in `src/routes/` map directly to URLs
|
|
574
|
-
- **Simple state**: TanStack Store for global state management
|
|
575
|
-
- **Type safety**: Full TypeScript support throughout
|
|
576
|
-
- **Minimal setup**: Counter and fetch examples to get started quickly
|
|
577
|
-
|
|
578
|
-
## Contributing
|
|
579
|
-
|
|
580
|
-
Contributions are welcome! Please open an issue or submit a pull request.
|
|
581
|
-
|
|
582
|
-
## Use Cases
|
|
583
|
-
|
|
584
|
-
**Perfect for:**
|
|
585
|
-
|
|
586
|
-
- 🏢 **Enterprise microservices** – Build multiple services with shared domain models
|
|
587
|
-
- 🚀 **Startup MVPs** – Start modular, scale without rewrites
|
|
588
|
-
- 📚 **Learning clean architecture** – Production-ready examples in multiple languages
|
|
589
|
-
- 🔄 **Migrating legacy code** – Gradually introduce hexagonal patterns
|
|
590
|
-
- 🎓 **Educational projects** – Teach DDD and clean architecture
|
|
591
|
-
|
|
592
|
-
**Success Stories:**
|
|
593
|
-
|
|
594
|
-
- E-commerce platforms with 10+ microservices in one monorepo
|
|
595
|
-
- SaaS products separating domain logic from infrastructure
|
|
596
|
-
- API-first startups with TypeScript and Go services side-by-side
|
|
597
142
|
|
|
598
143
|
## Roadmap
|
|
599
144
|
|
|
@@ -601,25 +146,12 @@ Contributions are welcome! Please open an issue or submit a pull request.
|
|
|
601
146
|
- [x] Go + Chi hexagonal templates
|
|
602
147
|
- [x] Monorepo structure generation
|
|
603
148
|
- [x] TanStack Router client generation
|
|
604
|
-
- [
|
|
149
|
+
- [x] DB (Postgres), DB-Turso, Cache, Event-Driven, Auth, S3 packages
|
|
150
|
+
- [x] Turborepo integration
|
|
605
151
|
- [ ] GraphQL adapter
|
|
606
|
-
- [ ]
|
|
607
|
-
- [ ] Rust support
|
|
608
|
-
- [ ] Event sourcing patterns
|
|
609
|
-
- [ ] gRPC support
|
|
610
|
-
- [-] Turborepo integration
|
|
152
|
+
- [ ] Kafka support
|
|
611
153
|
- [ ] Express & Fastify support
|
|
612
|
-
- [ ]
|
|
613
|
-
|
|
614
|
-
## Publishing
|
|
615
|
-
|
|
616
|
-
This project uses GitHub Actions to automate publishing to NPM.
|
|
617
|
-
|
|
618
|
-
1. **Update Version**: Bump the version in `package.json` (e.g., `npm version patch`).
|
|
619
|
-
2. **Push Changes**: Push your changes to the `main` branch.
|
|
620
|
-
3. **Automated Publish**: The GitHub Action will run tests and publish the new version to NPM automatically.
|
|
621
|
-
|
|
622
|
-
**Note**: You must add your `NPM_TOKEN` to the repository secrets for this to work.
|
|
154
|
+
- [ ] Rust support
|
|
623
155
|
|
|
624
156
|
## License
|
|
625
157
|
|