Directory Overview
Source Directory (src/)
The src/ directory contains all React Native application code written in TypeScript.
Components (src/components/)
Reusable UI components following the brutalist design system:
| Component | Purpose |
|---|---|
AnimatedEntry.tsx | Staggered fade+slide entrance animation for lists |
AnimatedListItem.tsx | Entry animation + press feedback combo |
AnimatedPressable.tsx | Spring scale + haptic press wrapper |
AppSheet.tsx | Custom swipe-to-dismiss bottom sheet |
ChatInput.tsx | Message input with attachments, vision/image-mode badges |
ChatMessage.tsx | Message bubbles with metadata |
DebugSheet.tsx | Developer debug bottom sheet |
ModelCard.tsx | Model display card (compact/full modes, icon actions) |
ModelSelectorModal.tsx | Quick model switcher |
GenerationSettingsModal.tsx | Image generation settings |
ProjectSelectorSheet.tsx | Project picker bottom sheet |
CustomAlert.tsx | Consistent alert dialogs |
Button.tsx | Reusable button component |
Card.tsx | Reusable card component |
ThinkingIndicator.tsx | LLM thinking animation |
VoiceRecordButton.tsx | Voice recording button |
Constants (src/constants/)
Theme-independent design tokens:
src/constants/index.ts
Hooks (src/hooks/)
Custom React hooks for shared logic:
useAppState.ts- App lifecycle state (foreground/background)useFocusTrigger.ts- Focus-based animation replay triggeruseVoiceRecording.ts- Voice recording logicuseWhisperTranscription.ts- Whisper transcription
Navigation (src/navigation/)
AppNavigator.tsx- Tab and stack navigators using React Navigation
Screens (src/screens/)
Full-screen views:
Chat & Conversations
Chat & Conversations
HomeScreen.tsx- Dashboard with model statusChatScreen.tsx- Main chat interface with message queueChatsListScreen.tsx- Conversation list
Models & Downloads
Models & Downloads
ModelsScreen.tsx- Browse and download models from Hugging FaceModelDownloadScreen.tsx- Model download details and progressModelSettingsScreen.tsx- Text and image model settings (temperature, GPU layers, etc.)DownloadManagerScreen.tsx- Download tracking
Media & Storage
Media & Storage
GalleryScreen.tsx- Generated images galleryStorageSettingsScreen.tsx- Storage management, orphaned file cleanup
Settings & Configuration
Settings & Configuration
SettingsScreen.tsx- App settings hubProjectsScreen.tsx- Project listProjectDetailScreen.tsx- Project detail viewProjectEditScreen.tsx- Create/edit projects (custom system prompts)SecuritySettingsScreen.tsx- Security settingsPassphraseSetupScreen.tsx- Passphrase configurationLockScreen.tsx- App lock screenVoiceSettingsScreen.tsx- Whisper settingsDeviceInfoScreen.tsx- Device hardware info
Onboarding
Onboarding
OnboardingScreen.tsx- First-launch onboarding
Services (src/services/)
Core business logic layer - singleton services that orchestrate native modules and manage state:
- LLM & Text Generation
- Image Generation
- Model Management
- Tools & Documents
- Voice & Misc
| Service | Purpose |
|---|---|
llm.ts | Text LLM inference (wraps llama.rn) |
activeModelService.ts | Model lifecycle management (load/unload) |
generationService.ts | Text generation orchestration (background-safe) |
generationToolLoop.ts | Multi-turn tool loop orchestration |
llmToolGeneration.ts | Low-level tool-aware LLM generation |
llmHelpers.ts | RAM-based context/GPU safeguards |
Stores (src/stores/)
Zustand state management with AsyncStorage persistence:
appStore.ts- Global app state (models, settings, hardware info, gallery)chatStore.ts- Conversations and messagesauthStore.ts- Authentication stateprojectStore.ts- Projects (custom system prompts)whisperStore.ts- Whisper model state
Theme (src/theme/)
Dynamic light/dark theme system:
index.ts-useTheme()hook,getTheme()functionpalettes.ts- Light/dark color palettes, shadows, elevationuseThemedStyles.ts- Memoized themed stylesheet factory
Types (src/types/)
TypeScript type definitions:
index.ts- All interfaces and typeswhisper.rn.d.ts- Whisper native module types
Utils (src/utils/)
Utility functions:
haptics.ts- Haptic feedback triggers
Android Native Code (android/)
Key Android Modules
LocalDreamModule
Bridges to local-dream C++ library for Stable Diffusion inference using MNN (CPU) or QNN (NPU) backends.
DownloadManager
Native Android DownloadManager wrapper for background model downloads with progress tracking.
PdfExtractorModule
Uses Android’s
PdfRenderer API for page-by-page PDF text extraction.iOS Native Code (ios/)
Key iOS Modules
CoreMLDiffusionModule
Swift bridge to Apple’s
ml-stable-diffusion StableDiffusionPipeline with Neural Engine (ANE) acceleration.PDFExtractorModule
Uses Apple’s
PDFKit framework (PDFDocument, PDFPage) for text extraction.DownloadManager
iOS download manager using RNFS/URLSession with progress callbacks to React Native.
Service Layer Architecture
Singleton Pattern
All core services are singletons to prevent:- Duplicate model loading
- Concurrent inference conflicts
- Memory leaks from orphaned contexts
- State desynchronization
Background-Safe Orchestration
generationService and imageGenerationService maintain state independently of React component lifecycle:
Memory-First Loading
All model loads check available RAM before proceeding:Key Design Patterns
Singleton Services
All core services are singleton instances exported from their modules to ensure single source of truth.
Background-Safe Ops
Long-running operations (inference, downloads) continue when screens unmount via lifecycle-independent services.
Memory-First
Pre-load RAM checks prevent OOM crashes by blocking loads that would exceed safe limits (60% of device RAM).
Combined Asset Tracking
Vision models track both GGUF and mmproj files as a single logical unit for memory estimation.
Documentation Files
Thedocs/ directory contains comprehensive technical documentation:
ARCHITECTURE.md- This comprehensive technical referencestandards/CODEBASE_GUIDE.md- Comprehensive code walkthroughdesign/DESIGN_PHILOSOPHY_SYSTEM.md- Brutalist design philosophy, theme systemdesign/VISUAL_HIERARCHY_STANDARD.md- Visual hierarchy and layout standards
Next Steps
Testing Guide
Learn how to run tests and understand the testing strategy
Contributing Guide
Understand the contribution workflow and quality gates