This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Guilherme Gonçalves - Coding Challenge #39
Open
Guivinicius362
wants to merge
18
commits into
Superformula:master
Choose a base branch
from
Guivinicius362:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Guivinicius362
changed the title
Guilherme Gonçalves Coding Challenge
Guilherme Gonçalves - Coding Challenge
Jun 12, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Project Overview
This project is a Flutter application that uses the Yelp API to fetch and display restaurant data. The application is built with a focus on clean architecture, dependency injection, and internationalization (i18n) and localization (l10n).
Architecture
The project follows the principles of clean architecture, which separates concerns into different layers:
This separation of concerns makes the codebase easier to maintain and test.
Feature and Core Separation
The project is structured in a way that separates core functionality from feature-specific functionality. The core directory contains code that is shared across multiple features, such as utilities, constants, and base classes. Each feature has its own directory under the features directory. This separation makes the codebase more organized and easier to navigate.
There are also empty directories under the features directory. These are placeholders for future features, demonstrating the scalability of the project structure.
Dependency Injection
Dependency injection is used to provide instances of classes to other classes. This project uses the get_it package for dependency injection.
In the dependency_injection.dart file, a Dio instance is registered with get_it. This Dio instance is configured with base options for the Yelp API, including the base URL and headers.
By using get_it, we can easily get the Dio instance anywhere in our codebase with _getIt(). This makes our codebase more flexible and testable.
Flutter BLoC
The project uses the Flutter BLoC (Business Logic Component) library for state management. BLoC helps to separate the presentation layer from the business logic, making the codebase easier to maintain and test. Each feature of the application has its own BLoC, which manages the state of that feature.
Internationalization and Localization (i18n and l10n)
The project uses Flutter's l10n support to make the app available in multiple languages. This allows us to reach a wider audience.
The flutter_localizations package is used to provide localized strings and certain locale-specific behaviors. The flutter_gen package is used to generate the localization delegate.
To add a new language, we simply need to create a new ARB file in the l10n directory with the translations for that language.
Testing
The project includes a suite of 9 tests that cover the core functionality of the application. These tests ensure that the application behaves as expected and help to catch any regressions that might be introduced during development.
Package-based Architecture
While this project uses a feature-based architecture, for larger, more scalable applications, a package-based architecture could be used. In this approach, each feature would be a separate package, and there would be additional packages for core functionality and design system components. This would allow for even greater separation of concerns and make it easier to manage dependencies and test each part of the application in isolation.
For example, in this application, there could be separate packages for restaurants, profile, auth, etc., each containing the relevant domain, data, and presentation code. There would also be a core package for shared functionality and a design_system package for reusable UI components. The main application would then act as a shell that brings all these packages together.
Conclusion
This project showcases the use of clean architecture, dependency injection, and localization in a Dart application. These practices help to create a codebase that is scalable, maintainable, and user-friendly.
Screenshots