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

Guilherme Gonçalves - Coding Challenge #39

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

Conversation

Guivinicius362
Copy link

@Guivinicius362 Guivinicius362 commented Jun 12, 2024

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:

  • Domain Layer: This layer contains the business logic of the application. It defines entities, use cases, and abstract interfaces for repositories.
  • Data Layer: This layer implements the repositories defined in the domain layer. It's responsible for fetching data from different sources (like the Yelp API).
  • Presentation Layer: This layer is responsible for displaying the data to the user. It includes widgets and state management solutions.

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

Screenshot_1718203148
Screenshot_1718203146
Screenshot_1718203212
Screenshot_1718203142
Screenshot_1718203139
Screenshot_1718203163

@Guivinicius362 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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant