DEV Community

Discussion on: Folder Structure and Frameworks: What is exerting control?

Collapse
 
renatodinhani profile image
Renato Dinhani • Edited

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.