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.
- package/create.js +10 -8
- package/package.json +1 -1
- package/templates/agent-generator/AI_GUIDE.md +162 -10
- package/templates/agent-generator/CONVENTIONS.md +63 -10
- package/templates/agent-generator/GENERATE_RULES.md +68 -11
- package/templates/agent-generator/README.md +64 -13
- package/templates/agent-generator/TEMPLATE_VARIANTS.md +474 -0
- package/templates/agent-generator/ai-context.json +4 -0
- package/templates/agent-generator/app/(auth)/login.tsx +2 -4
- package/templates/agent-generator/app/(auth)/register.tsx +2 -4
- package/templates/agent-generator/app/(tabs)/index.tsx +2 -4
- package/templates/agent-generator/examples/apps/dashboard-with-auth/README.md +417 -0
- package/templates/agent-generator/examples/apps/news-no-auth/README.md +350 -0
- package/templates/agent-generator/examples/apps/todo-offline/README.md +197 -0
- package/templates/agent-generator/examples/component.example.tsx +2 -3
- package/templates/agent-generator/examples/screens/detail-screen.example.tsx +287 -0
- package/templates/agent-generator/examples/screens/form-screen.example.tsx +368 -0
- package/templates/agent-generator/examples/screens/list-screen-no-auth.example.tsx +194 -0
- package/templates/agent-generator/examples/screens/list-screen-with-auth.example.tsx +250 -0
- package/templates/agent-generator/examples/services/offline-service.example.ts +259 -0
- package/templates/agent-generator/examples/services/service-with-mock.example.ts +156 -0
- package/templates/agent-generator/examples/services/service-without-mock.example.ts +121 -0
- package/templates/agent-generator/src/components/shared/ConfirmDialog.tsx +37 -84
- package/templates/agent-generator/src/components/shared/FormInput.tsx +12 -35
- 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. ā
|
|
214
|
-
${chalk.dim("# START HERE ā
|
|
215
|
-
2.
|
|
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
|
-
|
|
219
|
+
4. š GENERATE_RULES.md
|
|
218
220
|
${chalk.dim("# Pola pembuatan kode")}
|
|
219
|
-
|
|
221
|
+
5. š CONVENTIONS.md
|
|
220
222
|
${chalk.dim("# Standar coding")}
|
|
221
|
-
|
|
223
|
+
6. š SERVER_GUIDE.md
|
|
222
224
|
${chalk.dim("# Mock API & dummy data guide")}
|
|
223
|
-
|
|
225
|
+
7. š” examples/
|
|
224
226
|
${chalk.dim("# Contoh kode siap pakai")}
|
|
225
|
-
|
|
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
|
@@ -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. **`
|
|
12
|
-
4. **`
|
|
13
|
-
5. **`
|
|
14
|
-
6. **`
|
|
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. **
|
|
387
|
-
4. **
|
|
388
|
-
5. **
|
|
389
|
-
6. **
|
|
390
|
-
7. **
|
|
391
|
-
8. **
|
|
392
|
-
9. **
|
|
393
|
-
10. **
|
|
394
|
-
|
|
395
|
-
|
|
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
|
-
"
|
|
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. **
|
|
113
|
-
2. **Use
|
|
114
|
-
3. **
|
|
115
|
-
4. **
|
|
116
|
-
5. **
|
|
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
|
-
|
|
430
|
-
- `examples/
|
|
431
|
-
- `examples/
|
|
432
|
-
- `examples/
|
|
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
|
-
|
|
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. **[
|
|
21
|
-
2. **[
|
|
22
|
-
3. **[
|
|
23
|
-
4. **[
|
|
24
|
-
5. **[
|
|
25
|
-
6. **[
|
|
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
|
-
|
|
115
|
-
- **`
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|