Skip to content
loading...

Folder Structure and Frameworks: What is exerting control?

Barry O Sullivan on May 17, 2019

Recently I've been thinking about folder structures, specifically how we structure our web apps to encourage the design we want and to enable other... [Read Full]
markdown guide
 

I also structure the code of my back-end applications using the three same folders: app, domain and infrastructure, but the meaning of these three folders are completely different:

  • app: Contains entry points to the application. Usually have subfolders like "rest", "soap", "graphql", "websocket", "mvc", "console". It handles the peculiarities of the entry point technology and delegates the busines logic to domain.

  • domain: All the business logic goes here, including SQL queries, web-services calls, business rules, etc. Inspired by GraphQL, the two entry points are a "queries" and "mutations" subfolder, each class handling a use-case.

  • infrastructure: Code that is reusable and not related to the business logic and that can be copied to another application without any changes. Things like JSON formatter, SQL generator, etc.

 

I tend to favor feature oriented structures... A feature may consider of components, state, actions, API interactions, etc. It doesn't need to be all of them. You can also refer to those parts of other features.

It's more important to be discoverable than to separate different types of code into similar trees.

code of conduct - report abuse