Is it correct implement of layred Structure?

Hello Guys,
I tried to implement an E-commerce project and after looking for a good layout structure I found layered it can be good for my project. (why? because I have some Entity like:
Product, User, Order, Cart, Address, Media, Transaction and ....
and if I want to implement this project with domain or domain-hex I must implement a huge directory in my pkg directory. but if I’m in the wrong way of thinking and implement this project please guide me to found a Best layered structure for this project.)
I try to implement a tiny model of my project with directory structure in and share it with you guys. please let me know if anything can be better about anything of this project.

[](http://Please visit this link)

Why does the use of a layered architecture require a huge directory anywhere? What is the assumption behind this conclusion? Does this assumption really hold? (And what does “huge” mean in this context?)

In general, a layered architecture (like Clean Architecture, Hexagonal Architecture etc) is always a solid foundation for building larger project.

It is, however, not wrong if you start small using a flat project layout, and refactor the project into layers when it becomes large enough.


Thanks for your response Chris, so then if this project is huge is it ok to use domain-hex? in domain-hex, we have this package structure in this link:
is it ok to use domain-hex with the shared link for a bug E-commerce project?

I think if you look at Kat’s example/s, you’ll see that there isn’t a model for eg. users per se - but that that lives with the individual package itself, e.g adding/.

I’m quite new to Hex architecture too so not super comfortable yet, but it I believe it’s probably one of the few that are likely to support what you’re trying to do. As to how to structure your particular example, you’ll have to see how it goes, as @christophberger mentioned, you can start with flat and work your way up, see what works / doesn’t work. However, you are likely going to have to refactor your app, probably several times, in the process.

FWIW, I see you’re trying to do some RESTy kind of server, take a look at go-chi if you haven’t already.

Hope it helps!

1 Like