create-ern-boilerplate 0.0.38 → 0.0.40

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 (25) hide show
  1. package/create.js +10 -8
  2. package/package.json +1 -1
  3. package/templates/agent-generator/AI_GUIDE.md +162 -10
  4. package/templates/agent-generator/CONVENTIONS.md +63 -10
  5. package/templates/agent-generator/GENERATE_RULES.md +68 -11
  6. package/templates/agent-generator/README.md +64 -13
  7. package/templates/agent-generator/TEMPLATE_VARIANTS.md +474 -0
  8. package/templates/agent-generator/ai-context.json +4 -0
  9. package/templates/agent-generator/app/(auth)/login.tsx +2 -4
  10. package/templates/agent-generator/app/(auth)/register.tsx +2 -4
  11. package/templates/agent-generator/app/(tabs)/index.tsx +2 -4
  12. package/templates/agent-generator/examples/apps/dashboard-with-auth/README.md +417 -0
  13. package/templates/agent-generator/examples/apps/news-no-auth/README.md +350 -0
  14. package/templates/agent-generator/examples/apps/todo-offline/README.md +197 -0
  15. package/templates/agent-generator/examples/component.example.tsx +2 -3
  16. package/templates/agent-generator/examples/screens/detail-screen.example.tsx +287 -0
  17. package/templates/agent-generator/examples/screens/form-screen.example.tsx +368 -0
  18. package/templates/agent-generator/examples/screens/list-screen-no-auth.example.tsx +194 -0
  19. package/templates/agent-generator/examples/screens/list-screen-with-auth.example.tsx +250 -0
  20. package/templates/agent-generator/examples/services/offline-service.example.ts +259 -0
  21. package/templates/agent-generator/examples/services/service-with-mock.example.ts +156 -0
  22. package/templates/agent-generator/examples/services/service-without-mock.example.ts +121 -0
  23. package/templates/agent-generator/src/components/shared/ConfirmDialog.tsx +37 -84
  24. package/templates/agent-generator/src/components/shared/FormInput.tsx +12 -35
  25. package/templates/agent-generator/src/components/shared/RoleSelector.tsx +16 -35
package/create.js CHANGED
@@ -210,19 +210,21 @@ ${chalk.cyan("Sebelum mulai mengembangkan fitur, sangat disarankan mengikuti uru
210
210
 
211
211
  ${chalk.bold("\nšŸ“– READING ORDER (Urutan Baca yang Direkomendasikan):\n")}
212
212
 
213
- 1. ⭐ AI_GUIDE.md
214
- ${chalk.dim("# START HERE — onboarding & cara kerja AI")}
215
- 2. šŸ“ ai-context.json
213
+ 1. ⭐ TEMPLATE_VARIANTS.md
214
+ ${chalk.dim("# START HERE — Choose template variant")}
215
+ 2. ⭐ AI_GUIDE.md
216
+ ${chalk.dim("# Complete AI onboarding guide & cara kerja AI")}
217
+ 3. šŸ“ ai-context.json
216
218
  ${chalk.dim("# Path mappings & context")}
217
- 3. šŸ“‹ GENERATE_RULES.md
219
+ 4. šŸ“‹ GENERATE_RULES.md
218
220
  ${chalk.dim("# Pola pembuatan kode")}
219
- 4. šŸ“ CONVENTIONS.md
221
+ 5. šŸ“ CONVENTIONS.md
220
222
  ${chalk.dim("# Standar coding")}
221
- 5. šŸ“‹ SERVER_GUIDE.md
223
+ 6. šŸ“‹ SERVER_GUIDE.md
222
224
  ${chalk.dim("# Mock API & dummy data guide")}
223
- 6. šŸ’” examples/
225
+ 7. šŸ’” examples/
224
226
  ${chalk.dim("# Contoh kode siap pakai")}
225
- 7. šŸ“– README.md
227
+ 8. šŸ“– README.md
226
228
  ${chalk.dim("# Gambaran umum project")}
227
229
 
228
230
  ${chalk.bold("\nšŸ“– Pastikan untuk selalu menjaga stabilitas integrasi, skalabilitas arsitektur, maintainability, testability, konsistensi codebase, serta zero error.\n")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ern-boilerplate",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "Expo React Native boilerplate generator",
5
5
  "bin": {
6
6
  "create-ern-boilerplate": "./create.js",
@@ -8,10 +8,11 @@ When you first enter this project, read these files in order:
8
8
 
9
9
  1. **`README.md`** - Understand project structure and features
10
10
  2. **`ai-context.json`** - Know where to generate each type of code
11
- 3. **`GENERATE_RULES.md`** - āš ļø **READ THIS FIRST** - Tech stack & dependency rules
12
- 4. **`CONVENTIONS.md`** - Understand coding standards
13
- 5. **`SERVER_GUIDE.md`** - āš ļø **Mock API & dummy data guide**
14
- 6. **`examples/`** - See actual working code patterns
11
+ 3. **`TEMPLATE_VARIANTS.md`** - āš ļø **READ THIS FIRST** - Choose template variant for your app type
12
+ 4. **`GENERATE_RULES.md`** - āš ļø **Tech stack & dependency rules**
13
+ 5. **`CONVENTIONS.md`** - Understand coding standards
14
+ 6. **`SERVER_GUIDE.md`** - āš ļø **Mock API & dummy data guide**
15
+ 7. **`examples/`** - See actual working code patterns
15
16
 
16
17
  ## 🚨 CRITICAL RULES - Read First!
17
18
 
@@ -68,8 +69,12 @@ Fixed Versions:
68
69
  "themePath": "src/theme", // Theme configuration
69
70
  "mockDataPath": "server/db.json", // Mock database (sample/starter data)
70
71
  "examples": "examples", // Code examples - CHECK THIS FIRST!
72
+ "examplesScreens": "examples/screens", // Screen examples (list, form, detail)
73
+ "examplesServices": "examples/services", // Service examples (with/without mock/offline)
74
+ "examplesApps": "examples/apps", // Complete mini app examples
71
75
  "aiGuide": "AI_GUIDE.md", // AI agent guide
72
76
  "serverGuide": "SERVER_GUIDE.md", // Mock API & server guide
77
+ "templateVariants": "TEMPLATE_VARIANTS.md", // Template customization guide
73
78
  "rules": "GENERATE_RULES.md", // Code generation rules
74
79
  "conventions": "CONVENTIONS.md" // Coding conventions
75
80
  }
@@ -86,6 +91,124 @@ Stores: newsStore.ts, authStore.ts (camelCase + Store)
86
91
  Types: news.types.ts, user.types.ts (kebab-case + .types)
87
92
  ```
88
93
 
94
+ ## šŸ“ Examples Folder Structure
95
+
96
+ The `examples/` folder contains comprehensive code patterns organized by category:
97
+
98
+ ### Overview
99
+ ```
100
+ examples/
101
+ ā”œā”€ā”€ screens/ # Screen examples for different scenarios
102
+ │ ā”œā”€ā”€ list-screen-no-auth.example.tsx # Public content list (no auth)
103
+ │ ā”œā”€ā”€ list-screen-with-auth.example.tsx # Protected content list (with auth)
104
+ │ ā”œā”€ā”€ form-screen.example.tsx # Create/edit form
105
+ │ └── detail-screen.example.tsx # Detail page with actions
106
+ │
107
+ ā”œā”€ā”€ services/ # Service examples for different setups
108
+ │ ā”œā”€ā”€ service-with-mock.example.ts # API service with mock support
109
+ │ ā”œā”€ā”€ service-without-mock.example.ts # Direct API connection only
110
+ │ └── offline-service.example.ts # Offline storage (AsyncStorage)
111
+ │
112
+ ā”œā”€ā”€ apps/ # Complete mini app examples
113
+ │ ā”œā”€ā”€ todo-offline/ # Offline todo app (no auth, no API)
114
+ │ ā”œā”€ā”€ news-no-auth/ # News app (no auth, with API)
115
+ │ └── dashboard-with-auth/ # Dashboard (with auth, with API)
116
+ │
117
+ ā”œā”€ā”€ component.example.tsx # Reusable component pattern
118
+ ā”œā”€ā”€ hook.example.ts # Custom hook pattern
119
+ ā”œā”€ā”€ screen.example.tsx # Generic screen pattern (legacy)
120
+ └── service.example.ts # Generic service pattern (legacy)
121
+ ```
122
+
123
+ ### When to Use Which Example
124
+
125
+ #### Screen Examples (`examples/screens/`)
126
+
127
+ **1. `list-screen-no-auth.example.tsx`**
128
+ - **Use for:** Public content apps (news, recipes, products)
129
+ - **Features:** List view, pull-to-refresh, navigation to detail
130
+ - **No auth required:** Anyone can access
131
+ - **Example apps:** News reader, recipe browser, product catalog
132
+
133
+ **2. `list-screen-with-auth.example.tsx`**
134
+ - **Use for:** User-specific content (tasks, orders, notifications)
135
+ - **Features:** Protected route, user greeting, personalized data
136
+ - **Auth required:** Must be logged in
137
+ - **Example apps:** Task manager, order history, dashboard
138
+
139
+ **3. `form-screen.example.tsx`**
140
+ - **Use for:** Create/edit data (products, posts, profiles)
141
+ - **Features:** Form validation, create/edit modes, error handling
142
+ - **Works with or without auth**
143
+ - **Example apps:** Create product, edit profile, submit form
144
+
145
+ **4. `detail-screen.example.tsx`**
146
+ - **Use for:** Single item display (product, article, user)
147
+ - **Features:** Detail view, action buttons (edit, delete), params handling
148
+ - **Works with or without auth**
149
+ - **Example apps:** Product detail, article reader, profile page
150
+
151
+ #### Service Examples (`examples/services/`)
152
+
153
+ **1. `service-with-mock.example.ts`**
154
+ - **Use for:** Apps with backend API
155
+ - **Features:** Auto-switch between mock (dev) and real (prod) API
156
+ - **Mock API support:** Yes
157
+ - **Example:** Article service, product service
158
+
159
+ **2. `service-without-mock.example.ts`**
160
+ - **Use for:** Third-party APIs, production-only features
161
+ - **Features:** Direct API connection, no mock switching
162
+ - **Mock API support:** No
163
+ - **Example:** Weather API, payment gateway
164
+
165
+ **3. `offline-service.example.ts`**
166
+ - **Use for:** Offline-first apps, local storage
167
+ - **Features:** AsyncStorage, no network required
168
+ - **Mock API support:** N/A (no API)
169
+ - **Example:** Todo app, notes app, settings
170
+
171
+ #### Complete App Examples (`examples/apps/`)
172
+
173
+ **1. `todo-offline/`** - Offline Todo App
174
+ - **Auth:** āŒ No
175
+ - **API:** āŒ No
176
+ - **Storage:** AsyncStorage
177
+ - **Best for:** Personal productivity apps, calculators, offline tools
178
+ - **Read:** `examples/apps/todo-offline/README.md`
179
+
180
+ **2. `news-no-auth/`** - Public News App
181
+ - **Auth:** āŒ No
182
+ - **API:** āœ… Yes (with mock support)
183
+ - **Storage:** API only
184
+ - **Best for:** Public content, news, blogs, recipes
185
+ - **Read:** `examples/apps/news-no-auth/README.md`
186
+
187
+ **3. `dashboard-with-auth/`** - Protected Dashboard
188
+ - **Auth:** āœ… Yes
189
+ - **API:** āœ… Yes (with mock support)
190
+ - **Storage:** API + local token
191
+ - **Best for:** Business apps, SaaS, team tools
192
+ - **Read:** `examples/apps/dashboard-with-auth/README.md`
193
+
194
+ ### Quick Decision Guide
195
+
196
+ **Building a new app? Choose your template variant:**
197
+
198
+ ```
199
+ Does your app need user accounts?
200
+ ā”œā”€ NO
201
+ │ ā”œā”€ Does it need API?
202
+ │ │ ā”œā”€ NO → Use: examples/apps/todo-offline/
203
+ │ │ └─ YES → Use: examples/apps/news-no-auth/
204
+ │ └─ Remove auth from template (see TEMPLATE_VARIANTS.md)
205
+ │
206
+ └─ YES
207
+ ā”œā”€ Keep auth in template
208
+ ā”œā”€ Use: examples/apps/dashboard-with-auth/
209
+ └─ Follow patterns for protected routes
210
+ ```
211
+
89
212
  ## šŸŽÆ Common Tasks
90
213
 
91
214
  ### Task 1: Build a News App
@@ -383,13 +506,17 @@ This boilerplate includes a **mock API** that simulates a backend server:
383
506
  ## 🚦 Quick Checklist
384
507
 
385
508
  Before generating code:
509
+ - [ ] āš ļø **Check TEMPLATE_VARIANTS.md** - Understand which template variant to use
510
+ - [ ] āš ļø **Check examples/apps/** - See complete app examples for your use case
511
+ - [ ] āš ļø **Check examples/screens/** - Use appropriate screen pattern (auth/no-auth)
512
+ - [ ] āš ļø **Check examples/services/** - Use appropriate service pattern (mock/no-mock/offline)
386
513
  - [ ] āš ļø **Check package.json** - Only use existing packages!
387
514
  - [ ] āš ļø **NO new dependencies** - Use what's already installed
388
- - [ ] āš ļø **Check server/db.json** - Ensure dummy data exists and matches types
389
- - [ ] Read examples/ folder
515
+ - [ ] āš ļø **Check server/db.json** - Ensure dummy data exists and matches types (if using API)
516
+ - [ ] Read examples/ folder for patterns
390
517
  - [ ] Check ai-context.json for paths
391
518
  - [ ] Use TypeScript types
392
- - [ ] Add dummy data to server/db.json
519
+ - [ ] Add dummy data to server/db.json (if using mock API)
393
520
  - [ ] Create mock API file if needed
394
521
  - [ ] Use path aliases (@/)
395
522
  - [ ] Support theme (light/dark)
@@ -412,19 +539,44 @@ Before generating code:
412
539
  ## šŸ“ž Quick Commands
413
540
 
414
541
  ```bash
415
- # Read important files
542
+ # Read important files (in order!)
543
+ cat TEMPLATE_VARIANTS.md # ⭐ Start here - choose template variant
416
544
  cat README.md
417
545
  cat ai-context.json
418
546
  cat GENERATE_RULES.md
419
547
  cat CONVENTIONS.md
420
548
  cat SERVER_GUIDE.md
549
+ cat AI_GUIDE.md
421
550
 
422
- # Check examples
551
+ # Check examples structure
423
552
  ls examples/
553
+ ls examples/screens/ # Screen patterns
554
+ ls examples/services/ # Service patterns
555
+ ls examples/apps/ # Complete app examples
556
+
557
+ # Check screen examples
558
+ cat examples/screens/list-screen-no-auth.example.tsx
559
+ cat examples/screens/list-screen-with-auth.example.tsx
560
+ cat examples/screens/form-screen.example.tsx
561
+ cat examples/screens/detail-screen.example.tsx
562
+
563
+ # Check service examples
564
+ cat examples/services/service-with-mock.example.ts
565
+ cat examples/services/service-without-mock.example.ts
566
+ cat examples/services/offline-service.example.ts
567
+
568
+ # Check complete app examples
569
+ cat examples/apps/todo-offline/README.md
570
+ cat examples/apps/news-no-auth/README.md
571
+ cat examples/apps/dashboard-with-auth/README.md
572
+
573
+ # Check legacy examples
424
574
  cat examples/screen.example.tsx
575
+ cat examples/component.example.tsx
576
+ cat examples/hook.example.ts
425
577
  cat examples/service.example.ts
426
578
 
427
- # Check mock data & API
579
+ # Check mock data & API (if using API)
428
580
  cat server/db.json
429
581
  ls src/services/mockApi/
430
582
  cat src/services/mockApi/products.mock.ts
@@ -383,13 +383,66 @@ const handlePress = useCallback(() => {
383
383
 
384
384
  1. **NO New Dependencies** - Use only what's in package.json āš ļø
385
385
  2. **Fixed Tech Stack** - React 19.1.0, RN 0.81.4, Expo SDK 54 āš ļø
386
- 3. **TypeScript** - Always use proper types
387
- 4. **Path Aliases** - Use `@/` for imports
388
- 5. **NativeWind** - Use Tailwind classes
389
- 6. **Theme Support** - Always support light/dark
390
- 7. **Error Handling** - Always handle errors
391
- 8. **Loading States** - Always show loading
392
- 9. **Clean Code** - Small functions, clear names
393
- 10. **Examples** - Check `examples/` folder
394
-
395
- When in doubt, check the `examples/` folder!
386
+ 3. **Template Variants** - Check `TEMPLATE_VARIANTS.md` for your app type āš ļø
387
+ 4. **TypeScript** - Always use proper types
388
+ 5. **Path Aliases** - Use `@/` for imports
389
+ 6. **NativeWind** - Use Tailwind classes
390
+ 7. **Theme Support** - Always support light/dark
391
+ 8. **Error Handling** - Always handle errors
392
+ 9. **Loading States** - Always show loading
393
+ 10. **Clean Code** - Small functions, clear names
394
+ 11. **Examples** - Check `examples/` folder (see Examples Guide below)
395
+
396
+ ## šŸ“š Examples Guide
397
+
398
+ ### Before You Start
399
+
400
+ 1. **Read `TEMPLATE_VARIANTS.md`** - Choose the right template variant for your app
401
+ 2. **Check `examples/apps/`** - See complete app examples
402
+ 3. **Check `examples/screens/`** - Find the right screen pattern
403
+ 4. **Check `examples/services/`** - Find the right service pattern
404
+
405
+ ### Which Example to Use?
406
+
407
+ **Building a Todo/Notes App (Offline)?**
408
+ → Use `examples/apps/todo-offline/` + `examples/services/offline-service.example.ts`
409
+
410
+ **Building a News/Blog App (Public Content)?**
411
+ → Use `examples/apps/news-no-auth/` + `examples/screens/list-screen-no-auth.example.tsx`
412
+
413
+ **Building a Dashboard (Protected)?**
414
+ → Use `examples/apps/dashboard-with-auth/` + `examples/screens/list-screen-with-auth.example.tsx`
415
+
416
+ **Need a Form?**
417
+ → Use `examples/screens/form-screen.example.tsx`
418
+
419
+ **Need a Detail Page?**
420
+ → Use `examples/screens/detail-screen.example.tsx`
421
+
422
+ ### Complete Examples List
423
+
424
+ **App Examples:**
425
+ - `examples/apps/todo-offline/` - Offline app (no auth, no API)
426
+ - `examples/apps/news-no-auth/` - Public content (no auth, with API)
427
+ - `examples/apps/dashboard-with-auth/` - Protected app (with auth, with API)
428
+
429
+ **Screen Examples:**
430
+ - `examples/screens/list-screen-no-auth.example.tsx`
431
+ - `examples/screens/list-screen-with-auth.example.tsx`
432
+ - `examples/screens/form-screen.example.tsx`
433
+ - `examples/screens/detail-screen.example.tsx`
434
+
435
+ **Service Examples:**
436
+ - `examples/services/service-with-mock.example.ts`
437
+ - `examples/services/service-without-mock.example.ts`
438
+ - `examples/services/offline-service.example.ts`
439
+
440
+ **Legacy Examples:**
441
+ - `examples/screen.example.tsx`
442
+ - `examples/component.example.tsx`
443
+ - `examples/hook.example.ts`
444
+ - `examples/service.example.ts`
445
+
446
+ ---
447
+
448
+ When in doubt, check the `examples/` folder and `TEMPLATE_VARIANTS.md`!
@@ -103,17 +103,51 @@ From `ai-context.json`:
103
103
  "componentsPath": "src/components",
104
104
  "hooksPath": "src/hooks",
105
105
  "servicesPath": "src/services",
106
- "examples": "examples"
106
+ "mockApiPath": "src/services/mockApi",
107
+ "storePath": "src/store",
108
+ "typesPath": "src/types",
109
+ "utilsPath": "src/utils",
110
+ "themePath": "src/theme",
111
+ "mockDataPath": "server/db.json",
112
+ "examples": "examples",
113
+ "examplesScreens": "examples/screens",
114
+ "examplesServices": "examples/services",
115
+ "examplesApps": "examples/apps",
116
+ "templateVariants": "TEMPLATE_VARIANTS.md"
107
117
  }
108
118
  ```
109
119
 
110
120
  ## General Rules
111
121
 
112
- 1. **Use TypeScript** - All files must have proper types
113
- 2. **Use Path Aliases** - Import with `@/` not `../../`
114
- 3. **Follow Examples** - Check `examples/` folder first
115
- 4. **Theme Support** - Always use `useThemeStore` for colors
116
- 5. **Keep It Simple** - Don't over-engineer
122
+ 1. **Check Template Variant First** - Read `TEMPLATE_VARIANTS.md` to understand which variant fits your app
123
+ 2. **Use TypeScript** - All files must have proper types
124
+ 3. **Use Path Aliases** - Import with `@/` not `../../`
125
+ 4. **Follow Examples** - Check `examples/` folder first (see Examples Guide below)
126
+ 5. **Theme Support** - Always use `useThemeStore` for colors
127
+ 6. **Keep It Simple** - Don't over-engineer
128
+
129
+ ## šŸ“ Choosing the Right Examples
130
+
131
+ Before generating code, determine which examples to follow:
132
+
133
+ ### For Complete App Architecture
134
+ Check `examples/apps/` to understand overall structure:
135
+ - **`todo-offline/`** - No auth, no API (offline storage)
136
+ - **`news-no-auth/`** - No auth, with API (public content)
137
+ - **`dashboard-with-auth/`** - With auth, with API (protected content)
138
+
139
+ ### For Screen Patterns
140
+ Check `examples/screens/` for specific screen types:
141
+ - **`list-screen-no-auth.example.tsx`** - Public list (news, products, recipes)
142
+ - **`list-screen-with-auth.example.tsx`** - Protected list (tasks, orders, notifications)
143
+ - **`form-screen.example.tsx`** - Create/edit forms with validation
144
+ - **`detail-screen.example.tsx`** - Detail page with actions
145
+
146
+ ### For Service Patterns
147
+ Check `examples/services/` for data layer:
148
+ - **`service-with-mock.example.ts`** - API with mock support (dev/prod switch)
149
+ - **`service-without-mock.example.ts`** - Direct API only (third-party APIs)
150
+ - **`offline-service.example.ts`** - Offline storage with AsyncStorage
117
151
 
118
152
  ## Screens (app/)
119
153
 
@@ -402,6 +436,10 @@ if (loading) {
402
436
 
403
437
  Before generating code:
404
438
 
439
+ - [ ] **Check TEMPLATE_VARIANTS.md** - Understand which template variant to use
440
+ - [ ] **Check examples/apps/** - See complete app example for your use case
441
+ - [ ] **Check examples/screens/** - Use appropriate screen pattern (auth/no-auth)
442
+ - [ ] **Check examples/services/** - Use appropriate service pattern (mock/no-mock/offline)
405
443
  - [ ] Check `examples/` folder for similar pattern
406
444
  - [ ] Use TypeScript with proper types
407
445
  - [ ] Use path aliases (`@/`)
@@ -426,9 +464,28 @@ Before generating code:
426
464
 
427
465
  Always refer to `examples/` folder for complete, working patterns:
428
466
 
429
- - `examples/screen.example.tsx`
430
- - `examples/component.example.tsx`
431
- - `examples/hook.example.ts`
432
- - `examples/service.example.ts`
467
+ ### Complete App Examples
468
+ - `examples/apps/todo-offline/README.md` - Offline todo app
469
+ - `examples/apps/news-no-auth/README.md` - Public news app
470
+ - `examples/apps/dashboard-with-auth/README.md` - Protected dashboard
471
+
472
+ ### Screen Examples
473
+ - `examples/screens/list-screen-no-auth.example.tsx` - Public list
474
+ - `examples/screens/list-screen-with-auth.example.tsx` - Protected list
475
+ - `examples/screens/form-screen.example.tsx` - Create/edit forms
476
+ - `examples/screens/detail-screen.example.tsx` - Detail page
477
+
478
+ ### Service Examples
479
+ - `examples/services/service-with-mock.example.ts` - API with mock
480
+ - `examples/services/service-without-mock.example.ts` - Direct API
481
+ - `examples/services/offline-service.example.ts` - Offline storage
482
+
483
+ ### Legacy Examples (Generic Patterns)
484
+ - `examples/screen.example.tsx` - Generic list screen
485
+ - `examples/component.example.tsx` - Generic component
486
+ - `examples/hook.example.ts` - Generic hook
487
+ - `examples/service.example.ts` - Generic service
488
+
489
+ **Follow these patterns exactly - they work!**
433
490
 
434
- Follow these patterns exactly - they work!
491
+ Read `TEMPLATE_VARIANTS.md` to choose the right template variant for your app.
@@ -17,12 +17,13 @@ This template is designed to work seamlessly with AI agents for rapid developmen
17
17
 
18
18
  **First time in this project?** Read these files in order:
19
19
 
20
- 1. **[AI_GUIDE.md](AI_GUIDE.md)** ⭐ **START HERE** - Complete AI onboarding guide
21
- 2. **[ai-context.json](ai-context.json)** - Path mappings
22
- 3. **[GENERATE_RULES.md](GENERATE_RULES.md)** - Code generation patterns
23
- 4. **[CONVENTIONS.md](CONVENTIONS.md)** - Coding standards
24
- 5. **[SERVER_GUIDE.md](SERVER_GUIDE.md)** - Mock API & dummy data guide
25
- 6. **[examples/](examples/)** - Actual working code to copy
20
+ 1. **[TEMPLATE_VARIANTS.md](TEMPLATE_VARIANTS.md)** ⭐ **START HERE** - Choose template variant
21
+ 2. **[AI_GUIDE.md](AI_GUIDE.md)** - Complete AI onboarding guide
22
+ 3. **[ai-context.json](ai-context.json)** - Path mappings
23
+ 4. **[GENERATE_RULES.md](GENERATE_RULES.md)** - Code generation patterns
24
+ 5. **[CONVENTIONS.md](CONVENTIONS.md)** - Coding standards
25
+ 6. **[SERVER_GUIDE.md](SERVER_GUIDE.md)** - Mock API & dummy data guide
26
+ 7. **[examples/](examples/)** - Actual working code to copy
26
27
 
27
28
  ## Quick Start
28
29
 
@@ -43,6 +44,19 @@ npm start
43
44
  │ └── _layout.tsx # Root layout
44
45
  │
45
46
  ā”œā”€ā”€ examples # Code examples for AI
47
+ │ ā”œā”€ā”€ screens/ # Screen examples for different scenarios
48
+ │ │ ā”œā”€ā”€ list-screen-no-auth.example.tsx # Public content list
49
+ │ │ ā”œā”€ā”€ list-screen-with-auth.example.tsx # Protected content list
50
+ │ │ ā”œā”€ā”€ form-screen.example.tsx # Create/edit form
51
+ │ │ └── detail-screen.example.tsx # Detail page
52
+ │ ā”œā”€ā”€ services/ # Service examples for different setups
53
+ │ │ ā”œā”€ā”€ service-with-mock.example.ts # API with mock support
54
+ │ │ ā”œā”€ā”€ service-without-mock.example.ts # Direct API only
55
+ │ │ └── offline-service.example.ts # Offline storage
56
+ │ ā”œā”€ā”€ apps/ # Complete mini app examples
57
+ │ │ ā”œā”€ā”€ todo-offline/ # Offline todo app
58
+ │ │ ā”œā”€ā”€ news-no-auth/ # Public news app
59
+ │ │ └── dashboard-with-auth/ # Protected dashboard
46
60
  │ ā”œā”€ā”€ component.example.tsx # Component pattern
47
61
  │ ā”œā”€ā”€ hook.example.ts # Custom hook pattern
48
62
  │ ā”œā”€ā”€ screen.example.tsx # Screen pattern
@@ -109,10 +123,27 @@ The `ai-context.json` tells AI where to generate code:
109
123
 
110
124
  ### Code Examples
111
125
 
112
- Check `examples/` folder for patterns:
126
+ Check `examples/` folder for comprehensive patterns:
113
127
 
114
- - **`screen.example.tsx`** - List screen with loading/error states
115
- - **`component.example.tsx`** - Reusable component with variants
128
+ **Screen Patterns:**
129
+ - **`screens/list-screen-no-auth.example.tsx`** - Public content list (no auth)
130
+ - **`screens/list-screen-with-auth.example.tsx`** - Protected list (with auth)
131
+ - **`screens/form-screen.example.tsx`** - Create/edit forms with validation
132
+ - **`screens/detail-screen.example.tsx`** - Detail page with actions
133
+
134
+ **Service Patterns:**
135
+ - **`services/service-with-mock.example.ts`** - API service with mock support
136
+ - **`services/service-without-mock.example.ts`** - Direct API connection
137
+ - **`services/offline-service.example.ts`** - Offline storage (AsyncStorage)
138
+
139
+ **Complete App Examples:**
140
+ - **`apps/todo-offline/`** - Offline todo app (no auth, no API)
141
+ - **`apps/news-no-auth/`** - Public news app (no auth, with API)
142
+ - **`apps/dashboard-with-auth/`** - Protected dashboard (with auth, with API)
143
+
144
+ **Legacy Examples:**
145
+ - **`screen.example.tsx`** - Generic list screen
146
+ - **`component.example.tsx`** - Reusable component
116
147
  - **`hook.example.ts`** - Data fetching hook
117
148
  - **`service.example.ts`** - CRUD API service
118
149
 
@@ -120,14 +151,34 @@ Check `examples/` folder for patterns:
120
151
 
121
152
  Example prompts for AI:
122
153
 
154
+ **For Public Content App:**
155
+ ```
156
+ Build a news app following examples/apps/news-no-auth/
157
+ Use the list-screen-no-auth pattern for the main screen
158
+ Use service-with-mock pattern for the article service
123
159
  ```
124
- Create a news list screen following examples/screen.example.tsx
125
160
 
126
- Generate a ProductCard component like examples/component.example.tsx
161
+ **For Offline App:**
162
+ ```
163
+ Create a todo app following examples/apps/todo-offline/
164
+ Use offline-service pattern for data storage
165
+ No auth or API needed
166
+ ```
127
167
 
128
- Build a useProducts hook similar to examples/hook.example.ts
168
+ **For Protected Dashboard:**
169
+ ```
170
+ Build a dashboard following examples/apps/dashboard-with-auth/
171
+ Use list-screen-with-auth for the main screen
172
+ Keep authentication as-is
173
+ Use service-with-mock for data
174
+ ```
129
175
 
130
- Create a product service following examples/service.example.ts
176
+ **Individual Components:**
177
+ ```
178
+ Create a product list screen following examples/screens/list-screen-no-auth.example.tsx
179
+ Generate a create product form using examples/screens/form-screen.example.tsx
180
+ Build a product detail page using examples/screens/detail-screen.example.tsx
181
+ Create a product service using examples/services/service-with-mock.example.ts
131
182
  ```
132
183
 
133
184
  ## State Management