@buenojs/bueno 0.8.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 (120) hide show
  1. package/.env.example +109 -0
  2. package/.github/workflows/ci.yml +31 -0
  3. package/LICENSE +21 -0
  4. package/README.md +892 -0
  5. package/architecture.md +652 -0
  6. package/bun.lock +70 -0
  7. package/dist/cli/index.js +3233 -0
  8. package/dist/index.js +9014 -0
  9. package/package.json +77 -0
  10. package/src/cache/index.ts +795 -0
  11. package/src/cli/ARCHITECTURE.md +837 -0
  12. package/src/cli/bin.ts +10 -0
  13. package/src/cli/commands/build.ts +425 -0
  14. package/src/cli/commands/dev.ts +248 -0
  15. package/src/cli/commands/generate.ts +541 -0
  16. package/src/cli/commands/help.ts +55 -0
  17. package/src/cli/commands/index.ts +112 -0
  18. package/src/cli/commands/migration.ts +355 -0
  19. package/src/cli/commands/new.ts +804 -0
  20. package/src/cli/commands/start.ts +208 -0
  21. package/src/cli/core/args.ts +283 -0
  22. package/src/cli/core/console.ts +349 -0
  23. package/src/cli/core/index.ts +60 -0
  24. package/src/cli/core/prompt.ts +424 -0
  25. package/src/cli/core/spinner.ts +265 -0
  26. package/src/cli/index.ts +135 -0
  27. package/src/cli/templates/deploy.ts +295 -0
  28. package/src/cli/templates/docker.ts +307 -0
  29. package/src/cli/templates/index.ts +24 -0
  30. package/src/cli/utils/fs.ts +428 -0
  31. package/src/cli/utils/index.ts +8 -0
  32. package/src/cli/utils/strings.ts +197 -0
  33. package/src/config/env.ts +408 -0
  34. package/src/config/index.ts +506 -0
  35. package/src/config/loader.ts +329 -0
  36. package/src/config/merge.ts +285 -0
  37. package/src/config/types.ts +320 -0
  38. package/src/config/validation.ts +441 -0
  39. package/src/container/forward-ref.ts +143 -0
  40. package/src/container/index.ts +386 -0
  41. package/src/context/index.ts +360 -0
  42. package/src/database/index.ts +1142 -0
  43. package/src/database/migrations/index.ts +371 -0
  44. package/src/database/schema/index.ts +619 -0
  45. package/src/frontend/api-routes.ts +640 -0
  46. package/src/frontend/bundler.ts +643 -0
  47. package/src/frontend/console-client.ts +419 -0
  48. package/src/frontend/console-stream.ts +587 -0
  49. package/src/frontend/dev-server.ts +846 -0
  50. package/src/frontend/file-router.ts +611 -0
  51. package/src/frontend/frameworks/index.ts +106 -0
  52. package/src/frontend/frameworks/react.ts +85 -0
  53. package/src/frontend/frameworks/solid.ts +104 -0
  54. package/src/frontend/frameworks/svelte.ts +110 -0
  55. package/src/frontend/frameworks/vue.ts +92 -0
  56. package/src/frontend/hmr-client.ts +663 -0
  57. package/src/frontend/hmr.ts +728 -0
  58. package/src/frontend/index.ts +342 -0
  59. package/src/frontend/islands.ts +552 -0
  60. package/src/frontend/isr.ts +555 -0
  61. package/src/frontend/layout.ts +475 -0
  62. package/src/frontend/ssr/react.ts +446 -0
  63. package/src/frontend/ssr/solid.ts +523 -0
  64. package/src/frontend/ssr/svelte.ts +546 -0
  65. package/src/frontend/ssr/vue.ts +504 -0
  66. package/src/frontend/ssr.ts +699 -0
  67. package/src/frontend/types.ts +2274 -0
  68. package/src/health/index.ts +604 -0
  69. package/src/index.ts +410 -0
  70. package/src/lock/index.ts +587 -0
  71. package/src/logger/index.ts +444 -0
  72. package/src/logger/transports/index.ts +969 -0
  73. package/src/metrics/index.ts +494 -0
  74. package/src/middleware/built-in.ts +360 -0
  75. package/src/middleware/index.ts +94 -0
  76. package/src/modules/filters.ts +458 -0
  77. package/src/modules/guards.ts +405 -0
  78. package/src/modules/index.ts +1256 -0
  79. package/src/modules/interceptors.ts +574 -0
  80. package/src/modules/lazy.ts +418 -0
  81. package/src/modules/lifecycle.ts +478 -0
  82. package/src/modules/metadata.ts +90 -0
  83. package/src/modules/pipes.ts +626 -0
  84. package/src/router/index.ts +339 -0
  85. package/src/router/linear.ts +371 -0
  86. package/src/router/regex.ts +292 -0
  87. package/src/router/tree.ts +562 -0
  88. package/src/rpc/index.ts +1263 -0
  89. package/src/security/index.ts +436 -0
  90. package/src/ssg/index.ts +631 -0
  91. package/src/storage/index.ts +456 -0
  92. package/src/telemetry/index.ts +1097 -0
  93. package/src/testing/index.ts +1586 -0
  94. package/src/types/index.ts +236 -0
  95. package/src/types/optional-deps.d.ts +219 -0
  96. package/src/validation/index.ts +276 -0
  97. package/src/websocket/index.ts +1004 -0
  98. package/tests/integration/cli.test.ts +1016 -0
  99. package/tests/integration/fullstack.test.ts +234 -0
  100. package/tests/unit/cache.test.ts +174 -0
  101. package/tests/unit/cli-commands.test.ts +892 -0
  102. package/tests/unit/cli.test.ts +1258 -0
  103. package/tests/unit/container.test.ts +279 -0
  104. package/tests/unit/context.test.ts +221 -0
  105. package/tests/unit/database.test.ts +183 -0
  106. package/tests/unit/linear-router.test.ts +280 -0
  107. package/tests/unit/lock.test.ts +336 -0
  108. package/tests/unit/middleware.test.ts +184 -0
  109. package/tests/unit/modules.test.ts +142 -0
  110. package/tests/unit/pubsub.test.ts +257 -0
  111. package/tests/unit/regex-router.test.ts +265 -0
  112. package/tests/unit/router.test.ts +373 -0
  113. package/tests/unit/rpc.test.ts +1248 -0
  114. package/tests/unit/security.test.ts +174 -0
  115. package/tests/unit/telemetry.test.ts +371 -0
  116. package/tests/unit/test-cache.test.ts +110 -0
  117. package/tests/unit/test-database.test.ts +282 -0
  118. package/tests/unit/tree-router.test.ts +325 -0
  119. package/tests/unit/validation.test.ts +794 -0
  120. package/tsconfig.json +27 -0
@@ -0,0 +1,652 @@
1
+ # Bueno Framework Architecture
2
+
3
+ **A Bun-Native Full-Stack Framework**
4
+
5
+ ---
6
+
7
+ ## Executive Summary
8
+
9
+ Bueno is a high-performance, full-stack web framework built exclusively for Bun v1.3+. Unlike cross-runtime frameworks, Bueno deeply integrates with Bun's native APIs (`bun:sql`, `Bun.serve()`, `Bun.redis`, `Bun.s3`) to provide maximum performance and developer experience. It combines the best ideas from Hono (routing, RPC, middleware), Nest (modularity, dependency injection), and Next.js (full-stack integration, file routing) while staying true to Bun's philosophy of "batteries included."
10
+
11
+ **Design Principles:**
12
+ - **Bun-Exclusive:** No multi-runtime support. Embrace Bun's unique features without compromise.
13
+ - **Zero Configuration:** TypeScript, JSX, databases, and frontend bundling work out of the box.
14
+ - **Performance First:** Direct use of Bun's native APIs without abstraction overhead.
15
+ - **Progressive Enhancement:** Start simple, add complexity only when needed.
16
+ - **Type-Safe Everything:** Full type inference from routes to database queries to RPC clients.
17
+
18
+ ---
19
+
20
+ ## 1. Core Architecture Layers
21
+
22
+ ### Layer 1: Foundation (Bun Runtime Integration)
23
+
24
+ **Purpose:** Direct integration with Bun v1.3's built-in capabilities
25
+
26
+ **Components:**
27
+
28
+ #### 1.1 HTTP Server Engine
29
+ - Wraps `Bun.serve()` with enhanced routing capabilities
30
+ - Native support for HTTP/2, WebSocket, and Server-Sent Events
31
+ - Built-in compression and request deduplication
32
+ - Connection pooling and keep-alive management
33
+ - Zero-copy file serving using `Bun.file()`
34
+
35
+ #### 1.2 Database Layer (`BuenoDB`)
36
+ - Unified interface over `bun:sql` (PostgreSQL, MySQL, SQLite)
37
+ - Automatic driver detection from connection string
38
+ - Connection pooling with configurable limits
39
+ - Query pipelining for batch operations
40
+ - Transaction support with nested transactions
41
+ - Type generation from database schema
42
+ - Migration system with rollback support
43
+
44
+ #### 1.3 Caching Layer (`BuenoCache`)
45
+ - Built on `Bun.redis` native client
46
+ - Key-value storage with TTL support
47
+ - Pub/sub for distributed events
48
+ - Cache-aside and write-through patterns
49
+ - Distributed locking primitives
50
+ - Session storage backend
51
+
52
+ #### 1.4 Storage Layer (`BuenoStorage`)
53
+ - S3-compatible storage using `Bun.s3`
54
+ - Presigned URL generation
55
+ - Streaming uploads/downloads
56
+ - Multi-part upload support
57
+ - Local filesystem fallback for development
58
+
59
+ #### 1.5 Security Primitives
60
+ - Password hashing using `Bun.password` (argon2, bcrypt)
61
+ - CSRF token generation via `Bun.CSRF`
62
+ - Secret management with `Bun.secrets` (OS keychain integration)
63
+ - JWT signing and verification
64
+ - Rate limiting with token bucket algorithm
65
+
66
+ ---
67
+
68
+ ### Layer 2: Router & Request Processing
69
+
70
+ **Purpose:** Ultra-fast request routing with type-safe context
71
+
72
+ **Components:**
73
+
74
+ #### 2.1 Smart Router System
75
+ - **RegExpRouter:** Compiled regex patterns for maximum speed
76
+ - **TreeRouter:** Radix tree for deeply nested routes
77
+ - **LinearRouter:** Simple array matching for <10 routes
78
+ - **Auto-selection:** Automatically choose optimal router based on route count/complexity
79
+
80
+ #### 2.2 Route Definition API
81
+ ```
82
+ HTTP Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
83
+ Path Patterns: /users/:id, /files/*, /api/:version/users/:id
84
+ Route Groups: app.route('/api', apiRoutes)
85
+ Nested Routes: Support for modular route composition
86
+ ```
87
+
88
+ #### 2.3 Context System (`BuenoContext`)
89
+ - Request wrapper with helper methods
90
+ - Response builder with chaining
91
+ - Variable storage (type-safe `c.set()` / `c.get()`)
92
+ - Validator integration
93
+ - Database/cache/storage access
94
+ - User/session management
95
+
96
+ #### 2.4 Middleware Pipeline
97
+ - Async middleware with `await next()`
98
+ - Context mutation with type inference
99
+ - Early termination support
100
+ - Error boundary handling
101
+ - Built-in middleware:
102
+ - CORS
103
+ - Logger
104
+ - Auth (JWT, Session, API Key)
105
+ - Rate Limiter
106
+ - Request ID
107
+ - Compression
108
+ - Security Headers
109
+ - CSRF Protection
110
+
111
+ ---
112
+
113
+ ### Layer 3: Type Safety & Validation
114
+
115
+ **Purpose:** End-to-end type safety from request to response
116
+
117
+ **Components:**
118
+
119
+ #### 3.1 Schema Validation System
120
+ - **Multi-validator support:** Zod, Valibot, ArkType, Typia, TypeBox
121
+ - **Standard Schema API:** Common interface for all validators
122
+ - **Validation targets:** JSON body, Query params, Route params, Headers, Form data, Cookies
123
+ - **Custom validators:** Framework-agnostic validation interface
124
+
125
+ #### 3.2 Type Inference Engine
126
+ - Automatic type extraction from validators
127
+ - Union types for multiple status codes
128
+ - Optional/required field inference
129
+ - Generic constraints for type safety
130
+
131
+ #### 3.3 Database Type System
132
+ - Generate TypeScript types from SQL schema
133
+ - Infer result types from queries
134
+ - Type-safe query builders (optional)
135
+ - Prepared statement typing
136
+
137
+ ---
138
+
139
+ ### Layer 4: RPC System (Type-Safe API Client)
140
+
141
+ **Purpose:** Automatically generate fully-typed API clients
142
+
143
+ **Components:**
144
+
145
+ #### 4.1 Type Export System
146
+ - Export route types: `export type AppType = typeof app`
147
+ - Namespace isolation for multiple API versions
148
+ - Monorepo support with workspace types
149
+
150
+ #### 4.2 Client Generator
151
+ - `bc<AppType>()` creates typed client (bueno-client)
152
+ - Method inference: `client.api.users.$get()`
153
+ - Parameter typing from validators
154
+ - Response typing from handlers
155
+ - Status code branching
156
+
157
+ #### 4.3 Runtime Features
158
+ - Automatic request serialization
159
+ - Response deserialization
160
+ - Error handling with typed errors
161
+ - Request/response interceptors
162
+ - Retry logic with exponential backoff
163
+
164
+ #### 4.4 Advanced Features
165
+ - **Context Extraction:** `tryGetContext()` helper
166
+ - **URL Type Safety:** Generic base URL parameter
167
+ - **Request Deduplication:** Automatic caching of identical requests
168
+ - **Optimistic Updates:** Client-side state management integration
169
+
170
+ ---
171
+
172
+ ### Layer 5: Frontend Integration
173
+
174
+ **Purpose:** Seamless full-stack development experience
175
+
176
+ **Components:**
177
+
178
+ #### 5.1 Development Server
179
+ - Serve `.html` files with `Bun.serve()`
180
+ - Automatic bundling of React/Vue/Svelte/Solid
181
+ - TypeScript/JSX transpilation (zero config)
182
+ - CSS imports and bundling
183
+ - Asset handling (images, fonts, etc.)
184
+ - Hot Module Replacement (HMR)
185
+ - Browser console streaming to terminal
186
+
187
+ #### 5.2 Production Bundler
188
+ - Code splitting by route
189
+ - Tree shaking and dead code elimination
190
+ - Minification and compression
191
+ - Source map generation
192
+ - CSS extraction and optimization
193
+ - Asset optimization (image compression, etc.)
194
+
195
+ #### 5.3 Rendering Strategies
196
+ - **SPA (Single Page Application):** Client-side rendering only
197
+ - **SSR (Server-Side Rendering):** Render on request
198
+ - **SSG (Static Site Generation):** Pre-render at build time
199
+ - **ISR (Incremental Static Regeneration):** Hybrid SSG + SSR
200
+ - **Island Architecture:** Partial hydration for performance
201
+
202
+ #### 5.4 File-Based Routing (Optional)
203
+ - Next.js-style routing: `pages/api/users/[id].ts`
204
+ - Layout nesting: `_layout.tsx` for shared layouts
205
+ - API routes: Automatic endpoint generation
206
+ - Middleware: `_middleware.ts` for route-level middleware
207
+ - Dynamic imports: Code splitting by route
208
+
209
+ ---
210
+
211
+ ### Layer 6: Module System (Nest-Inspired)
212
+
213
+ **Purpose:** Large application organization with modularity and DI
214
+
215
+ **Components:**
216
+
217
+ #### 6.1 Module Definition
218
+ - `@Module()` decorator for module metadata
219
+ - Import/export system for module composition
220
+ - Provider registration (services, repositories)
221
+ - Controller registration (route handlers)
222
+ - Global modules for shared services
223
+
224
+ #### 6.2 Dependency Injection
225
+ - Constructor injection
226
+ - Property injection
227
+ - Interface-based injection with tokens
228
+ - Scope management (singleton, request, transient)
229
+ - Circular dependency resolution
230
+ - Lazy loading support
231
+
232
+ #### 6.3 Provider System
233
+ - **Services:** Business logic layer
234
+ - **Repositories:** Database access layer
235
+ - **Guards:** Authorization checks
236
+ - **Interceptors:** Response transformation
237
+ - **Pipes:** Data transformation and validation
238
+ - **Filters:** Exception handling
239
+
240
+ #### 6.4 Lifecycle Hooks
241
+ - `onModuleInit()`: Module initialization
242
+ - `onApplicationBootstrap()`: App startup
243
+ - `onModuleDestroy()`: Module cleanup
244
+ - `beforeApplicationShutdown()`: Graceful shutdown
245
+ - Request lifecycle hooks
246
+
247
+ ---
248
+
249
+ ### Layer 7: Testing & Observability
250
+
251
+ **Purpose:** Built-in testing and production monitoring
252
+
253
+ **Components:**
254
+
255
+ #### 7.1 Testing Framework
256
+ - Integration with `bun:test`
257
+ - Test context helpers
258
+ - Mock database/cache/storage
259
+ - Request/response testing utilities
260
+ - Snapshot testing for API responses
261
+ - Test fixtures and factories
262
+ - Coverage reporting
263
+
264
+ #### 7.2 Logging System
265
+ - Structured logging with JSON output
266
+ - Log levels (debug, info, warn, error)
267
+ - Context-aware logging (request ID, user ID)
268
+ - Performance metrics logging
269
+ - Integration with external log aggregators
270
+
271
+ #### 7.3 Metrics & Tracing
272
+ - Request duration tracking
273
+ - Database query performance
274
+ - Cache hit/miss ratios
275
+ - Memory and CPU usage
276
+ - Distributed tracing support (OpenTelemetry)
277
+ - Health check endpoints
278
+
279
+ ---
280
+
281
+ ## 2. Application Structure
282
+
283
+ ### Standard Project Layout
284
+
285
+ ```
286
+ my-bueno-app/
287
+ ├── server/
288
+ │ ├── main.ts # Application entry point
289
+ │ ├── app.module.ts # Root module
290
+ │ │
291
+ │ ├── modules/ # Feature modules
292
+ │ │ ├── users/
293
+ │ │ │ ├── users.module.ts
294
+ │ │ │ ├── users.controller.ts
295
+ │ │ │ ├── users.service.ts
296
+ │ │ │ ├── users.repository.ts
297
+ │ │ │ └── dto/
298
+ │ │ │ ├── create-user.dto.ts
299
+ │ │ │ └── update-user.dto.ts
300
+ │ │ │
301
+ │ │ ├── posts/
302
+ │ │ │ └── ... (similar structure)
303
+ │ │ │
304
+ │ │ └── auth/
305
+ │ │ ├── auth.module.ts
306
+ │ │ ├── auth.controller.ts
307
+ │ │ ├── auth.service.ts
308
+ │ │ ├── guards/
309
+ │ │ │ └── jwt.guard.ts
310
+ │ │ └── strategies/
311
+ │ │ └── jwt.strategy.ts
312
+ │ │
313
+ │ ├── common/ # Shared utilities
314
+ │ │ ├── middleware/
315
+ │ │ ├── decorators/
316
+ │ │ ├── filters/
317
+ │ │ └── interceptors/
318
+ │ │
319
+ │ ├── config/ # Configuration
320
+ │ │ ├── database.config.ts
321
+ │ │ ├── cache.config.ts
322
+ │ │ └── app.config.ts
323
+ │ │
324
+ │ ├── database/ # Database assets
325
+ │ │ ├── migrations/
326
+ │ │ ├── seeds/
327
+ │ │ └── schema.ts
328
+ │ │
329
+ │ └── types/ # Type definitions
330
+ │ └── app.types.ts
331
+ │
332
+ ├── client/ # Frontend application
333
+ │ ├── index.html
334
+ │ ├── src/
335
+ │ │ ├── main.tsx
336
+ │ │ ├── api/
337
+ │ │ │ └── client.ts # RPC client
338
+ │ │ ├── components/
339
+ │ │ ├── pages/
340
+ │ │ └── styles/
341
+ │ └── public/
342
+ │
343
+ ├── shared/ # Shared between client/server
344
+ │ └── types/
345
+ │
346
+ ├── tests/ # E2E and integration tests
347
+ │ ├── integration/
348
+ │ └── e2e/
349
+ │
350
+ ├── bueno.config.ts # Framework configuration
351
+ └── package.json
352
+ ```
353
+
354
+ ---
355
+
356
+ ## 3. Feature Matrix
357
+
358
+ ### Core Features (MVP)
359
+
360
+ | Category | Features |
361
+ |----------|----------|
362
+ | **HTTP** | GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS |
363
+ | **Routing** | Path params, Query params, Wildcards, RegExp patterns, Route groups |
364
+ | **Request** | JSON, Form data, File uploads, Streaming, Headers, Cookies |
365
+ | **Response** | JSON, HTML, Text, Stream, File, Redirect, Status codes |
366
+ | **Validation** | Zod, Valibot, ArkType, Typia, Custom validators |
367
+ | **Database** | PostgreSQL, MySQL, SQLite via `bun:sql` |
368
+ | **Caching** | Redis via `Bun.redis` |
369
+ | **Storage** | S3-compatible via `Bun.s3` |
370
+ | **Auth** | JWT, Sessions, API Keys, OAuth helpers |
371
+ | **Security** | CORS, CSRF, Rate limiting, Secure headers, Password hashing |
372
+ | **WebSocket** | Connection upgrade, Pub/sub, Per-connection data |
373
+ | **Middleware** | Async pipeline, Context mutation, Error boundaries |
374
+ | **Testing** | `bun:test` integration, Mocking, Fixtures |
375
+
376
+ ### Advanced Features (Post-MVP)
377
+
378
+ | Category | Features |
379
+ |----------|----------|
380
+ | **Modules** | Dependency injection, Module system, Providers |
381
+ | **Frontend** | Dev server, HMR, Bundling, SSR/SSG/ISR |
382
+ | **RPC** | Type-safe client generation, Status code branching |
383
+ | **CLI** | Project scaffolding, Code generation, Migrations |
384
+ | **Observability** | Structured logging, Metrics, Tracing |
385
+ | **Deployment** | Single-file executables, Docker images, Cloud platforms |
386
+ | **GraphQL** | Optional GraphQL server integration |
387
+ | **Queues** | Background job processing with Redis |
388
+
389
+ ---
390
+
391
+ ## 4. Configuration System
392
+
393
+ ### bueno.config.ts
394
+
395
+ ```typescript
396
+ export default {
397
+ // Server configuration
398
+ server: {
399
+ port: 3000,
400
+ hostname: 'localhost',
401
+ development: {
402
+ hmr: true,
403
+ console: true,
404
+ },
405
+ },
406
+
407
+ // Database configuration
408
+ database: {
409
+ url: process.env.DATABASE_URL,
410
+ pool: { min: 2, max: 10 },
411
+ migrations: './database/migrations',
412
+ seeds: './database/seeds',
413
+ },
414
+
415
+ // Cache configuration
416
+ cache: {
417
+ url: process.env.REDIS_URL,
418
+ ttl: 3600,
419
+ keyPrefix: 'bueno:',
420
+ },
421
+
422
+ // Storage configuration
423
+ storage: {
424
+ driver: 's3',
425
+ bucket: process.env.S3_BUCKET,
426
+ region: process.env.S3_REGION,
427
+ },
428
+
429
+ // Auth configuration
430
+ auth: {
431
+ jwt: {
432
+ secret: process.env.JWT_SECRET,
433
+ expiresIn: '7d',
434
+ },
435
+ session: {
436
+ secret: process.env.SESSION_SECRET,
437
+ maxAge: 86400,
438
+ },
439
+ },
440
+
441
+ // Frontend configuration
442
+ frontend: {
443
+ entry: './client/index.html',
444
+ outDir: './dist/public',
445
+ ssr: true,
446
+ ssg: ['/', '/about'],
447
+ },
448
+
449
+ // Module configuration
450
+ modules: {
451
+ autoImport: true,
452
+ lazyLoad: false,
453
+ },
454
+ }
455
+ ```
456
+
457
+ ---
458
+
459
+ ## 5. Key Design Decisions
460
+
461
+ ### 5.1 Bun-Exclusive (No Multi-Runtime)
462
+ **Decision:** Build exclusively for Bun v1.3+, no Node.js or Deno support.
463
+
464
+ **Rationale:**
465
+ - Unlock maximum performance by using Bun's native APIs directly
466
+ - Avoid abstraction layers that slow down development and runtime
467
+ - Smaller bundle size (no runtime detection code)
468
+ - Simpler codebase and documentation
469
+
470
+ **Trade-offs:**
471
+ - Cannot run on other runtimes
472
+ - Smaller ecosystem initially
473
+ - Requires Bun installation
474
+
475
+ ### 5.2 Zero Configuration Philosophy
476
+ **Decision:** Sensible defaults for everything, configuration only when needed.
477
+
478
+ **Rationale:**
479
+ - TypeScript/JSX work out of the box (Bun transpiles natively)
480
+ - Database connections auto-detect driver from URL scheme
481
+ - Hot reload enabled in development automatically
482
+ - Frontend bundling requires zero config
483
+ - Production builds optimized by default
484
+
485
+ **Trade-offs:**
486
+ - Less flexibility for edge cases
487
+ - May need escape hatches for advanced users
488
+
489
+ ### 5.3 Type-Safety First
490
+ **Decision:** Full type inference from routes to RPC clients to database queries.
491
+
492
+ **Rationale:**
493
+ - Catch errors at compile time, not runtime
494
+ - Better autocomplete and IntelliSense
495
+ - Self-documenting APIs
496
+ - Easier refactoring
497
+
498
+ **Trade-offs:**
499
+ - More complex type system
500
+ - Steeper learning curve for TypeScript beginners
501
+ - Slower TypeScript compilation in large projects
502
+
503
+ ### 5.4 Progressive Complexity
504
+ **Decision:** Simple apps stay simple, complex apps get powerful features.
505
+
506
+ **Rationale:**
507
+ - Start with basic HTTP server in 10 lines of code
508
+ - Add database when needed (one line of config)
509
+ - Enable modules/DI only for large applications
510
+ - Frontend is optional
511
+
512
+ **Trade-offs:**
513
+ - Need to document multiple "levels" of framework usage
514
+ - Users might not discover advanced features
515
+
516
+ ### 5.5 Batteries Included
517
+ **Decision:** Core features built-in (database, cache, storage, auth, testing).
518
+
519
+ **Rationale:**
520
+ - Faster development (no hunting for packages)
521
+ - Better performance (native implementations)
522
+ - Consistent APIs across features
523
+ - Easier upgrades (no dependency hell)
524
+
525
+ **Trade-offs:**
526
+ - Larger framework size
527
+ - Less flexibility in choosing implementations
528
+ - Framework must maintain more code
529
+
530
+ ---
531
+
532
+ ## 6. Performance Targets
533
+
534
+ | Metric | Target | Measurement |
535
+ |--------|--------|-------------|
536
+ | **Cold Start** | <50ms | Time from `bun run` to first request handled |
537
+ | **Request Throughput** | >100k req/s | Simple "Hello World" endpoint |
538
+ | **Database Query** | <5ms p99 | Single row SELECT with connection pool |
539
+ | **RPC Client Overhead** | <1ms | Client wrapper vs direct fetch |
540
+ | **Hot Reload** | <100ms | Time from file save to server reload |
541
+ | **Memory Usage** | <50MB | Idle server with all features enabled |
542
+ | **Bundle Size** | <2MB | Framework code without dependencies |
543
+
544
+ ---
545
+
546
+ ## 7. Roadmap
547
+
548
+ ### Phase 1: Core (v0.1-0.3)
549
+ - HTTP server with routing
550
+ - Middleware system
551
+ - Context API
552
+ - Database integration (`bun:sql`)
553
+ - Validation (Zod integration)
554
+ - Basic testing utilities
555
+
556
+ ### Phase 2: Full-Stack (v0.4-0.6)
557
+ - Frontend dev server
558
+ - Hot Module Replacement
559
+ - RPC client generation
560
+ - Cache layer (Redis)
561
+ - Storage layer (S3)
562
+ - Auth middleware (JWT, Sessions)
563
+
564
+ ### Phase 3: Enterprise (v0.7-0.9)
565
+ - Module system with DI
566
+ - File-based routing
567
+ - SSR/SSG support
568
+ - CLI for scaffolding
569
+ - Production bundler
570
+ - Observability (logging, metrics)
571
+
572
+ ### Phase 4: v1.0
573
+ - Full documentation
574
+ - Migration guides
575
+ - Performance benchmarks
576
+ - Production-ready stability
577
+ - Plugin system
578
+ - Ecosystem integrations
579
+
580
+ ---
581
+
582
+ ## 8. Success Metrics
583
+
584
+ **Adoption:**
585
+ - 10k+ GitHub stars in first year
586
+ - 100+ community plugins
587
+ - Used by 1k+ production applications
588
+
589
+ **Performance:**
590
+ - Top 3 in TechEmpower benchmarks for Bun category
591
+ - Faster than Express/Fastify on Bun
592
+ - Comparable to raw `Bun.serve()` performance
593
+
594
+ **Developer Experience:**
595
+ - <5 minutes from install to production deploy
596
+ - <10 lines of code for basic CRUD API
597
+ - 90%+ TypeScript type coverage
598
+ - <100ms hot reload times
599
+
600
+ ---
601
+
602
+ ## 9. Ecosystem & Extensions
603
+
604
+ ### Official Packages
605
+ - `@bueno/cli` - Project scaffolding and code generation
606
+ - `@bueno/devtools` - Browser extension for debugging
607
+ - `@bueno/graphql` - GraphQL server integration
608
+ - `@bueno/queues` - Background job processing
609
+ - `@bueno/admin` - Auto-generated admin panel
610
+ - `@bueno/docs` - API documentation generator
611
+
612
+ ### Community Extensions
613
+ - Database ORMs (Drizzle, Prisma adapters)
614
+ - Authentication providers (Auth0, Clerk, etc.)
615
+ - Payment integrations (Stripe, PayPal)
616
+ - Email services (SendGrid, Resend)
617
+ - Monitoring (Sentry, DataDog)
618
+
619
+ ---
620
+
621
+ ## 10. Migration & Compatibility
622
+
623
+ ### From Hono
624
+ - Similar routing API (easy mental model)
625
+ - Middleware pattern compatible
626
+ - RPC concepts transferable
627
+ - Validation system similar
628
+
629
+ ### From Express
630
+ - Middleware pattern similar
631
+ - Route handler signatures compatible
632
+ - Request/response helpers familiar
633
+
634
+ ### From Nest
635
+ - Module system nearly identical
636
+ - Dependency injection compatible
637
+ - Decorator-based approach similar
638
+ - Provider pattern transferable
639
+
640
+ ### From Next.js
641
+ - File-based routing optional
642
+ - SSR/SSG concepts similar
643
+ - API routes pattern compatible
644
+ - Full-stack integration familiar
645
+
646
+ ---
647
+
648
+ ## Conclusion
649
+
650
+ Bueno is designed to be the fastest, most developer-friendly full-stack framework for Bun. By embracing Bun's native capabilities and avoiding multi-runtime abstractions, Bueno achieves performance that rivals raw `Bun.serve()` while providing the structure and features needed for production applications.
651
+
652
+ The architecture balances simplicity for small projects with power for enterprise applications, using progressive enhancement to ensure developers only pay for what they use. With built-in database, caching, storage, and authentication, Bueno provides everything needed to build and deploy modern web applications—all in one cohesive package.