Skip to content

Restaurant Tour - Refactor with clean architecture #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Darjc
Copy link

@Darjc Darjc commented Sep 18, 2024

``

## Setup Instructions

  • Install dependencies: Run fvm flutter pub get to install required packages.
  • Create a .env file: In your project root, create a .env file containing this line:
YELP_API_KEY=<your_Yelp_API_key>
YELP_API_URL=https://api.yelp.com/v3/graphql
  • Replace <your_Yelp_API_key> with your actual Yelp API key.

  • Reference .env for running:

    • Terminal: Use fvm flutter run -d <your_device> --dart-define-from-file .env
    • VS Code: Modify your launch.json (refer to Flutter documentation for details). Here's an example structure:

JSON

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "app",
      "request": "launch",
      "type": "dart",
      "args": [
        "--dart-define-from-file",
        ".env"
      ]
    }
  ]
}

## Running Tests

  • Unit & Widget Tests: Use flutter test ./test for unit and widget testing.
  • Integration Tests: Execute flutter test ./integration_test -d <your_device> for integration tests (requires a connected device).

## Code Structure

The application code is organized in a layered structure within the lib folder:

  • common: Reusable classes across different layers.
  • data: Handles data access, including shared preferences and API calls.
  • di: Establishes dependency injection using GetIt.
  • domain: Contains business logic defined by interfaces (contracts).
  • models: Represents data structures with JSON annotations (e.g., Restaurant model).
  • presentation: Manages data flow using BLoC patterns (business logic components) that interact with the view and domain layers.
  • view: Holds UI components like pages and widgets.

## Observations

  • Prioritized Coverage: Instead of aiming for 100% coverage, we've focused on testing core use cases and the repository layer for optimal app functionality.
  • Comprehensive Testing Suite: The app utilizes unit tests, widget tests, and integration tests.
  • Integration Test Data Swapping: To bypass API call limitations during testing, a testMode flag is implemented in di.dart to switch the data source for restaurants.

Thank you (:

Add RestaurantsUsecase class

Implement methods for fetching restaurants and managing favorites

Integrate with RestaurantsRepository

add memory implementations for data source interfaces

add test for the use case
Add Exceptions for add/remove favorite

Update restaurants get methods
add restaurant page

create app theme file
Add dependency injection

Add favorite property

Update repository for to check favorite restaurants
refactor for restaurant pagination

add presentation tests
review integration test share preference behavior
add condition for test mode for restaurant datasource

add logs lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant