chadstart 1.0.5 → 1.0.6

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/TODO.md ADDED
@@ -0,0 +1,739 @@
1
+ # ChadStart TODO — Feature Review, BaaS Comparison & Roadmap
2
+
3
+ > **Purpose**: This document serves as a comprehensive task list for improving ChadStart across multiple AI sessions. Each section is self-contained with enough context for an AI agent to pick up and execute independently.
4
+
5
+ ---
6
+
7
+ ## Project Decisions
8
+
9
+ > These decisions were made by the project owner and should guide all implementation work.
10
+
11
+ | Decision | Answer | Impact |
12
+ |----------|--------|--------|
13
+ | **Target audience** | Solo developers and small teams | Prioritize simplicity and PocketBase-level DX over enterprise features |
14
+ | **SMTP/Email priority** | Yes, build first | Phase 1 confirmed: SMTP → Email verification → Password reset |
15
+ | **Admin UI approach** | Continue single-file SPA | Keep `admin/index.html` as HTMX + Alpine.js; do NOT migrate to React/Vue/Svelte |
16
+ | **Managed cloud hosting** | Future possibility | Keep multi-tenancy in mind but don't prioritize; P3-4 stays low priority |
17
+ | **Implementation order** | Agrees with recommended phases | Follow Phase 1→5 as documented |
18
+ | **Additional SDK languages** | Not a priority | Deprioritize P2-5; JS SDK is sufficient for now |
19
+
20
+ ---
21
+
22
+ ## Table of Contents
23
+
24
+ 1. [Feature Comparison Matrix](#1-feature-comparison-matrix)
25
+ 2. [Gap Analysis](#2-gap-analysis--missing-features)
26
+ 3. [Priority Tasks](#3-priority-tasks)
27
+ - [P0 — Critical / Core Parity](#p0--critical--core-parity)
28
+ - [P1 — High Value Features](#p1--high-value-features)
29
+ - [P2 — Developer Experience](#p2--developer-experience)
30
+ - [P3 — Nice to Have](#p3--nice-to-have)
31
+ 4. [Documentation Tasks](#4-documentation-tasks)
32
+ 5. [Testing Tasks](#5-testing-tasks)
33
+ 6. [AI Session Guide](#6-ai-session-guide)
34
+
35
+ ---
36
+
37
+ ## 1. Feature Comparison Matrix
38
+
39
+ ### Legend
40
+ - ✅ Fully supported
41
+ - 🟡 Partially supported / limited
42
+ - ❌ Not supported
43
+ - 🔧 Planned / in progress
44
+
45
+ | Feature | ChadStart | PocketBase | Supabase | Appwrite | Firebase |
46
+ |---|---|---|---|---|---|
47
+ | **DATA & SCHEMA** | | | | | |
48
+ | Declarative schema (YAML/JSON) | ✅ YAML-first | ✅ Admin UI + API | ✅ SQL migrations | ✅ Admin UI | ❌ schemaless |
49
+ | Auto REST API generation | ✅ | ✅ | ✅ (PostgREST) | ✅ | ❌ (SDK only) |
50
+ | Collections (multi-record) | ✅ | ✅ | ✅ | ✅ | ✅ |
51
+ | Singles (single-record) | ✅ | ❌ | ❌ | ❌ | ❌ |
52
+ | Relations (belongsTo) | ✅ | ✅ | ✅ (FK) | ✅ | ❌ |
53
+ | Relations (belongsToMany) | ✅ | ✅ | ✅ (junction) | ✅ | ❌ |
54
+ | Nested/embedded objects (groups) | ✅ | ✅ (JSON) | ✅ (JSONB) | ❌ | ✅ |
55
+ | Schema validation | ✅ (JSON Schema) | ✅ | ✅ (pg constraints) | ✅ | 🟡 (rules) |
56
+ | Computed/virtual fields | ❌ | ❌ | ✅ (pg views) | ❌ | ❌ |
57
+ | Full-text search | ❌ | ❌ | ✅ (pg tsvector) | ✅ | ✅ (Algolia) |
58
+ | Database views | ❌ | ❌ | ✅ | ❌ | ❌ |
59
+ | **DATABASES** | | | | | |
60
+ | SQLite | ✅ | ✅ (embedded) | ❌ | ❌ | ❌ |
61
+ | PostgreSQL | ✅ | ❌ | ✅ (primary) | ❌ (MariaDB) | ❌ |
62
+ | MySQL | ✅ | ❌ | ❌ | ✅ (MariaDB) | ❌ |
63
+ | Single binary / embedded DB | 🟡 (Node + SQLite) | ✅ (Go binary) | ❌ (Docker stack) | ❌ (Docker) | ❌ (cloud) |
64
+ | **AUTHENTICATION** | | | | | |
65
+ | Email + password | ✅ | ✅ | ✅ | ✅ | ✅ |
66
+ | OAuth / social login | ✅ (200+ via Grant) | ✅ (~12 built-in) | ✅ (~20+) | ✅ (~30+) | ✅ (~15) |
67
+ | API keys | ✅ | ❌ | ✅ (service keys) | ✅ | ✅ |
68
+ | JWT tokens | ✅ | ✅ | ✅ | ✅ | ✅ (custom) |
69
+ | Magic link / passwordless | ❌ | ❌ | ✅ | ✅ | ✅ |
70
+ | Phone / SMS auth | ❌ | ❌ | ✅ | ✅ | ✅ |
71
+ | Multi-factor auth (MFA/2FA) | ❌ | ✅ (OTP) | ✅ | ✅ | ✅ |
72
+ | Anonymous auth | ❌ | ❌ | ✅ | ✅ | ✅ |
73
+ | Email verification | ❌ | ✅ | ✅ | ✅ | ✅ |
74
+ | Password reset flow | ❌ | ✅ | ✅ | ✅ | ✅ |
75
+ | Custom auth providers | 🟡 (via Grant) | ✅ | ✅ | ✅ | ✅ |
76
+ | Session management | 🟡 (JWT only) | ✅ | ✅ | ✅ | ✅ |
77
+ | **ACCESS CONTROL** | | | | | |
78
+ | Role-based (public/restricted/admin) | ✅ | ✅ (API rules) | ✅ (RLS) | ✅ (roles) | ✅ (rules) |
79
+ | Row-level security | 🟡 (self condition) | ✅ (filter rules) | ✅ (Postgres RLS) | ✅ | ✅ (rules) |
80
+ | Per-operation policies | ✅ (CRUD) | ✅ | ✅ | ✅ | ✅ |
81
+ | Custom policy expressions | ❌ | ✅ (JS-like) | ✅ (SQL) | 🟡 | ✅ |
82
+ | Field-level permissions | ❌ | ❌ | 🟡 | ❌ | ✅ |
83
+ | **REALTIME** | | | | | |
84
+ | WebSocket subscriptions | ✅ | ✅ (SSE) | ✅ (Postgres changes) | ✅ | ✅ |
85
+ | Entity CRUD events | ✅ | ✅ | ✅ | ✅ | ✅ |
86
+ | Channel filtering | 🟡 (entity-level) | ✅ (record-level) | ✅ (table/row) | ✅ (channels) | ✅ (path) |
87
+ | Presence / online status | ❌ | ❌ | ✅ (Presence) | ❌ | ✅ |
88
+ | **FILE STORAGE** | | | | | |
89
+ | Local file storage | ✅ | ✅ | ❌ | ✅ | ❌ |
90
+ | S3-compatible storage | ✅ | ✅ | ✅ (primary) | ❌ | ✅ (GCS) |
91
+ | Image auto-resize | ✅ (Sharp) | ✅ (thumbs) | ✅ (transforms) | ✅ | ✅ (Extensions) |
92
+ | File size limits | 🟡 | ✅ | ✅ | ✅ | ✅ |
93
+ | MIME type validation | 🟡 | ✅ | ✅ | ✅ | ✅ |
94
+ | CDN integration | ❌ | ❌ | ✅ | ❌ | ✅ |
95
+ | **FUNCTIONS / SERVERLESS** | | | | | |
96
+ | Custom HTTP endpoints | ✅ | 🟡 (Go hooks) | ✅ (Edge Functions) | ✅ | ✅ |
97
+ | Multiple runtimes (JS/Python/Go/etc) | ✅ (7 runtimes) | ❌ (Go only) | 🟡 (Deno/TS) | ✅ (14 runtimes) | ✅ (Node/Python) |
98
+ | Cron / scheduled jobs | ✅ | ✅ (Go hooks) | ✅ (pg_cron) | ✅ | ✅ |
99
+ | Event-driven triggers | ✅ | ✅ (hooks) | ✅ (webhooks) | ✅ | ✅ |
100
+ | Lifecycle hooks (before/after CRUD) | ✅ | ✅ (Go hooks) | ✅ (triggers) | ✅ | ❌ |
101
+ | Webhook notifications | ✅ | ❌ | ✅ | ✅ | ❌ |
102
+ | **ADMIN UI** | | | | | |
103
+ | Built-in admin dashboard | ✅ | ✅ | ✅ | ✅ | ✅ |
104
+ | CRUD data management | ✅ | ✅ | ✅ (Table Editor) | ✅ | ✅ |
105
+ | Schema editor in UI | ❌ (YAML only) | ✅ | ✅ | ✅ | ❌ |
106
+ | User management UI | 🟡 | ✅ | ✅ | ✅ | ✅ |
107
+ | Logs / monitoring in UI | ❌ | ✅ | ✅ | ✅ | ✅ |
108
+ | Custom admin actions | ❌ | ❌ | ❌ | ❌ | ❌ |
109
+ | **API & DX** | | | | | |
110
+ | OpenAPI / Swagger docs | ✅ (auto-gen) | ❌ | ✅ | ✅ | ❌ |
111
+ | TypeScript type generation | ✅ (types.ts) | ✅ | ✅ | ✅ | ✅ |
112
+ | Official SDK (JavaScript) | ✅ | ✅ (JS/Dart) | ✅ (JS/Python/etc) | ✅ (many) | ✅ (many) |
113
+ | GraphQL API | ❌ | ❌ | ✅ (pg_graphql) | ✅ | ❌ |
114
+ | Filtering / pagination | ✅ | ✅ | ✅ | ✅ | ✅ |
115
+ | Sorting | ✅ | ✅ | ✅ | ✅ | ✅ |
116
+ | Batch operations | ❌ | ❌ | ✅ | ❌ | ✅ |
117
+ | **MIGRATIONS** | | | | | |
118
+ | Auto schema sync (dev) | ✅ | ✅ | ❌ | ✅ | ✅ |
119
+ | Git-based migration generation | ✅ | ❌ | ❌ | ❌ | ❌ |
120
+ | SQL migration files | ✅ (Postgrator) | ❌ | ✅ (Flyway-like) | ❌ | ❌ |
121
+ | Rollback support | ✅ (undo files) | ✅ (auto backup) | ✅ | ❌ | ❌ |
122
+ | **OBSERVABILITY** | | | | | |
123
+ | OpenTelemetry support | ✅ | ❌ | ❌ | ❌ | ❌ |
124
+ | Sentry error reporting | ✅ | ❌ | ❌ | ❌ | ❌ |
125
+ | Request logging | 🟡 | ✅ | ✅ | ✅ | ✅ |
126
+ | Metrics / dashboards | ❌ | ❌ | ✅ | ✅ | ✅ |
127
+ | **DEPLOYMENT** | | | | | |
128
+ | Docker support | ✅ | ✅ | ✅ | ✅ | ❌ (cloud) |
129
+ | Self-hosted | ✅ | ✅ | ✅ | ✅ | ❌ |
130
+ | Cloud-hosted (managed) | ❌ | ✅ (PocketHost) | ✅ | ✅ (Cloud) | ✅ |
131
+ | Single binary deployment | ❌ (Node.js) | ✅ (Go) | ❌ | ❌ | ❌ |
132
+ | Edge deployment | ❌ | ❌ | ✅ | ❌ | ✅ |
133
+ | **EXTRAS** | | | | | |
134
+ | Email sending (SMTP/transactional) | ❌ | ✅ | ❌ (3rd party) | ✅ | ❌ |
135
+ | Push notifications | ❌ | ❌ | ❌ | ✅ | ✅ |
136
+ | Geolocation queries | ❌ | ❌ | ✅ (PostGIS) | ❌ | ✅ |
137
+ | Plugin system | ✅ | ❌ | ✅ (Extensions) | ❌ | ✅ |
138
+ | Rate limiting | ✅ | ❌ | ❌ | ✅ | ❌ |
139
+ | Data seeding | ✅ | ❌ | ❌ | ❌ | ❌ |
140
+ | Hot-reload development | ✅ | ❌ | ❌ | ❌ | ✅ (emulator) |
141
+ | Config formats (YAML/JSON/JS) | ✅ (5 formats) | ❌ | ❌ | ❌ | ❌ |
142
+
143
+ ---
144
+
145
+ ## 2. Gap Analysis — Missing Features
146
+
147
+ ### 🔴 Critical Gaps (vs PocketBase)
148
+
149
+ These are features PocketBase has that ChadStart lacks, which users would notice immediately:
150
+
151
+ | # | Gap | PocketBase Behavior | Impact |
152
+ |---|-----|---------------------|--------|
153
+ | G1 | **Email verification flow** | Built-in verify email on signup | High — production apps need this |
154
+ | G2 | **Password reset flow** | Built-in forgot/reset password | High — essential for any user-facing app |
155
+ | G3 | **Admin logs viewer** | View API request logs in admin | Medium — debugging is harder |
156
+ | G4 | **Schema editor in Admin UI** | Create/edit collections in UI | Medium — currently YAML-only |
157
+ | G5 | **Record-level realtime filters** | Subscribe to specific records | Medium — currently entity-level only |
158
+ | G6 | **MFA / OTP support** | TOTP-based 2FA | Medium — security requirement |
159
+ | G7 | **Backup & restore** | One-click backup/restore | Medium — data safety |
160
+ | G8 | **File validation (size/MIME)** | Configurable per field | Low-Medium — basic validation exists |
161
+
162
+ ### 🟡 Valuable Gaps (vs Supabase / Appwrite)
163
+
164
+ Features from the broader BaaS ecosystem worth considering:
165
+
166
+ | # | Gap | Available In | Impact |
167
+ |---|-----|-------------|--------|
168
+ | G9 | **Magic link / passwordless auth** | Supabase, Appwrite, Firebase | Medium |
169
+ | G10 | **Phone/SMS authentication** | Supabase, Appwrite, Firebase | Medium |
170
+ | G11 | **Anonymous auth** | Supabase, Appwrite, Firebase | Low |
171
+ | G12 | **GraphQL API** | Supabase, Appwrite | Medium |
172
+ | G13 | **Full-text search** | Supabase (pg), Appwrite, Firebase | High |
173
+ | G14 | **Batch/bulk operations** | Supabase, Firebase | Medium |
174
+ | G15 | **Field-level permissions** | Firebase | Low |
175
+ | G16 | **Custom policy expressions** | PocketBase, Supabase | Medium |
176
+ | G17 | **Email sending (SMTP)** | PocketBase, Appwrite | High |
177
+ | G18 | **Push notifications** | Appwrite, Firebase | Low |
178
+ | G19 | **CDN / edge caching** | Supabase, Firebase | Low |
179
+ | G20 | **Managed cloud hosting** | All competitors | High (business) |
180
+ | G21 | **Presence / online status** | Supabase, Firebase | Low |
181
+
182
+ ### 🟢 ChadStart Unique Advantages
183
+
184
+ Features where ChadStart **leads** the market:
185
+
186
+ | # | Advantage | Details |
187
+ |---|-----------|---------|
188
+ | A1 | **YAML-first declarative config** | Single file defines entire backend — unmatched DX |
189
+ | A2 | **Singles (single-record entities)** | No other BaaS has this natively |
190
+ | A3 | **7 function runtimes** | JS, Python, Go, C++, Ruby, PHP, Bash — most in any BaaS |
191
+ | A4 | **Git-based migration generation** | Auto-diff YAML → SQL — unique workflow |
192
+ | A5 | **5 config formats** | YAML, JSON, JSON5, Jsonnet, JS — unmatched flexibility |
193
+ | A6 | **OpenTelemetry native** | Production-grade observability built-in |
194
+ | A7 | **200+ OAuth providers** | Via Grant — largest provider list |
195
+ | A8 | **Data seeding** | Built-in dummy data generation |
196
+ | A9 | **Hot-reload dev server** | Instant feedback loop |
197
+ | A10 | **Plugin system** | Extensible via npm/GitHub plugins |
198
+ | A11 | **3 database engines** | SQLite + PostgreSQL + MySQL from same config |
199
+ | A12 | **Property groups** | Reusable nested field sets — unique feature |
200
+ | A13 | **Sentry integration** | Built-in error reporting |
201
+
202
+ ---
203
+
204
+ ## 3. Priority Tasks
205
+
206
+ ### P0 — Critical / Core Parity
207
+
208
+ These tasks bring ChadStart to feature parity with PocketBase for production use.
209
+
210
+ ---
211
+
212
+ #### TASK P0-1: Email Verification Flow ✅
213
+ - **Gap**: G1
214
+ - **Status**: ✅ **Complete**
215
+ - **Context**: PocketBase and all major BaaS solutions include email verification on signup. Currently ChadStart has no way to verify user emails.
216
+ - **Requirements**:
217
+ - [x] Add `emailVerified` (boolean) and `emailVerificationToken` (string) columns to authenticable entities
218
+ - [x] Generate verification token on signup
219
+ - [x] Add `POST /api/auth/:slug/request-verification` endpoint
220
+ - [x] Add `POST /api/auth/:slug/confirm-verification` endpoint (accepts token)
221
+ - [x] SMTP configuration already done in P0-5
222
+ - [x] Send verification email with configurable template
223
+ - [x] Add `requireEmailVerification: true` option on authenticable entities
224
+ - [ ] Update Admin UI to show verification status (deferred — API-only for now)
225
+ - [x] Update OpenAPI spec
226
+ - [x] Add tests (40 tests in test/verification.test.js)
227
+ - **Files modified**: `core/auth.js`, `core/db.js`, `core/entity-engine.js`, `core/openapi.js`, `chadstart.schema.json`, `test/verification.test.js`
228
+
229
+ ---
230
+
231
+ #### TASK P0-2: Password Reset Flow ✅
232
+ - **Gap**: G2
233
+ - **Status**: ✅ **Complete**
234
+ - **Context**: Essential for any user-facing application. PocketBase has built-in forgot/reset password.
235
+ - **Requirements**:
236
+ - [x] Add `passwordResetToken` and `passwordResetExpiry` columns
237
+ - [x] Add `POST /api/auth/:slug/request-password-reset` endpoint
238
+ - [x] Add `POST /api/auth/:slug/confirm-password-reset` endpoint
239
+ - [x] Generate secure time-limited token (1h expiry)
240
+ - [x] Send password reset email with configurable template
241
+ - [x] Anti-enumeration: always return 200 on password reset request
242
+ - [x] Update OpenAPI spec
243
+ - [x] Add tests (in test/verification.test.js)
244
+ - **Files modified**: `core/auth.js`, `core/db.js`, `core/openapi.js`, `test/verification.test.js`
245
+
246
+ ---
247
+
248
+ #### TASK P0-3: Admin Logs Viewer ✅
249
+ - **Gap**: G3
250
+ - **Status**: ✅ **Complete**
251
+ - **Context**: PocketBase shows API request logs in the admin UI. Currently ChadStart has no request logging UI.
252
+ - **Requirements**:
253
+ - [x] Add request logging middleware (method, path, status, duration, IP, user)
254
+ - [x] Store logs in `_cs_logs` table (with auto-cleanup for old entries)
255
+ - [x] Add `GET /admin/logs` API endpoint (paginated, filterable)
256
+ - [ ] Add Logs page in Admin UI with table view (deferred — API-only for now)
257
+ - [x] Add filters: by status code, method, path, date range
258
+ - [x] Add log retention configuration in YAML
259
+ - [x] Add tests (24 tests in test/logs.test.js)
260
+ - **Files modified**: New `core/logs.js`, `server/express-server.js`, `core/entity-engine.js`, `chadstart.schema.json`, `test/logs.test.js`
261
+
262
+ ---
263
+
264
+ #### TASK P0-4: Backup & Restore ✅
265
+ - **Gap**: G7
266
+ - **Status**: ✅ **Complete**
267
+ - **Context**: PocketBase has one-click backup/restore. Critical for data safety.
268
+ - **Requirements**:
269
+ - [x] Add `POST /admin/backup` endpoint (creates database dump)
270
+ - [x] Add `POST /admin/restore` endpoint (restores from dump)
271
+ - [x] Add `GET /admin/backups` endpoint (list available backups)
272
+ - [x] Support SQLite (file copy), PostgreSQL (`pg_dump`), MySQL (`mysqldump`)
273
+ - [x] Add backup directory configuration
274
+ - [ ] Add auto-backup on migration (deferred)
275
+ - [ ] Add scheduled backup option (cron) (deferred)
276
+ - [ ] Add Admin UI backup management page (deferred — API-only for now)
277
+ - [x] Add CLI commands: `npx chadstart backup`, `npx chadstart restore`
278
+ - [x] Add tests (14 tests in test/backup.test.js)
279
+ - **Files modified**: New `core/backup.js`, `server/express-server.js`, `cli/cli.js`, `core/entity-engine.js`, `chadstart.schema.json`, `test/backup.test.js`
280
+
281
+ ---
282
+
283
+ #### TASK P0-5: Email Sending (SMTP) ✅
284
+ - **Gap**: G17
285
+ - **Status**: ✅ **Complete**
286
+ - **Context**: Required by P0-1 and P0-2. PocketBase has built-in SMTP. Needed for verification, password reset, and user notifications.
287
+ - **Requirements**:
288
+ - [x] Add `email` section to YAML schema (host, port, username, from, secure, templates)
289
+ - [x] Implement email service in `core/email.js` using nodemailer
290
+ - [x] Support environment variables for credentials (`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `SMTP_FROM`)
291
+ - [x] Add configurable email templates (verification, password reset)
292
+ - [x] Add `POST /admin/test-email` endpoint to test SMTP config
293
+ - [x] Add `GET /admin/email/status` endpoint to check SMTP status
294
+ - [x] Add template variable interpolation (`{{name}}`, `{{link}}`, `{{appName}}`)
295
+ - [x] Update schema validation
296
+ - [x] Add tests (36 tests covering config, templates, schema, buildCore)
297
+ - **Files modified**: New `core/email.js`, `chadstart.schema.json`, `server/express-server.js`, `core/entity-engine.js`, `chadstart.example.yaml`, `test/email.test.js`
298
+ - **Dependency added**: `nodemailer@^8.0.4`
299
+
300
+ ---
301
+
302
+ ### P1 — High Value Features
303
+
304
+ These significantly improve ChadStart's value proposition.
305
+
306
+ ---
307
+
308
+ #### TASK P1-1: Full-Text Search
309
+ - **Gap**: G13
310
+ - **Context**: Supabase uses PostgreSQL tsvector, Appwrite has built-in search. Currently ChadStart only supports `_like` filter suffix.
311
+ - **Requirements**:
312
+ - [ ] Add `searchable: true` option on string/text properties
313
+ - [ ] SQLite: Use FTS5 virtual tables
314
+ - [ ] PostgreSQL: Use `tsvector` + `GIN` indexes
315
+ - [ ] MySQL: Use `FULLTEXT` indexes
316
+ - [ ] Add `?search=query` query parameter to collection list endpoints
317
+ - [ ] Add search ranking/relevance ordering
318
+ - [ ] Update OpenAPI spec
319
+ - [ ] Add tests for all 3 DB engines
320
+ - **Files to modify**: `core/entity-engine.js`, `core/db.js`, `server/express-server.js`, `chadstart.schema.json`
321
+ - **Estimated effort**: Large (2-3 sessions)
322
+
323
+ ---
324
+
325
+ #### TASK P1-2: MFA / Two-Factor Authentication
326
+ - **Gap**: G6
327
+ - **Context**: PocketBase supports TOTP-based OTP. Increasingly required for security compliance.
328
+ - **Requirements**:
329
+ - [ ] Add `mfa` option on authenticable entities
330
+ - [ ] Implement TOTP generation and verification (RFC 6238)
331
+ - [ ] Add `POST /api/auth/:slug/mfa/setup` — returns QR code / secret
332
+ - [ ] Add `POST /api/auth/:slug/mfa/verify` — verify TOTP code
333
+ - [ ] Add `POST /api/auth/:slug/mfa/disable` — disable MFA
334
+ - [ ] Modify login flow to require TOTP when enabled
335
+ - [ ] Add recovery codes generation
336
+ - [ ] Update Admin UI to show MFA status
337
+ - [ ] Add tests
338
+ - **Files to modify**: `core/auth.js`, `server/express-server.js`, `chadstart.schema.json`
339
+ - **Estimated effort**: Large (2-3 sessions)
340
+ - **New dependency**: `otpauth` or `speakeasy`
341
+
342
+ ---
343
+
344
+ #### TASK P1-3: Record-Level Realtime Subscriptions
345
+ - **Gap**: G5
346
+ - **Context**: PocketBase allows subscribing to specific record changes. Currently ChadStart only supports entity-level subscriptions.
347
+ - **Requirements**:
348
+ - [ ] Support subscription to specific record: `{ "type": "subscribe", "channel": "Post/abc123" }`
349
+ - [ ] Support filter-based subscriptions: `{ "type": "subscribe", "channel": "Post", "filter": { "status": "published" } }`
350
+ - [ ] Apply access policies to realtime events (don't send events for records user can't read)
351
+ - [ ] Add subscription acknowledgment messages
352
+ - [ ] Update realtime documentation
353
+ - [ ] Add tests
354
+ - **Files to modify**: `core/realtime.js`, docs
355
+ - **Estimated effort**: Medium (1-2 sessions)
356
+
357
+ ---
358
+
359
+ #### TASK P1-4: Batch / Bulk Operations
360
+ - **Gap**: G14
361
+ - **Context**: Supabase and Firebase support batch inserts/updates/deletes. Useful for data import and bulk actions.
362
+ - **Requirements**:
363
+ - [ ] Add `POST /api/collections/:slug/batch` endpoint (create multiple records)
364
+ - [ ] Add `PATCH /api/collections/:slug/batch` endpoint (update multiple records)
365
+ - [ ] Add `DELETE /api/collections/:slug/batch` endpoint (delete by IDs)
366
+ - [ ] Wrap batch ops in database transactions
367
+ - [ ] Respect access policies on batch operations
368
+ - [ ] Add batch size limit configuration
369
+ - [ ] Fire realtime events for each record in batch
370
+ - [ ] Update OpenAPI spec and SDK
371
+ - [ ] Add tests
372
+ - **Files to modify**: `server/express-server.js`, `core/entity-engine.js`, `chadstart.schema.json`
373
+ - **Estimated effort**: Medium (1-2 sessions)
374
+
375
+ ---
376
+
377
+ #### TASK P1-5: Custom Policy Expressions
378
+ - **Gap**: G16
379
+ - **Context**: PocketBase allows JS-like expressions in access rules (e.g., `@request.auth.role = "editor"`). Supabase uses SQL policies.
380
+ - **Requirements**:
381
+ - [ ] Design expression syntax (e.g., `condition: "@auth.role == 'editor'"`)
382
+ - [ ] Implement expression parser/evaluator
383
+ - [ ] Support common operators: `==`, `!=`, `>`, `<`, `>=`, `<=`, `&&`, `||`
384
+ - [ ] Support variables: `@auth` (current user), `@record` (current record), `@request` (request data)
385
+ - [ ] Apply expressions in middleware chain
386
+ - [ ] Add documentation and examples
387
+ - [ ] Add tests
388
+ - **Files to modify**: `core/auth.js`, `server/express-server.js`, `chadstart.schema.json`
389
+ - **Estimated effort**: Large (2-3 sessions)
390
+
391
+ ---
392
+
393
+ #### TASK P1-6: Magic Link / Passwordless Auth
394
+ - **Gap**: G9
395
+ - **Context**: Supabase, Appwrite, and Firebase support magic link login. Growing user preference.
396
+ - **Requirements**:
397
+ - [ ] Add `magicLink: true` option on authenticable entities
398
+ - [ ] Add `POST /api/auth/:slug/magic-link` endpoint (sends email with login link)
399
+ - [ ] Add `GET /api/auth/:slug/magic-link/confirm` endpoint (verifies token, returns JWT)
400
+ - [ ] Generate secure time-limited token (15min default)
401
+ - [ ] Rate-limit magic link requests
402
+ - [ ] Update SDK with `magicLink(entity, email)` method
403
+ - [ ] Add tests
404
+ - **Files to modify**: `core/auth.js`, `server/express-server.js`, `chadstart.schema.json`
405
+ - **Estimated effort**: Medium (1-2 sessions)
406
+ - **Dependencies**: TASK P0-5 (SMTP/Email sending)
407
+
408
+ ---
409
+
410
+ #### TASK P1-7: Schema Editor in Admin UI
411
+ - **Gap**: G4
412
+ - **Context**: PocketBase and Supabase allow creating/editing collections directly in the Admin UI. Currently ChadStart requires YAML editing.
413
+ - **⚠️ Constraint**: Must remain in the single-file SPA approach (`admin/index.html` with HTMX + Alpine.js). Do NOT introduce React/Vue/Svelte.
414
+ - **Requirements**:
415
+ - [ ] Add entity creation form in Admin UI
416
+ - [ ] Add property editor (add/remove/reorder fields)
417
+ - [ ] Add relation configuration UI
418
+ - [ ] Add validation rule editor
419
+ - [ ] Add policy configuration UI
420
+ - [ ] Generate YAML from UI changes and save to config file
421
+ - [ ] Show YAML preview before saving
422
+ - [ ] Support read-only mode for non-YAML configs (Jsonnet, JS)
423
+ - [ ] Add confirmation dialogs for destructive changes
424
+ - [ ] Add tests
425
+ - **Files to modify**: `admin/index.html`, `server/express-server.js`, `core/config-loader.js`
426
+ - **Estimated effort**: Very Large (3-4 sessions)
427
+
428
+ ---
429
+
430
+ ### P2 — Developer Experience
431
+
432
+ These improve the developer workflow and adoption.
433
+
434
+ ---
435
+
436
+ #### TASK P2-1: CHANGELOG.md
437
+ - **Context**: No changelog exists. Important for tracking version history.
438
+ - **Requirements**:
439
+ - [ ] Create CHANGELOG.md following [Keep a Changelog](https://keepachangelog.com/) format
440
+ - [ ] Document all changes from v1.0.0 to current (v1.0.5)
441
+ - [ ] Add sections: Added, Changed, Deprecated, Removed, Fixed, Security
442
+ - [ ] Reference commit history for accuracy
443
+
444
+ ---
445
+
446
+ #### TASK P2-2: CONTRIBUTING.md
447
+ - **Context**: No contribution guidelines exist.
448
+ - **Requirements**:
449
+ - [ ] Create CONTRIBUTING.md
450
+ - [ ] Document: setup instructions, coding style, PR process, testing requirements
451
+ - [ ] Add code of conduct reference
452
+ - [ ] Document architecture overview for contributors
453
+
454
+ ---
455
+
456
+ #### TASK P2-3: Improved Error Messages
457
+ - **Context**: Make error messages more actionable with suggested fixes.
458
+ - **Requirements**:
459
+ - [ ] Audit all error paths in `core/` and `server/`
460
+ - [ ] Add error codes (e.g., `CS_AUTH_001`, `CS_DB_001`)
461
+ - [ ] Add suggestion text (e.g., "Did you mean..." for typos in YAML)
462
+ - [ ] Add link to relevant docs in error messages
463
+ - [ ] Add tests for error messages
464
+
465
+ ---
466
+
467
+ #### TASK P2-4: CLI Improvements
468
+ - **Context**: CLI could be more helpful and interactive.
469
+ - **Requirements**:
470
+ - [ ] Add `npx chadstart init` — interactive project scaffolding
471
+ - [ ] Add `npx chadstart validate` — validate YAML without starting server
472
+ - [ ] Add `npx chadstart info` — show project info (entities, endpoints, etc.)
473
+ - [ ] Add `npx chadstart generate:entity <name>` — add entity to YAML
474
+ - [ ] Add `npx chadstart generate:function <name>` — scaffold function file
475
+ - [ ] Colorized output with progress indicators
476
+ - [ ] Add `--verbose` and `--quiet` flags
477
+ - **Files to modify**: `cli/cli.js`
478
+ - **Estimated effort**: Medium (1-2 sessions)
479
+
480
+ ---
481
+
482
+ #### TASK P2-5: Additional SDK Languages _(deprioritized)_
483
+ - **Status**: ⏸️ **Not a priority** — Owner confirmed JS SDK is sufficient for current target audience (solo devs / small teams).
484
+ - **Context**: Currently only JavaScript SDK exists. PocketBase has JS+Dart, Supabase has JS+Python+Swift+Kotlin+C#+Flutter.
485
+ - **Requirements** (if revisited later):
486
+ - [ ] Python SDK (`pip install chadstart`)
487
+ - [ ] Dart/Flutter SDK (`pub add chadstart`)
488
+ - [ ] Go SDK
489
+ - [ ] Auto-generate SDKs from OpenAPI spec (consider openapi-generator)
490
+ - **Estimated effort**: Large per SDK (1-2 sessions each)
491
+
492
+ ---
493
+
494
+ #### TASK P2-6: Troubleshooting & FAQ Documentation
495
+ - **Context**: No troubleshooting guide exists in docs/.
496
+ - **Requirements**:
497
+ - [ ] Create `docs/troubleshooting.md`
498
+ - [ ] Document common errors and solutions
499
+ - [ ] Add FAQ section
500
+ - [ ] Add database-specific troubleshooting (SQLite, PostgreSQL, MySQL)
501
+ - [ ] Add deployment troubleshooting
502
+ - [ ] Update mkdocs.yml navigation
503
+
504
+ ---
505
+
506
+ #### TASK P2-7: Architecture Documentation
507
+ - **Context**: No architecture overview for contributors/power-users.
508
+ - **Requirements**:
509
+ - [ ] Create `docs/architecture.md`
510
+ - [ ] Document core module responsibilities
511
+ - [ ] Add data flow diagrams (request → middleware → handler → DB → response)
512
+ - [ ] Document plugin architecture
513
+ - [ ] Document realtime event flow
514
+ - [ ] Document function runtime execution model
515
+
516
+ ---
517
+
518
+ ### P3 — Nice to Have
519
+
520
+ Lower priority features that would differentiate ChadStart further.
521
+
522
+ ---
523
+
524
+ #### TASK P3-1: GraphQL API
525
+ - **Gap**: G12
526
+ - **Context**: Supabase uses pg_graphql, Appwrite has built-in GraphQL. Could auto-generate from entity schema.
527
+ - **Requirements**:
528
+ - [ ] Auto-generate GraphQL schema from YAML entities
529
+ - [ ] Implement queries (list, get by ID, filtered)
530
+ - [ ] Implement mutations (create, update, delete)
531
+ - [ ] Implement subscriptions (realtime via WebSocket)
532
+ - [ ] Add GraphQL playground UI at `/graphql`
533
+ - [ ] Respect access policies
534
+ - [ ] Add tests
535
+ - **Estimated effort**: Very Large (4-5 sessions)
536
+
537
+ ---
538
+
539
+ #### TASK P3-2: Phone/SMS Authentication
540
+ - **Gap**: G10
541
+ - **Context**: Supabase, Appwrite, and Firebase support phone auth. Requires SMS provider integration.
542
+ - **Requirements**:
543
+ - [ ] Add `phone` property type
544
+ - [ ] Integrate with Twilio or similar SMS provider
545
+ - [ ] Add `POST /api/auth/:slug/phone/send-code` endpoint
546
+ - [ ] Add `POST /api/auth/:slug/phone/verify` endpoint
547
+ - [ ] Add SMS configuration in YAML
548
+ - **Estimated effort**: Medium (1-2 sessions)
549
+ - **New dependency**: SMS provider SDK
550
+
551
+ ---
552
+
553
+ #### TASK P3-3: Computed / Virtual Fields
554
+ - **Gap**: G9 (partial)
555
+ - **Context**: Supabase supports this via PostgreSQL views.
556
+ - **Requirements**:
557
+ - [ ] Add `computed: true` option on properties
558
+ - [ ] Support expression-based computation (`expression: "firstName || ' ' || lastName"`)
559
+ - [ ] Compute on read (not stored)
560
+ - [ ] Support in API responses
561
+ - [ ] Add tests
562
+ - **Estimated effort**: Medium (1-2 sessions)
563
+
564
+ ---
565
+
566
+ #### TASK P3-4: Managed Cloud Hosting
567
+ - **Gap**: G20
568
+ - **Context**: PocketBase has PocketHost, Supabase/Appwrite/Firebase all have managed cloud. This is a business-level feature.
569
+ - **Requirements**:
570
+ - [ ] Design multi-tenant architecture
571
+ - [ ] Build deployment automation
572
+ - [ ] Add billing/usage tracking
573
+ - [ ] Add project management dashboard
574
+ - [ ] Add custom domain support
575
+ - [ ] Add SSL provisioning
576
+ - **Estimated effort**: Epic (many sessions, separate project)
577
+
578
+ ---
579
+
580
+ #### TASK P3-5: Database Views / Computed Collections
581
+ - **Context**: Allow read-only collections backed by SQL views or aggregations.
582
+ - **Requirements**:
583
+ - [ ] Add `view` entity type
584
+ - [ ] Define SQL query in YAML
585
+ - [ ] Auto-generate read-only API endpoints
586
+ - [ ] Support in Admin UI (read-only mode)
587
+ - **Estimated effort**: Medium (1-2 sessions)
588
+
589
+ ---
590
+
591
+ #### TASK P3-6: Import/Export Data
592
+ - **Context**: Ability to import/export data in CSV, JSON formats.
593
+ - **Requirements**:
594
+ - [ ] Add `POST /api/collections/:slug/import` (CSV/JSON upload)
595
+ - [ ] Add `GET /api/collections/:slug/export` (CSV/JSON download)
596
+ - [ ] Add import/export buttons in Admin UI
597
+ - [ ] Handle validation errors during import
598
+ - [ ] Support large files with streaming
599
+ - **Estimated effort**: Medium (1-2 sessions)
600
+
601
+ ---
602
+
603
+ #### TASK P3-7: Audit Log / Activity Trail
604
+ - **Context**: Track all data changes with who/what/when for compliance.
605
+ - **Requirements**:
606
+ - [ ] Add `audit: true` option on entities
607
+ - [ ] Create `_cs_audit_log` table (entity, record_id, action, user_id, old_data, new_data, timestamp)
608
+ - [ ] Add `GET /admin/audit-log` endpoint
609
+ - [ ] Add audit log viewer in Admin UI
610
+ - [ ] Add retention policy configuration
611
+ - **Estimated effort**: Medium (1-2 sessions)
612
+
613
+ ---
614
+
615
+ #### TASK P3-8: Webhooks Management UI
616
+ - **Context**: Currently webhooks are configured in YAML only. Admin UI management would improve DX.
617
+ - **Requirements**:
618
+ - [ ] Add webhook management page in Admin UI
619
+ - [ ] Show webhook delivery history (success/fail)
620
+ - [ ] Allow retry failed deliveries
621
+ - [ ] Show request/response details
622
+ - **Estimated effort**: Medium (1-2 sessions)
623
+
624
+ ---
625
+
626
+ ## 4. Documentation Tasks
627
+
628
+ | # | Task | Priority | File |
629
+ |---|------|----------|------|
630
+ | D1 | Create CHANGELOG.md | P2 | `CHANGELOG.md` |
631
+ | D2 | Create CONTRIBUTING.md | P2 | `CONTRIBUTING.md` |
632
+ | D3 | Create troubleshooting guide | P2 | `docs/troubleshooting.md` |
633
+ | D4 | Create architecture overview | P2 | `docs/architecture.md` |
634
+ | D5 | Add comparison page (vs PocketBase, etc.) | P2 | `docs/comparison.md` |
635
+ | D6 | Improve API reference docs | P2 | `docs/api-reference.md` |
636
+ | D7 | Add migration/upgrade guide | P2 | `docs/upgrading.md` |
637
+ | D8 | Add performance tuning guide | P3 | `docs/performance.md` |
638
+ | D9 | Add security hardening guide | P2 | `docs/security.md` (expand existing) |
639
+ | D10 | Add example projects/templates | P2 | `examples/` directory |
640
+
641
+ ---
642
+
643
+ ## 5. Testing Tasks
644
+
645
+ | # | Task | Priority | Notes |
646
+ |---|------|----------|-------|
647
+ | T1 | Add PostgreSQL CI test matrix | P1 | Currently tests only run on SQLite |
648
+ | T2 | Add MySQL CI test matrix | P1 | Need Docker MySQL in CI |
649
+ | T3 | Add E2E tests for Admin UI | P2 | Playwright tests for admin workflows |
650
+ | T4 | Add OAuth integration tests | P2 | Mock OAuth provider |
651
+ | T5 | Add load/performance tests | P3 | k6 or artillery |
652
+ | T6 | Add security tests (OWASP) | P1 | SQL injection, XSS, CSRF |
653
+ | T7 | Increase code coverage to >80% | P2 | Current coverage unknown |
654
+
655
+ ---
656
+
657
+ ## 6. AI Session Guide
658
+
659
+ ### How to Use This Document
660
+
661
+ Each task is designed to be self-contained. An AI agent can:
662
+
663
+ 1. **Pick a task** by ID (e.g., "Implement TASK P0-5")
664
+ 2. **Read the requirements** — all context needed is in the task description
665
+ 3. **Find the files** — file paths are listed for each task
666
+ 4. **Implement** — follow the requirements checklist
667
+ 5. **Test** — run `npm test` to verify
668
+ 6. **Mark complete** — check off items in this TODO.md
669
+
670
+ ### Session Templates
671
+
672
+ #### Starting a new feature session:
673
+ ```
674
+ Implement TASK [ID] from TODO.md. Follow the requirements checklist.
675
+ The repository is at /home/runner/work/chadstart.com/chadstart.com.
676
+ Run existing tests with `npm test` to verify no regressions.
677
+ ```
678
+
679
+ #### Starting a documentation session:
680
+ ```
681
+ Complete documentation task [D#] from TODO.md.
682
+ The docs/ directory uses MkDocs with Material theme.
683
+ Update mkdocs.yml navigation if adding new pages.
684
+ ```
685
+
686
+ #### Starting a testing session:
687
+ ```
688
+ Complete testing task [T#] from TODO.md.
689
+ Existing tests are in test/*.test.js using Mocha.
690
+ Run with: npm test
691
+ ```
692
+
693
+ ### Recommended Implementation Order
694
+
695
+ ```
696
+ Phase 1 (Foundation):
697
+ P0-5 → P0-1 → P0-2 (Email → Verification → Password Reset)
698
+
699
+ Phase 2 (Core Parity):
700
+ P0-3 → P0-4 (Logs → Backup)
701
+ P1-3 → P1-4 (Realtime filters → Batch ops)
702
+
703
+ Phase 3 (Differentiation):
704
+ P1-1 → P1-5 (Full-text search → Custom policies)
705
+ P1-2 → P1-6 (MFA → Magic links)
706
+
707
+ Phase 4 (DX & Polish):
708
+ P2-1 → P2-7 (All DX tasks)
709
+ P1-7 (Schema editor in Admin UI)
710
+
711
+ Phase 5 (Advanced):
712
+ P3-1 → P3-8 (GraphQL, Phone auth, etc.)
713
+ ```
714
+
715
+ ### Key File Reference
716
+
717
+ | File/Directory | Purpose |
718
+ |---|---|
719
+ | `core/entity-engine.js` | Schema parsing, entity building, relations |
720
+ | `core/auth.js` | Authentication, authorization, API keys |
721
+ | `core/db.js` | Database abstraction (SQLite/PG/MySQL) |
722
+ | `core/realtime.js` | WebSocket subscriptions |
723
+ | `core/functions-engine.js` | Custom functions & triggers |
724
+ | `core/config-loader.js` | YAML/JSON/Jsonnet config loading |
725
+ | `core/oauth.js` | OAuth/social login |
726
+ | `core/migrations.js` | Database migration engine |
727
+ | `core/openapi.js` | OpenAPI spec generation |
728
+ | `core/telemetry.js` | OpenTelemetry + Sentry |
729
+ | `server/express-server.js` | Express app builder, route registration |
730
+ | `admin/index.html` | Admin UI (single-file SPA) |
731
+ | `cli/cli.js` | CLI commands |
732
+ | `chadstart.schema.json` | YAML config validation schema |
733
+ | `chadstart.example.yaml` | Full config reference |
734
+ | `test/*.test.js` | Test suite (Mocha) |
735
+
736
+ ---
737
+
738
+ *Last updated: 2026-03-30 (decisions incorporated)*
739
+ *ChadStart version: 1.0.5*