My question is not about codes properly, but about how to better organize project files.
I know this is an issue that does not have a right answer, nor does it have the best answer. But as I am developing a project now where I am encountering various areas and functions, I would like to know of you the tips or guidelines you can give to improve this organization and not get lost amid so many files in the future.
I currently have an organization in this style:
-js //Arquivos Js necessários para rodar o app
--angular.min.js
--angular-animate.min.js
--angular-local-storage.min.js
--angular-touch.min.js
--oc-lazyload.min.js
--ui-router.min.js
-App //escrito por eu mesmo
--controller - todos os controllers
--directives - todos os directives
--factory - todas as factorys
--app.js - configurações principais (router, filter, config)
-Lib //modulo de terceiros
--ngMask.min.js
--ngTooltip.min.js
--ngMap.min.js
-- [..etc..]
However, after some classes I learned more about modulating the code and I was also able to do lazyload
of files. That is, a lot of the code I have, I will be able to segment according to the area. For example:
Currently my webApp
has 3 different areas:
- User: Anyone who signs up for the site;
- Moderators / Attendants: people who service, check, handle some restricted areas of the company;
- Administrators: Control sales flow, reports, etc.
For this I am thinking of using lazyload
, to improve the security and speed of webApp
, since I will only load the module that is really necessary for that determined view
. But that's where things start to complicate.
In a quick structural outline I wrote, this was the framework I got:
-App //escrito por eu mesmo
--Controller
---ctrl-admin.js
---ctrl-empresa.js
---ctrl-comum.js
--Directive
---dire-admin.js
---dire-empresa.js
---dire-comum.js
--Factory
---fact-admin.js
---fact-empresa.js
---fact-comum.js
--Config
---config.js
--app.js //config da rota, autenticação, etc.
-Lib
--main //Arquivos Js necessários para rodar o app
---angular.min.js
---angular-animate.min.js
---angular-local-storage.min.js
---angular-touch.min.js
---oc-lazyload.min.js
---ui-router.min.js
--modulos //lib de terceiros, secundárias (tooltip, ngImago, etc.)
---main //principais - comum a todos - (escritas por eu mesmo)
----ngLogin.min.js //processa login
----ngCart.min.js //carrinho de compras
----ngAlert.min.js //notificação de pedidos, mensagens, novo ticket, etc.
---sec //secundarias - modular - (de terceiros)
----ngMap.js - somente carrega em view X
----ngMask.js - somente carrega em view Y
----ngTooltip.js - somente carrega em view Y, view Z
[.. etc ..]
As you can see, this structure starts to get a bit 'messy' and you have to be very careful because I can start losing myself, especially since some of these files (or a large majority) will have to pass concat
.
And it needs to be separate because, for example, the files uglify
, ctrl-admin
and dire-admin
, will only be loaded in the views for administrators (controlled by fact-admin
).
Would you have any suggestions? ocLazyLoad
? Suggestion or any guide that I can study and improve this structure?