This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Flutter-based mobile application for learning AI and Data Science. The app features:
- Gamified learning experience (XP, levels, streaks, achievements)
- AI-generated educational content via local LLMs
- Duolingo-inspired UI/UX
- Comprehensive learning path from beginner to expert
- Full offline support with local storage
Target Platform: iOS (Android-ready architecture)
# Install Flutter dependencies
flutter pub get
# Generate code for Hive adapters and Riverpod
flutter pub run build_runner build --delete-conflicting-outputs
# Clean generated files
flutter pub run build_runner clean# Run on iOS simulator (default)
flutter run
# Run on specific simulator
flutter run -d "iPhone 14 Pro"
# Run on physical device
flutter run -d <device-id>
# Run in release mode
flutter run --release# Hot reload: Press 'r' while app is running
# Hot restart: Press 'R' while app is running
# Quit: Press 'q'
# Format code
flutter format .
# Analyze code
flutter analyze
# List devices
flutter devices# Run all tests
flutter test
# Run with coverage
flutter test --coverage
# Run specific test file
flutter test test/models/user_progress_test.dart# Build iOS release
flutter build ios --release
# Build iOS debug
flutter build ios --debug
# Clean build artifacts
flutter clean# Start Ollama server (in separate terminal)
ollama serve
# Pull AI model
ollama pull llama3.2
# Test Ollama connection
curl http://localhost:11434/api/generate -d '{"model":"llama3.2","prompt":"test"}'The app uses Riverpod 2.0+ for state management:
- Providers are in
lib/providers/ - Notifiers extend
StateNotifier<T> - Use
ConsumerWidgetorConsumerto watch providers - Use
ref.watch()for reactive updates - Use
ref.read()for one-time access
Key provider:
userProgressProvider: Main user progress state
- Hive: Complex objects (UserProgress, cached lessons)
- SharedPreferences: Simple settings
- Adapters: Generated via
build_runner(see*.g.dartfiles) - Storage Service: Centralized API in
lib/services/storage_service.dart
- Uses named routes defined in
main.dart - Main routes:
/,/onboarding,/home,/learning-path,/lesson,/profile,/achievements - Pass arguments via
Navigator.pushNamed(context, '/lesson', arguments: {'lessonId': id})
- Centralized in
lib/utils/app_theme.dart - Duolingo-inspired color palette
- Google Fonts: Poppins (headings), Inter (body)
- Material 3 design system
lib/
├── main.dart # App entry, routes, providers
├── models/ # Data structures
│ ├── user_progress.dart # User stats, XP, streaks
│ ├── lesson.dart # Lesson structure
│ ├── learning_module.dart # Module organization
│ └── achievement.dart # Achievement system
├── providers/ # Riverpod state
│ └── user_progress_provider.dart
├── screens/ # Full-screen views
│ ├── splash_screen.dart
│ ├── onboarding_screen.dart
│ ├── home_screen.dart
│ ├── learning_path_screen.dart
│ ├── lesson_screen.dart
│ ├── profile_screen.dart
│ └── achievements_screen.dart
├── widgets/ # Reusable components
│ ├── stat_card.dart
│ ├── streak_widget.dart
│ ├── daily_goal_widget.dart
│ └── module_card.dart
├── services/ # Business logic
│ ├── ai_content_service.dart # LLM integration
│ ├── storage_service.dart # Data persistence
│ └── notification_service.dart # Push notifications
├── data/ # Static content
│ └── learning_content.dart # Pre-generated lessons
└── utils/ # Helpers
└── app_theme.dart
- XP: Users earn experience points for completing lessons
- Levels: Every 100 XP unlocks a new level
- Streaks: Daily learning maintains fire streak
- Achievements: Unlocked by milestones (streaks, XP, lessons)
- Daily Goals: Customizable daily XP targets
- Modules: High-level topics (e.g., "Python Basics")
- Lessons: Individual learning units within modules
- Lesson Types: Tutorial, Practice, Quiz, Project, Reading
- Difficulty Levels: Beginner, Intermediate, Advanced, Expert
- Uses Ollama for local LLM inference
- Falls back to template content if AI unavailable
- Can generate: lessons, quizzes, code examples, explanations
- Configured in
AIContentServiceclass
- Create file in
lib/screens/ - Extend
StatelessWidgetorStatefulWidget - Add route in
main.dartroutes map - Navigate with
Navigator.pushNamed(context, '/route-name')
- Create file in
lib/widgets/ - Make it reusable with required parameters
- Use
constconstructors when possible - Follow existing widget patterns
- Create file in
lib/models/ - For Hive storage:
- Add
@HiveType(typeId: X)annotation - Add
@HiveField(Y)for each field - Add
part 'model_name.g.dart'; - Run code generation
- Add
- For simple models: extend
Equatablefor easy equality
Always use the provider:
// In a ConsumerWidget
ref.read(userProgressProvider.notifier).addXP(50);
ref.read(userProgressProvider.notifier).completeLesson('lesson_id', 20);
ref.read(userProgressProvider.notifier).updateStreak();- Edit
lib/data/learning_content.dart - Add modules, lessons, questions following existing patterns
- Use AI service for dynamic generation
- Test content rendering in lesson viewer
final aiService = AIContentService();
final lesson = await aiService.generateLesson(
moduleId: 'my_module',
topic: 'Python Functions',
difficulty: DifficultyLevel.beginner,
type: LessonType.tutorial,
);await StorageService.completeLesson('lesson_id', xpReward: 20);
// This automatically:
// - Marks lesson as complete
// - Awards XP
// - Checks for level up
// - Triggers notifications if needed- Add to
LearningContent.getAllAchievements()inlearning_content.dart - Check conditions in appropriate places
- Unlock via:
ref.read(userProgressProvider.notifier).unlockAchievement('achievement_id')
This project uses build_runner for:
- Hive adapters:
*.g.dartfiles for model persistence - Riverpod generators: Future use with
riverpod_generator
Important: After modifying models with @HiveType annotations, run:
flutter pub run build_runner build --delete-conflicting-outputsUse AppTheme constants:
AppTheme.primaryGreen- Success, primary actionsAppTheme.primaryBlue- Info, secondaryAppTheme.primaryPurple- PremiumAppTheme.primaryYellow- RewardsAppTheme.primaryOrange- Streaks
Use theme text styles:
Theme.of(context).textTheme.displayLarge
Theme.of(context).textTheme.headlineMedium
Theme.of(context).textTheme.bodyLargeUse consistent spacing (multiples of 4):
- Small: 8px
- Medium: 16px
- Large: 24px
- Extra Large: 32px
- Test model logic (XP calculation, level progression)
- Test service methods (storage, AI generation)
- Test utility functions
- Test widget rendering
- Test user interactions
- Test state changes
- Test user flows (onboarding, lesson completion)
- Test data persistence
- Test gamification triggers
- Use
constconstructors wherever possible - Minimize rebuilds: Watch specific providers, not entire state
- Lazy load: Don't load all lessons at once
- Cache images: Use
CachedNetworkImage - Profile regularly: Use Flutter DevTools
flutter clean
rm -rf .dart_tool
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputscd ios
pod deintegrate
pod install
cd ..
flutter clean
flutter run- Ensure using
ConsumerWidgetorConsumer - Use
ref.watch()notref.read()for reactive updates - Check if
StateNotifieris callingstate = newState
- Verify Ollama is running:
ollama serve - Check model is downloaded:
ollama list - Test endpoint:
curl http://localhost:11434/api/tags - App will use fallback content if AI unavailable
flutter: Frameworkflutter_riverpod: State managementhive,hive_flutter: Local storageshared_preferences: Simple key-value storage
google_fonts: Typographyflutter_animate: Animationslottie: Complex animationsshimmer: Loading states
flutter_local_notifications: Push notificationsflutter_highlighting: Code syntax highlightingfl_chart: Data visualizationcached_network_image: Image caching
build_runner: Code generationhive_generator: Generate adaptersflutter_lints: Linting rules
- Screens:
*_screen.dart - Widgets:
*_widget.dartor descriptive name - Services:
*_service.dart - Providers:
*_provider.dart - Models: descriptive name
- Use snake_case for files
- Always run code generation after model changes
- Test on real device for accurate performance
- Use Riverpod DevTools for debugging state
- Check memory usage when adding animations
- Profile before optimizing - measure first!
- Flutter Docs
- Riverpod Docs
- Hive Docs
- Project docs:
README.md,SETUP_GUIDE.md,DEVELOPMENT.md
ref.read(userProgressProvider.notifier).addXP(50);final progress = ref.watch(userProgressProvider);
final isCompleted = progress?.hasCompletedLesson('lesson_id') ?? false;Navigator.pushNamed(context, '/lesson', arguments: {'lessonId': 'id'});await StorageService.saveLesson('id', lessonData);
final lesson = StorageService.getLesson('id');For detailed information, see:
- Setup:
SETUP_GUIDE.md - Development:
DEVELOPMENT.md - Overview:
PROJECT_SUMMARY.md