Skip to content
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

[enhancement] Model directory under the domain directory #47

Open
aeharvlee opened this issue May 26, 2020 · 0 comments
Open

[enhancement] Model directory under the domain directory #47

aeharvlee opened this issue May 26, 2020 · 0 comments

Comments

@aeharvlee
Copy link

aeharvlee commented May 26, 2020

Thanks for the great project btw.
It is really nice and neat structure, and I'm really enjoying develop project with this architecture.

How would you go about putting some depth on domain directories like below?
Because one domain may have so much of data types and if all that data types exists in just one file (black_ipv4.go in v3 clean-arch), it would be really hard to read the code and would be very fat.

black_ipv4
  - delivery
    - http
      - black_ipv4_handler.go
  - repository
    - black_ipv4_repo.go
  - usecase
    - black_ipv4_usecase.go
  - repository.go
  - usecase.go

domain
  - black_ipv4
    - model
      - attack_vector.go // Attack vector is a core data type indicating the type of attack the black ipv4. was attacking one of our customer's domain.
      - report.go // Report is a data type summarizing the most dangerous black ipv4 in specific period.
      - reputation.go // Reputation of black ipv4 during whole period.
  - custom_error
    - auth.go // Handles error raising during authentication process. To use this API, user must issue api key.
    - server.go // Handles error raising because of server fault which have status code 5xx mostly.

If we struct project like above example there are benefits:

  1. You can import all data types which is used in a domain with just one import sentense: import "github.com/aeharvlee/black-ip-api/black_ipv4/model
  2. You don't have to worry about one big domain file. You can freely add many data types for a domain.
  3. Readability is now good. You can read domain directory like "Oh, black_ipv4 domain have three main data types. attack_vector, report, and reputation. So if I want to add some fields on attack vector, what I do is just add some fields in attack_vector.go

Actually I used version2 features: You can see repository.go and usecase.go in black_ipv4 directory. The reason I use this v2 feature is "Repository and Usecase should use for a domain and should not use for each data types of the domain." It don't make sense use repo for attack_vector under the domain/black_ipv4/attack_vector because what we target is "domain/black_ipv4" not a piece of the domain.

If you don't understand well or need specific examples, please feel free to tell me. I will make an appropriate example on GitHub.

Edit:
If you agree with me, I will edit the source code and proceed with the pull request. Thanks.

The reason I use model directory under the black_ipv4 is for using echo-swagger. echo-swagger confuses because if we don't have model directory, there are two black_ipv4 directories.

@aeharvlee aeharvlee changed the title Model directory under the domain directory [enhancement Label] Model directory under the domain directory May 26, 2020
@aeharvlee aeharvlee changed the title [enhancement Label] Model directory under the domain directory [enhancement] Model directory under the domain directory May 26, 2020
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

No branches or pull requests

1 participant