Perfect for discovering new meals with what you have at home! Never waste ingredients again and explore creative cooking possibilities powered by AI.
|
|
|
|
- Ingredient Management: Add, edit, and organize your available ingredients with categories
- AI Recipe Generation: Get creative, personalized recipes using OpenAI's GPT-4
- Smart Suggestions: Intelligent ingredient recommendations based on your preferences
- Recipe History: Keep track of previously generated recipes you loved
- Beautiful UI: Modern Material Design 3 interface with smooth animations
- Dark/Light Mode: Automatic theme switching based on system preferences
- Intuitive Navigation: Easy-to-use bottom navigation and gesture controls
- Responsive Design: Optimized for both phones and tablets
- Offline Support: Fallback sample recipes when AI is unavailable
- Recipe Sharing: Copy and share recipes with friends and family
- Local Storage: Save favorite recipes and ingredients locally
- Performance Optimized: Fast loading and smooth scrolling experience
This app follows Clean Architecture principles with the following layers:
- UI Components: Reusable Flutter widgets with Material Design 3
- State Management: BLoC pattern for predictable state management
BLoC (Business Logic Component) is a reactive state management pattern that separates business logic from UI components. Here's why we chose BLoC for this project:
What is BLoC?
- Business Logic Component is a design pattern that helps separate presentation from business logic
- Uses Streams and Sinks to handle data flow reactively
- Follows the Single Responsibility Principle - each BLoC handles one specific feature
- Implements Event-Driven Architecture where UI sends events and BLoC responds with states
Key Benefits:
✅ Predictable State Management: Every state change is traceable and testable
✅ Separation of Concerns: UI components only handle presentation, business logic stays in BLoC
✅ Reactive Programming: Automatic UI updates when data changes
✅ Testability: Easy to unit test business logic without UI dependencies
✅ Scalability: Clear structure that grows well with app complexity
✅ Reusability: BLoCs can be shared across multiple UI components
- BLoC Flow in Our App:
┌─────────────┐ Events ┌──────────────┐ States ┌─────────────┐
│ UI │─────────────▶│ BLoC │─────────────▶│ UI │
│ (Widgets) │ │ (Business │ │ (Rebuild) │
│ │ │ Logic) │ │ │
└─────────────┘ └──────────────┘ └─────────────┘
│
▼
┌──────────────┐
│ Repositories │
│ (Data) │
└──────────────┘
- BLoC vs Other State Management Solutions:
| Feature | BLoC | Provider | Riverpod | GetX |
|---|---|---|---|---|
| Learning Curve | Medium | Easy | Medium | Easy |
| Boilerplate | Medium | Low | Low | Very Low |
| Testability | Excellent | Good | Excellent | Good |
| Scalability | Excellent | Good | Excellent | Medium |
| Performance | Excellent | Good | Excellent | Good |
| Community | Large | Large | Growing | Medium |
Why BLoC for Recipe Generation?
- Complex State Management: Recipe generation involves multiple states (loading, success, error, caching)
- Reactive UI: Ingredients list changes should automatically update recipe suggestions
- Business Logic Separation: AI integration and data processing logic stays separate from UI
- Testing Requirements: Critical business logic needs thorough testing
- Future Scalability: Easy to add features like recipe history, favorites, and user preferences
- Use Cases: Business logic for recipe generation, ingredient management
- Entities: Core data models (Recipe, Ingredient, User preferences)
- Repositories: Abstract interfaces for data access
- Remote Data Source: OpenAI API integration for recipe generation
- Local Data Source: Hive database for offline storage
- Network Layer: Dio for HTTP requests with retry mechanisms
- Flutter 3.16.0 or higher
- Dart 3.2.0 or higher
- OpenAI API key (optional - app works with sample recipes without it)
- Android Studio / VS Code with Flutter extensions
-
Clone the repository
bash
git clone https://github.com/abbasiandev/smart_recipe_generator.git cd smart_recipe_generator -
Install dependencies
bash
flutter pub get -
Set up OpenAI API (Optional)
-
Create a
.envfile in the root directory -
Add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
-
-
Run the app
bash
flutter run



