kauemurakami / getx_pattern

Design pattern designed to standardize your projects with GetX on Flutter.
https://kauemurakami.github.io/getx_pattern
1k stars 235 forks source link

Where would an auth service fit in here ? #10

Closed cedvdb closed 3 years ago

cedvdb commented 3 years ago

I'm looking at the project structure and I am wondering where an auth service would fit in here. I assume it's in the data directory.

I usually organise my projects with a core folder at the top

- core
   -  api
   -  controllers
   -  models
   auth_service.dart
- shared_widgets
- screens
- routing
- theming
kauemurakami commented 3 years ago

Hello ced, the goal of getx patterns is to totally simplify the architecture of a project.

Summary the auth in this model as a controller, a Service is "a controller that is not removed from memory", roughly speaking. But you have two options, to create something dedicated to your services, if you have a relevant number of services, which do not depend directly on a page, or you must keep with it.

Speaking now of its version, in packages, it becomes too long, it is very difficult to find your controller, then go and look for your page, imagine in 20, 30 screens, each with its controller?

I advise you to use a modular structure, the pattern itself has its version in modules and would look like this :

- /app  

    - /data
        - /repository
          - my_repository.dart
        - /services
          - /my_service.dart
          - /my_another_service.dart
        - /model
          - my_model.dart
        - /provider
          - my_provider.dart
    - /modules
        - /my_module
            - my_page.dart
            - my_controller.dart
            - my_binding.dart
            - /widgets
              - reusable_module_widget.dart
    - /widgets 
      - reusable_global_widget.dart
    - /routes
        - my_routes.dart
        - my_pages.dart
    - /theme
        - text_theme.dart  
        - color_theme.dart  
        - app_theme.dart  
- main.dart  

That way your page will always be next to your responsible controller.