1730315066

Two best folder structures for a web application


## Structure 1 - Layered Modularization This structure is useful for medium to large projects where responsibilities are well divided. Each layer represents a part of the application (frontend, backend, config) and facilitates teamwork. ``` project-root/ │ ├── config/ │ ├── database.js │ └── server.js │ ├── src/ │ ├── controllers/ │ │ └── userController.js │ ├── models/ │ │ └── userModel.js │ ├── routes/ │ │ └── userRoutes.js │ ├── services/ │ │ └── authService.js │ └── utils/ │ └── helpers.js │ ├── public/ │ ├── css/ │ ├── images/ │ └── js/ │ ├── tests/ │ ├── controllers/ │ └── models/ │ └── index.js ``` ## <br>Structure 2 - Modularization by Functionality In this structure, the organization is done by functionality. Each module includes all the layers (controller, model, etc.) in the same directory. Ideal for projects with independent functionality. ``` project-root/ │ ├── config/ │ ├── database.js │ └── server.js │ ├── modules/ │ ├── auth/ │ │ ├── authController.js │ │ ├── authModel.js │ │ ├── authRoutes.js │ │ └── authService.js │ ├── user/ │ │ ├── userController.js │ │ ├── userModel.js │ │ ├── userRoutes.js │ │ └── userService.js │ ├── public/ │ ├── css/ │ ├── images/ │ └── js/ │ ├── tests/ │ └── modules/ │ ├── auth/ │ └── user/ │ └── index.js ``` These are the most appropriate folder structures for web applications. Try them out and let us know what you think

(7) Comments
fschmidt
fschmidt
1731471648

I just finished programming a web chat that has my typical structure. Here is the [source](https://hg.reactionary.software/repo/chat/file/tip).

amargo85
amargo85
1731474322

wow, that's interesting. how long did it take to design and program that?

fschmidt
fschmidt
1731474594

2 weeks. You can chat with me [here](https://chat.luan.software/?with=fschmidt@gmail.com). I needed this for support for a web business.

amargo85
amargo85
1731497528

i was delighted with your service mr fschmidt, and it reminds me a lot of irc. how about we open a room and in it we only open the tech, fonts and languages that require a more complex way of programming?

fschmidt
fschmidt
1731563908

What do you mean by this? The point of my tools is to make all application programming simple (not complex). My chat code is simple.

amargo85
amargo85
1731564507

yes, I mean complex for those who need tools to create things like frameworks. My way of working is very similar to yours and that's why I say that. But we can continue this conversation here in this room. [https://chat-to.dev/chat?q=General](https://chat-to.dev/chat?q=General)

fschmidt
fschmidt
1731564698

No one should create frameworks, the horror. Libs only. Anyway, make a room and send me the link and I will participate.

    vote comment 0

Welcome to Chat-to.dev, a space for both novice and experienced programmers to chat about programming and share code in their posts.

About | Privacy | Terms | Donate
[2024 © Chat-to.dev]