-
Notifications
You must be signed in to change notification settings - Fork 0
Transform codebase into Based Native App Template with OpenSpec integration #1
Copy link
Copy link
Open
Description
Transform Codebase into Based Native App Template
Overview
Transform the current React Native gallery app into a reusable template system that combines smart AI-guided customization with OpenSpec workflow integration.
Current State Analysis
Tech Stack
- React Native 0.81.4 (New Architecture with JSI)
- React 19.1.0, TypeScript 5.9.3
- Navigation: React Navigation v7 with custom horizontal pages
- State: React Context + useReducer
- Database: WatermelonDB 0.28.0 + MMKV 3.3.3
- UI: Atomic Design (atoms/molecules/organisms/templates)
- Animation: Reanimated 3.19.2
- ML: ML Kit (image labeling, text recognition)
- Media: Vision Camera, Camera Roll, Fast Image
Current Structure
src/
├── components/
│ ├── atoms/ # Button, Icon, Badge, ProgressBar, etc.
│ ├── molecules/ # AlbumCard, SearchBar, ProcessingIndicator
│ ├── organisms/ # PhotoGrid, PhotoViewerModal, SettingsDrawer
│ └── templates/ # MainTemplate, OnboardingTemplate
├── screens/ # Main, Albums, Onboarding, Settings
├── contexts/ # Gallery, Navigation, Processing, Search, Settings, Toast
├── services/ # Background, database, media, ML, orchestrator
├── models/ # WatermelonDB models (MediaFile, Album, Label)
├── theme/ # Design tokens, useTheme hook
└── utils/ # Animations, constants, device utilities
Requirements from Discovery (5 Rounds)
Round 1: Core Architecture
- Scope: Modular - users can choose which features to keep/delete
- AI Instructions: Inline comments + hybrid approach (markers + reference docs)
- Customization: Everything - branding, theme, pages, data models, business logic
- Workflow: Guided wizard at initialization → AI reads project → asks about new app → fills OpenSpec
Round 2: Technical Implementation
- Module Structure: Feature flags + layer-based removal (maintain project structure)
- Wizard Flow: Collect all info (project identity, feature selection, branding, domain context) - via interactive questions OR pre-written file
- Marker Syntax: Special comment blocks
/* AI-INSTRUCTION-START:id ... AI-INSTRUCTION-END */ - Domain Logic: Skeleton only - empty Home & Settings pages with minimal placeholder UI
Round 3: Project Structure
- Feature Flags: template.config.json at root
- Code Removal: Immediate - create skeleton first
- openspec/project.md: All sections (tech stack, template conventions, AI instruction reference, example workflows)
- Directory: Root becomes the template (no archive needed, backed up elsewhere)
Round 4: Skeleton Details
- Skeleton UI: Minimal functional - just navigation between Home/Settings
- Files to Remove:
- All gallery/photo logic (MainScreen, AlbumsScreen, PhotoGrid, PhotoViewerModal, InfoDrawer)
- ML & Processing services (image labeling, text recognition, background processing)
- Transform domain models to placeholders, delete unnecessary files
- Keep native modules for now
- Instruction Detail: Spec-driven - each block references OpenSpec requirement
- Config Schema: OpenSpec-aligned structure
Round 5: Deployment & Usage
- Initialization: Manual clone + guided mode (AI auto-detects unconfigured template and launches wizard)
- Example Changes: Generated during wizard based on user's initial feature
- Updates: Static snapshot (one-time starting point, users maintain independently)
- Documentation: README with quick start guide
Implementation Plan
Phase 1: Clean Skeleton Creation
-
Remove domain-specific code
- Delete gallery/photo screens: MainScreen, AlbumsScreen, PhotoGrid, PhotoViewerModal, InfoDrawer
- Delete ML services: image-labeling, text-recognition, background processing, orchestrator
- Transform WatermelonDB models to generic placeholders (remove MediaFile, Album, Label specifics)
- Clean up unnecessary service files
- Keep: Navigation system, all UI components (atoms/molecules/organisms), context pattern, theme system, native modules
-
Create minimal skeleton pages
- HomeScreen: Minimal functional page with navigation working
- SettingsScreen: Basic settings drawer with essential options only
- Update RootNavigator to include only Home & Settings
- Remove Albums page and custom horizontal page navigation if not needed
Phase 2: Feature Flag System
-
Create template.config.json
- OpenSpec-aligned structure with sections for template metadata, project info, features, branding, domain
- Document schema thoroughly in comments
- Include configured flag to trigger wizard
-
Implement feature flags in code
- Mark optional features with conditional loading based on config
- Create utility to read template.config.json
- Implement layer-based removal system (can cleanly remove features across all layers)
Phase 3: AI Instruction System
-
Add AI instruction blocks throughout codebase
- Use syntax:
/* AI-INSTRUCTION-START:instruction-id ... AI-INSTRUCTION-END */ - Mark all customization points: theme, data models, screens, business logic, contexts
- Each instruction references an OpenSpec requirement
- Use syntax:
-
Create openspec/ai-instructions/ directory
- Detailed guidance documents for each instruction block
- Spec-driven format with requirements and scenarios
- Examples: theme-customization.md, data-model-creation.md, screen-generation.md, service-implementation.md
Phase 4: OpenSpec Integration
-
Fill out openspec/project.md with:
- Tech Stack & Architecture: Complete documentation of RN setup, New Architecture, Atomic Design, Context patterns
- Template-Specific Conventions: How to add features, file organization, naming conventions for template system
- AI Instruction Reference: Catalog of all AI-INSTRUCTION blocks with explanations
- Example Customization Workflows: Step-by-step examples for common tasks
-
Set up OpenSpec structure
- Copy AGENTS.md from based-native-app/ to root
- Copy CLAUDE.md from based-native-app/ to root
- Create openspec/ directory structure (AGENTS.md, project.md, ai-instructions/, specs/, changes/)
Phase 5: Setup Wizard System
- Create wizard detection & flow
- Detect unconfigured template by checking configured flag in config
- Wizard collects: project identity, feature selection, branding & theme, initial domain context
- Support interactive mode AND file-based mode
- Apply customizations: replace placeholders, remove unused features, generate theme, create models
- Generate first OpenSpec change proposal as learning example
- Update configured flag to true
Phase 6: Documentation & Polish
-
Write comprehensive README.md
- What is this template, features, quick start guide
- OpenSpec workflow overview, AI collaboration guide
- Tech stack, project structure, contributing
-
Final cleanup & verification
- Update package.json metadata
- Verify all placeholders are marked correctly
- Test wizard flow end-to-end
- Ensure no domain-specific code remains
- Verify feature flags work correctly
- Test AI instructions are discoverable
- Remove based-native-app/ directory (merge what's needed)
Success Criteria
- Template is completely domain-agnostic (no gallery/photo logic)
- All reusable components preserved (atoms/molecules/organisms)
- Feature flag system works for modular features
- AI instruction blocks are in place and reference OpenSpec
- Setup wizard detects unconfigured template and guides user
- openspec/project.md is comprehensive and accurate
- README provides clear quick start
- First clone → wizard → customized project works seamlessly
- Generated OpenSpec example helps users learn the workflow
Estimated Scope
- ~50-70 files modified/deleted
- ~2000 lines removed (domain-specific code)
- ~1000 lines added (config, instructions, docs)
- Time estimate: 6-10 hours of focused work
Deliverable
Production-ready React Native template with:
- Clean skeleton structure (Home + Settings)
- Atomic Design component library
- Modular feature system
- AI-guided customization with OpenSpec integration
- Comprehensive documentation
- One-time setup wizard
- Ready for users to build apps 10x faster
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels