Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Coding Challenge - Joao Costa #32

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a94eb52
chore(android): change kotlin version due to conflict with gradle ver…
jodamco Apr 12, 2024
44998c9
chore(general): initial setup; sets yelp appKey
jodamco Apr 12, 2024
1e8c497
feat(all restaurants): wip - creates restaurants bloc; move models an…
jodamco Apr 13, 2024
357947f
feat(all restaurants): create all restaurants list page; creates rest…
jodamco Apr 14, 2024
9c41e9c
refactor(yelp repository): refactor repository to get mock data due t…
jodamco Apr 14, 2024
b9a1445
feat(restaurant details): wip - add restaurant details view; add on t…
jodamco Apr 14, 2024
4536d7e
feat(restaurant details): wip - add reviews query to yelp repo; renam…
jodamco Apr 14, 2024
6816174
feat(restaurant details): adds reviews to restaurant details page; mo…
jodamco Apr 14, 2024
0f9e4f1
fix(yelp repo): fix 'getReviewsQuery' query
jodamco Apr 14, 2024
fdd2628
refactor(home page): change tabs style
jodamco Apr 14, 2024
8b8f446
feat(fav restaurants): wip - refactor model and yelp repo to handle r…
jodamco Apr 15, 2024
fcff18a
feat(fav restaurants): wip - creates favourite_restaurants hyrdrated …
jodamco Apr 15, 2024
1c2eda6
feat(fav restaurants): fix StatusQueryResult json notation; rename re…
jodamco Apr 15, 2024
f2eb18b
test: adds tests for reviews cubit, restaurant bloc, image hero and r…
jodamco Apr 15, 2024
48512bb
test: fix usage of DioException on tests
jodamco Apr 15, 2024
c89c02b
chore(general): fix warnings; set yelp repo to use yelp API only on r…
jodamco Apr 15, 2024
14a0bdf
fix(yelp repo): fix _getRestaurantStatusQuery
jodamco Apr 15, 2024
cbadec1
docs: update docs with app structure and architecture
jodamco Apr 15, 2024
b464662
fix(yelp repo): reset apiKey value
jodamco Apr 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.13.9",
"flavors": {}
}
109 changes: 45 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ If you're a VScode user link the new Flutter SDK path in your settings
}
```


</p>
</details>

Expand All @@ -65,9 +64,14 @@ Go to `Preferences > Languages & Frameworks > Flutter` and set the Flutter SDK p
</p>
</details>

## Requirements
## App Structure

### Design

The app is based on the following [Figma File](https://www.figma.com/file/KsEhQUp66m9yeVkvQ0hSZm/Flutter-Test?node-id=0%3A1). Improvements and new features are welcolme as long as they follow the same visual aspect of the initial design

### App Structure
![List View](screenshots/listview.png)
![Detail View](screenshots/detailview.png)

#### Restaurant List Page

Expand Down Expand Up @@ -96,88 +100,65 @@ Go to `Preferences > Languages & Frameworks > Flutter` and set the Flutter SDK p
- User image
- Review Text (These are just snippets of the full review, usually like 3-4 lines long)

#### Misc.
### Architechture

- Clear documentation on the structure and architecture of your application.
- Clear and logical commit messages.
- We suggest following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
The project follows a Domain based architecture, a less rigid form of Clean Architecture. On the domain, sets of features may share same widgets, repositories and logic to acomplish the desired tasks. So far, the only domain is the Restaurant itself since it's a small app, therefore dependencies are declared right on top of widget tree, the top of the domain, and injected when needed through the usage of RepositoryProvider and BlocProvider.

## Test Coverage
- Restaurant domain
- data
- Restaurant models
- Yelp Repository
- logic
- FavouriteRestaurantsBloc
- RestaurantReviewsCubit
- RestaurantsBloczz
- presentation
- All Restaurants
- Favourite Restaurants
- Restaurant details

To demonstrate your experience writing different types of tests in Flutter please do the following:
This organization also aims to protect core models from change and make the view dependent on models and logic in a way that make the view reflect the desired business rules of the project.

- Choose ONE portion of your state management and write a unit test.
- Choose ONE widget and write a widget test.
### Presentation

Feel free to add more tests as you see fit but the above is the minimum requirement.
The presentation widgets are splited into two different folders
- common, where widgets used across the Restaurants domain are stored
- views, where widgets representing bigger/complete screen vies are stored

## Design
Common and View widgets both may have widget folders within, where minor widgets are stored to enhance code splitting. This helps improve maintainance, code readability and testing.

- See this [Figma File](https://www.figma.com/file/KsEhQUp66m9yeVkvQ0hSZm/Flutter-Test?node-id=0%3A1) for design information related to the overall look and feel of the application. We do not expect pixel-perfection but would like the application to visually be close to what is specified in the Figma file.
Whenever view or common widgets get bigger, consider spliting into smaller parts within widgets folder.

![List View](screenshots/listview.png)
![Detail View](screenshots/detailview.png)
### Data

Data folder contains models and repositories that will dictate the domain main data types and how the application interacts with the source of data.

## API
#### Yelp API

The [Yelp GraphQL API](https://www.yelp.com/developers/graphql/guides/intro) is used as the API for this Application. We have provided the boilerplate of the API requests and backing data models to save you some time. To successfully make a request to the Yelp GraphQL API, please follow these steps:
The [Yelp GraphQL API](https://www.yelp.com/developers/graphql/guides/intro) is used as the API for this Application. To successfully make a request to the Yelp GraphQL API, please follow these steps:

1. Please go to https://www.yelp.com/signup and sign up for a developer account.
1. Once signed up, navigate to https://www.yelp.com/developers/v3/manage_app.
1. Create a new app by filling out the required information.
1. Once your app is created, scroll down and join the `Developer Beta`. This allows you to use the GraphQL API.
1. Copy your API Key from your app page and paste it on `line 5` [yelp_repository.dart](app/lib/yelp_repository.dart) replacing the `<PUT YOUR API KEY HERE>` with your key.
1. Run the app and tap the `Fetch Restaurants` button. If you see a log like `Fetched x restaurants` you are all set!

## Technical Requirements

### State Management

Please restrict your usage of state management or dependency injection to the following options:

1. [provider](https://pub.dev/packages/provider)
2. [Riverpod](https://pub.dev/packages/riverpod)
3. [bloc](https://pub.dev/packages/bloc)
4. [get_it](https://pub.dev/packages/get_it)/[get_it_mixins](https://pub.dev/packages/get_it_mixin)
5. [Mobx](https://pub.dev/packages/mobx)

We ask this because this challenge values consistency and efficiency over ingenuity. Using commonly used libraries ensures that we can review your code in a timely manner and allows us to provide better feedback.

## Coding Values

At **Superformula** we strive to build applications that have

- Consistent architecture
- Extensible, clean code
- Solid testing
- Good security & performance best practices

### Clear, consistent architecture

Approach your submission as if it were a real world app. This includes Use any libraries that you would normally choose.

_Please note: we're interested in your code & the way you solve the problem, not how well you can use a particular library or feature._

### Easy to understand

Writing boring code that is easy to follow is essential at **Superformula**.

We're interested in your method and how you approach the problem just as much as we're interested in the end result.
1. Copy your API Key from your app page and paste it on `line 5` [yelp_repository.dart](./lib/data/repositories/yelp_repository.dart) replacing the `<PUT YOUR API KEY HERE>` with your key.

### Solid testing approach
#### Yelp Repository

While the purpose of this challenge is not to gauge whether you can achieve 100% test coverage, we do seek to evaluate whether you know how & what to test.
This repository uses Dio and GraphQl notation to fetch data from Yelp GraphQL API. Response models from models folder are used to handle response parsing.

## Q&A
#### Favourite Restaurants

> Where should I send back the result when I'm done?
Due to the simplicity of data, local storage of favourite restaurants is being handled under the hood by HydratedBloc. No repository is necessary to handle this source of data.

Please fork this repo and then send us a pull request to our repo when you think you are done. There is no deadline for this task unless otherwise noted to you directly.
### State management / Logic

> What if I have a question?
The logic folder contains the BLoC files to handle the logic and state of the application. BLoC was chosen to better define the desired states and the transition between them, and also HydratedBloc provided a built-in way to handle local storage of states. There are 3 BLoCs, all of them making use of Yelp Repository:

Just create a new issue in this repo and we will respond and get back to you quickly.
- FavouriteRestaurantsBloc
- RestaurantReviewsCubit
- RestaurantsBloc

## Review
## Misc.

The coding challenge is a take-home test upon which we'll be conducting a thorough code review once complete. The review will consist of meeting some more of our mobile engineers and giving a review of the solution you have designed. Please be prepared to share your screen and run/demo the application to the group. During this process, the engineers will be asking questions.
- This project follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.0'
repositories {
google()
mavenCentral()
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
12 changes: 12 additions & 0 deletions assets/yelp_rest_status_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data": {
"business": {
"id": "syhA1ugJpyNLaB0MiP19VA",
"hours": [
{
"is_open_now": true
}
]
}
}
}
Loading