@etus/bhono-app 0.1.6 → 0.1.7

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 (61) hide show
  1. package/package.json +3 -2
  2. package/templates/base/.claude/commands/check-skill-rules.md +112 -29
  3. package/templates/base/.claude/commands/linear/implement-issue.md +383 -55
  4. package/templates/base/.claude/commands/ship.md +77 -13
  5. package/templates/base/.claude/hooks/package-lock.json +0 -419
  6. package/templates/base/.claude/hooks/skill-activation-prompt.ts +185 -113
  7. package/templates/base/.claude/hooks/skill-tool-guard.sh +6 -0
  8. package/templates/base/.claude/hooks/skill-tool-guard.ts +198 -0
  9. package/templates/base/.claude/scripts/validate-skill-rules.sh +55 -32
  10. package/templates/base/.claude/settings.json +18 -11
  11. package/templates/base/.claude/skills/skill-rules.json +326 -173
  12. package/templates/base/.env.example +3 -0
  13. package/templates/base/README.md +9 -7
  14. package/templates/base/config/eslint.config.js +1 -0
  15. package/templates/base/config/wrangler.json +16 -17
  16. package/templates/base/docs/SETUP-GUIDE.md +566 -0
  17. package/templates/base/docs/architecture/README.md +162 -8
  18. package/templates/base/docs/architecture/api-catalog.md +575 -0
  19. package/templates/base/docs/architecture/c4-component.md +309 -0
  20. package/templates/base/docs/architecture/c4-container.md +183 -0
  21. package/templates/base/docs/architecture/c4-context.md +106 -0
  22. package/templates/base/docs/architecture/dependencies.md +327 -0
  23. package/templates/base/docs/architecture/tech-debt.md +184 -0
  24. package/templates/base/package.json +20 -15
  25. package/templates/base/scripts/capture-prod-session.ts +2 -2
  26. package/templates/base/scripts/sync-template.sh +104 -0
  27. package/templates/base/src/server/db/sql.ts +24 -4
  28. package/templates/base/src/server/index.ts +1 -0
  29. package/templates/base/src/server/lib/audited-db.ts +10 -10
  30. package/templates/base/src/server/middleware/account.ts +1 -1
  31. package/templates/base/src/server/middleware/auth.ts +11 -11
  32. package/templates/base/src/server/middleware/rate-limit.ts +3 -6
  33. package/templates/base/src/server/routes/auth/handlers.ts +5 -5
  34. package/templates/base/src/server/routes/auth/test-login.ts +9 -9
  35. package/templates/base/src/server/routes/index.ts +9 -0
  36. package/templates/base/src/server/routes/invitations/handlers.ts +6 -6
  37. package/templates/base/src/server/routes/openapi.ts +1 -1
  38. package/templates/base/src/server/services/accounts.ts +9 -9
  39. package/templates/base/src/server/services/audits.ts +12 -12
  40. package/templates/base/src/server/services/auth.ts +15 -15
  41. package/templates/base/src/server/services/invitations.ts +16 -16
  42. package/templates/base/src/server/services/users.ts +13 -13
  43. package/templates/base/src/shared/types/api.ts +66 -198
  44. package/templates/base/tests/e2e/auth.setup.ts +1 -1
  45. package/templates/base/tests/unit/server/auth/guards.test.ts +1 -1
  46. package/templates/base/tests/unit/server/middleware/auth.test.ts +273 -0
  47. package/templates/base/tests/unit/server/routes/auth/handlers.test.ts +111 -0
  48. package/templates/base/tests/unit/server/routes/users/handlers.test.ts +69 -5
  49. package/templates/base/tests/unit/server/services/accounts.test.ts +148 -0
  50. package/templates/base/tests/unit/server/services/audits.test.ts +219 -0
  51. package/templates/base/tests/unit/server/services/auth.test.ts +480 -3
  52. package/templates/base/tests/unit/server/services/invitations.test.ts +178 -0
  53. package/templates/base/tests/unit/server/services/users.test.ts +363 -8
  54. package/templates/base/tests/unit/shared/schemas.test.ts +1 -1
  55. package/templates/base/vite.config.ts +3 -1
  56. package/templates/base/.github/workflows/test.yml +0 -127
  57. package/templates/base/.husky/pre-push +0 -26
  58. package/templates/base/auth-setup-error.png +0 -0
  59. package/templates/base/pnpm-lock.yaml +0 -8052
  60. package/templates/base/tests/e2e/_auth/.gitkeep +0 -0
  61. package/templates/base/tsconfig.tsbuildinfo +0 -1
@@ -1,11 +1,165 @@
1
- # Architecture Docs
1
+ # Architecture Documentation - BHono
2
2
 
3
- Contexto canonico: `docs/app_spec.txt`
3
+ > Production-ready multi-tenant SaaS boilerplate with Hono.js backend and React frontend, deployed on Cloudflare Workers.
4
4
 
5
- Indice rapido dos documentos de arquitetura.
5
+ ## Executive Summary
6
6
 
7
- - `docs/architecture/erd.md` - ERD e dicionario de dados.
8
- - `docs/architecture/data-requirements.md` - Data Requirements Document (DRD).
9
- - `docs/architecture/db-bootstrap.md` - Bootstrap do schema.sql e seed.
10
- - `docs/architecture/drizzle-migration-plan.md` - Mapeamento do Drizzle e plano de migracao para SQL puro.
11
- - `docs/architecture/sql-standards.md` - Padrao de SQL puro e mapeamento de resultados.
7
+ | Attribute | Value | Confidence |
8
+ |-----------|-------|------------|
9
+ | **Architecture Type** | Full-Stack Monolith (Single Deploy) | HIGH |
10
+ | **Deployment** | Cloudflare Workers (Edge Computing) | HIGH |
11
+ | **Backend** | Hono.js 4.x with OpenAPI | HIGH |
12
+ | **Frontend** | React 19 + TanStack Router | HIGH |
13
+ | **Database** | Cloudflare D1 (SQLite at Edge) | HIGH |
14
+ | **Sessions** | Cloudflare KV | HIGH |
15
+ | **Storage** | Cloudflare R2 | HIGH |
16
+ | **Auth** | Google OAuth 2.0 + Session Cookies | HIGH |
17
+ | **Multi-tenancy** | Account-based with RBAC | HIGH |
18
+
19
+ ### Key Characteristics
20
+
21
+ - **Edge-first**: Entire stack runs at Cloudflare's edge, ~50ms latency globally
22
+ - **Multi-tenant**: Users belong to multiple Accounts with role-based permissions
23
+ - **Type-safe**: Full TypeScript with Zod validation on both client and server
24
+ - **API-first**: OpenAPI 3.0 spec with Swagger UI
25
+ - **Test coverage**: 94%+ server, 90%+ client, 363+ E2E tests
26
+
27
+ ## Architecture Indicators Detected
28
+
29
+ | Indicator | Found | Location |
30
+ |-----------|-------|----------|
31
+ | Single Dockerfile | N/A | Serverless deployment |
32
+ | `wrangler.json` | YES | `config/wrangler.json` |
33
+ | D1 Database | YES | `config/wrangler.json:d1_databases` |
34
+ | KV Sessions | YES | `config/wrangler.json:kv_namespaces` |
35
+ | R2 Storage | YES | `config/wrangler.json:r2_buckets` |
36
+ | React SPA | YES | `src/client/*` |
37
+ | TanStack Router | YES | `src/client/routes/*` |
38
+ | Hono.js Backend | YES | `src/server/*` |
39
+ | OpenAPI/Swagger | YES | `src/server/routes/openapi.ts` |
40
+ | Multi-tenancy | YES | `src/server/auth/guards.ts` |
41
+
42
+ ## Document Index
43
+
44
+ | Document | Description | Status |
45
+ |----------|-------------|--------|
46
+ | [c4-context.md](./c4-context.md) | C4 Level 1 - System Context | Complete |
47
+ | [c4-container.md](./c4-container.md) | C4 Level 2 - Containers | Complete |
48
+ | [c4-component.md](./c4-component.md) | C4 Level 3 - Components | Complete |
49
+ | [erd.md](./erd.md) | Entity Relationship Diagram | Complete |
50
+ | [api-catalog.md](./api-catalog.md) | REST API Endpoints | Complete |
51
+ | [dependencies.md](./dependencies.md) | Module Dependency Map | Complete |
52
+ | [tech-debt.md](./tech-debt.md) | Technical Debt Register | Complete |
53
+ | [data-requirements.md](./data-requirements.md) | Data Requirements Document | Legacy |
54
+ | [db-bootstrap.md](./db-bootstrap.md) | Database Bootstrap Guide | Legacy |
55
+ | [sql-standards.md](./sql-standards.md) | SQL Standards Guide | Legacy |
56
+
57
+ ## Technology Stack
58
+
59
+ ### Runtime & Infrastructure
60
+
61
+ | Component | Technology | Version | Confidence |
62
+ |-----------|------------|---------|------------|
63
+ | Runtime | Cloudflare Workers | - | HIGH |
64
+ | Database | Cloudflare D1 (SQLite) | - | HIGH |
65
+ | Session Store | Cloudflare KV | - | HIGH |
66
+ | File Storage | Cloudflare R2 | - | HIGH |
67
+ | CDN/Edge | Cloudflare | - | HIGH |
68
+
69
+ ### Backend
70
+
71
+ | Component | Technology | Version | Confidence |
72
+ |-----------|------------|---------|------------|
73
+ | Framework | Hono.js | 4.11.x | HIGH |
74
+ | API Docs | @hono/zod-openapi | 1.2.x | HIGH |
75
+ | Swagger UI | @hono/swagger-ui | 0.5.x | HIGH |
76
+ | Validation | Zod | 4.3.x | HIGH |
77
+ | UUID | uuidv7 | 1.1.x | HIGH |
78
+
79
+ ### Frontend
80
+
81
+ | Component | Technology | Version | Confidence |
82
+ |-----------|------------|---------|------------|
83
+ | UI Library | React | 19.2.x | HIGH |
84
+ | Routing | TanStack Router | 1.144.x | HIGH |
85
+ | Data Fetching | TanStack Query | 5.90.x | HIGH |
86
+ | Forms | React Hook Form | 7.70.x | HIGH |
87
+ | Styling | Tailwind CSS | 4.1.x | HIGH |
88
+ | UI Components | Radix UI | 1.x | HIGH |
89
+ | Icons | Lucide React | 0.562.x | HIGH |
90
+ | Toasts | Sonner | 2.0.x | HIGH |
91
+
92
+ ### Testing
93
+
94
+ | Component | Technology | Version | Confidence |
95
+ |-----------|------------|---------|------------|
96
+ | Unit/Integration | Vitest | 4.0.x | HIGH |
97
+ | E2E | Playwright | 1.57.x | HIGH |
98
+ | Coverage | V8/Istanbul | - | HIGH |
99
+ | Browser Testing | Vitest Browser | 4.0.x | HIGH |
100
+
101
+ ### DevOps
102
+
103
+ | Component | Technology | Version | Confidence |
104
+ |-----------|------------|---------|------------|
105
+ | Bundler | Vite | 7.3.x | HIGH |
106
+ | Wrangler | Wrangler | 4.54.x | HIGH |
107
+ | Linting | ESLint | 9.x | HIGH |
108
+ | Commit Lint | Commitlint | 20.x | HIGH |
109
+ | Changesets | @changesets/cli | 2.29.x | HIGH |
110
+ | Git Hooks | Husky | 9.x | HIGH |
111
+
112
+ ## Security Assessment
113
+
114
+ | Area | Implementation | Confidence |
115
+ |------|----------------|------------|
116
+ | **Authentication** | Google OAuth 2.0 + Session Cookies | HIGH |
117
+ | **Authorization** | RBAC (7 roles) with Guards | HIGH |
118
+ | **Session Management** | KV-backed, httpOnly cookies | HIGH |
119
+ | **Token Security** | SHA-256 hashed refresh tokens | HIGH |
120
+ | **CSRF Protection** | SameSite=Strict cookies | HIGH |
121
+ | **Rate Limiting** | In-memory with lazy cleanup | HIGH |
122
+ | **Audit Logging** | All state changes logged | HIGH |
123
+ | **Soft Delete** | Users/Accounts retain data | HIGH |
124
+
125
+ ## Project Structure Overview
126
+
127
+ ```
128
+ ├── config/ # Configuration files
129
+ │ └── wrangler.json # Cloudflare Workers config
130
+ ├── src/
131
+ │ ├── server/ # Hono.js Backend
132
+ │ │ ├── routes/ # API endpoints (OpenAPI)
133
+ │ │ ├── services/ # Business logic
134
+ │ │ ├── middleware/ # Request middleware
135
+ │ │ ├── auth/ # RBAC system
136
+ │ │ ├── db/ # D1 database layer
137
+ │ │ └── lib/ # Utilities
138
+ │ ├── client/ # React Frontend
139
+ │ │ ├── routes/ # TanStack file-based routing
140
+ │ │ ├── components/ # UI components
141
+ │ │ └── hooks/ # React hooks
142
+ │ └── shared/ # Shared code
143
+ │ ├── schemas/ # Zod validation
144
+ │ └── types/ # TypeScript types
145
+ ├── tests/ # Centralized tests
146
+ │ ├── unit/ # Unit tests
147
+ │ ├── integration/ # Integration tests
148
+ │ └── e2e/ # Playwright E2E
149
+ └── packages/ # Monorepo packages
150
+ └── bhono-app/ # CLI scaffolding tool
151
+ ```
152
+
153
+ ## Quick Links
154
+
155
+ - **OpenAPI Spec**: `/api/doc`
156
+ - **Swagger UI**: `/api/swagger`
157
+ - **Health Check**: `/health`
158
+ - **Readiness Probe**: `/health/ready`
159
+ - **Liveness Probe**: `/health/live`
160
+
161
+ ## Related Documentation
162
+
163
+ - `docs/app_spec.txt` - Canonical application specification
164
+ - `docs/testing.md` - Testing strategy and guidelines
165
+ - `CLAUDE.md` - AI assistant context file