How a-ghorbani/pocketpal-ai works
Main Components
a. Frontend Layer:
• React Native UI Components (src/components)
• Screens (src/screens)
• Chat Screen
• Models Screen
• Settings Screen
• Benchmark Screen
b. State Management Layer:
• MobX Stores (src/store)
• ModelStore
• ChatSessionStore
• BenchmarkStore
• UIStore
• HFStore
c. Core Services:
• Model Management System
• Hugging Face Integration
• Local Storage System
• Device Info Services
d. External Integrations:
• llama.cpp (via llama.rn bindings)
• Hugging Face Hub API
• Firebase App Check
┌─ User Interface Layer ─────────────────────┐
• ┌─ Screens ─┐ ┌─ Core Components ───────┐ │
• Chat │ │Avatar │Dialog │ │
• Models │ │ChatInput │MarkdownView │ │
• Settings │ │Bubble │TextMessage │ │
• Benchmark │ │... │... │ │
• ┘ └────────────────────────┘ │
• State Management Layer ──────────────────┤
• ┌─ MobX Stores ────────────────────────┐ │
• ModelStore │ChatSessionStore │ │
• BenchmarkStore│UIStore │ │
• HFStore │ │ │
• ┘ │
• Core Services Layer ───────────────────┤
• ┌─ Model Management ─┐ ┌─ Storage ────┐ │
• Download │ │AsyncStorage │ │
• Load/Unload │ │File System │ │
• Inference │ │ │ │
• ┘ └──────────────┘ │
• Native Bridge Layer ─────────────────┤
• ┌─ Platform Specific ─────────────────┐ │
• iOS Native Modules │Android Native │ │
• Device Info │Modules │ │
• ┘ │
• External Dependencies ────────────────┘
• llama.cpp/llama.rn│Firebase AppCheck│
• Hugging Face API │ │
• ┘
Key Relationships to Highlight
• User interface components (blue)
• State management (green)
• Core services (orange)
• External dependencies (gray)
Important Details
• Offline capability workflow
• Model loading/unloading cycle
• Memory management flow
• Data persistence paths
• Platform-specific implementations
Implementation Notes
• Maintain consistent styling throughout
• Brief annotations for complex interactions
• Creating separate detailed views for critical subsystems
Key Workflows to Highlight
• Model download and initialization process
• Chat session management
• Memory optimization cycle
• Hugging Face model integration
• Platform-specific native module interactions
Remember to emphasize the unique aspects of PocketPal AI, such as its ability to run models directly on device and the automatic memory management system.