Skip to content

Latest commit

 

History

History
126 lines (91 loc) · 6.62 KB

File metadata and controls

126 lines (91 loc) · 6.62 KB

DESIGN.md

Overview

This document outlines the design for a smart task manager Flutter application. The application will allow users to manage tasks, which will be automatically categorized and prioritized. The design emphasizes scalability, maintainability, and adherence to modern Flutter best practices.

Detailed Analysis of the Goal or Problem

The core problem is to create a task manager that reduces the manual effort of organizing tasks. This is achieved through two main features:

  1. Automatic Categorization: Tasks are automatically assigned to categories (e.g., "Work", "Personal") based on keywords found in the task description. This eliminates the need for users to manually select a category for each task.
  2. Automatic Prioritization: Tasks are assigned a priority level (High, Medium, Low) based on their due date. This helps users focus on the most urgent tasks.

The application should be designed to be extensible, with a plan to replace the initial keyword-based categorization with a more intelligent AI-based solution in the future.

Alternatives Considered

State Management

  • Provider: A popular choice for dependency injection and state management. It's a wrapper around InheritedWidget and is relatively easy to use.
  • Bloc: A more structured approach to state management, using events and states. It's well-suited for complex applications but can be verbose for simpler cases.
  • Riverpod: A compile-safe dependency injection and state management solution that addresses some of the pain points of Provider.
  • Built-in Solutions (ChangeNotifier, ValueNotifier): Flutter's built-in tools are often sufficient for simple to moderately complex state management needs. They are lightweight and easy to understand.

For this project, we will start with Flutter's built-in solutions within an MVVM (Model-View-ViewModel) architecture. This provides a good balance of simplicity and structure, and it can be easily scaled or migrated to a more advanced solution like Provider or Riverpod if needed.

Categorization Service

  • Hard-coded Logic: The simplest approach would be to have a single class with hard-coded if/else statements for categorization. This is not easily extensible.
  • Strategy Pattern: This pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. This is a good fit for our needs, as we can define a CategorizationStrategy interface and have different implementations for keyword-based and AI-based categorization.

We will use the Strategy Pattern for the categorization service. This will allow us to easily switch between the initial keyword-based implementation and a future AI-based implementation without changing the rest of the application.

Detailed Design for the New Package

Architecture

We will use a layered architecture based on the principles of Clean Architecture, adapted for a Flutter application. The layers will be:

  1. Presentation Layer: Contains the UI (widgets and screens) and the ViewModels. This layer will be responsible for displaying the data and handling user input.
  2. Domain Layer: Contains the business logic of the application. This includes use cases (e.g., AddTask, GetTasks), entities (e.g., Task), and the interfaces for our repositories.
  3. Data Layer: Responsible for data retrieval and storage. This layer will contain the implementation of the repositories and the data sources (e.g., a local database, a remote API).

State Management

We will use the MVVM pattern. Each screen will have a corresponding ViewModel, which will be a ChangeNotifier. The ViewModel will expose the state to the UI using ValueNotifiers and will handle the business logic by calling the appropriate use cases from the domain layer.

Categorization Service

The categorization service will be implemented using the Strategy Pattern.

  • TaskCategorizationStrategy (Interface):
    • Future<String> categorize(String taskDescription);
  • KeywordBasedTaskCategorizationStrategy (Implementation):
    • Implements the TaskCategorizationStrategy interface.
    • Contains a map of keywords to categories.
    • The categorize method will scan the task description for keywords and return the corresponding category.
  • AIBasedTaskCategorizationStrategy (Future Implementation):
    • Will also implement the TaskCategorizationStrategy interface.
    • The categorize method will use a machine learning model to classify the task.

Prioritization Logic

The prioritization logic will be simpler and can be encapsulated in a utility class or within the Task model itself. A method will take the due date and return the priority level (High, Medium, Low).

Project Structure

lib/
├── main.dart
├── core/
│   ├── usecases/
│   │   ├── add_task.dart
│   │   ├── get_tasks.dart
│   │   └── ...
│   ├── services/
│   │   └── task_categorization_service.dart
│   └── utils/
│       └── priority_util.dart
├── data/
│   ├── models/
│   │   └── task.dart
│   ├── repositories/
│   │   └── task_repository_impl.dart
│   └── datasources/
│       └── local_datasource.dart
├── domain/
│   ├── entities/
│   │   └── task.dart
│   └── repositories/
│       └── task_repository.dart
└── presentation/
    ├── viewmodels/
    │   └── task_list_viewmodel.dart
    └── views/
        └── task_list_screen.dart

Diagrams

Application Architecture

graph TD
    A[Presentation Layer (UI, ViewModels)] -->|Calls| B(Domain Layer (Use Cases, Entities))
    B -->|Calls| C(Data Layer (Repositories, Data Sources))
Loading

Categorization Strategy Pattern

graph TD
    A[TaskCategorizationService] --> B{TaskCategorizationStrategy};
    B --> C[KeywordBasedStrategy];
    B --> D[AIBasedStrategy (Future)];
Loading

Summary of the Design

The proposed design uses a layered architecture with MVVM for state management and the Strategy Pattern for the categorization service. This design is modular, testable, and extensible, providing a solid foundation for the smart task manager application.

References