Project Structure
Unanswered
DoyteDoyenr posted this in #help-forum
Hello everyone, lately I've been bothered by the lack of centralization, like a repository, in my applications. I also want to add SOLID principles to this Next.js back-end. What do you guys think? Or do you think that this wouldn't really be the main focus of Next.js?
2 Replies
Bengal
You can architect your Next.js project to loosely follow SOLID principles. Chances are most projects already are somewhat following some of the principles just by using infered types, SRP components, open/closed principle with ReactNode props or just props in general.
As for the Repository (and Service) layers, I always recommend having a data access layer. Whether that be one layer that does everything or you split it up into a repository + service layers (database + business logic) is up to however people prefer. You can split it up into however many layers you want.
The Next.js team also recommends using a DAL https://nextjs.org/blog/security-nextjs-server-components-actions#data-access-layer
As for the Repository (and Service) layers, I always recommend having a data access layer. Whether that be one layer that does everything or you split it up into a repository + service layers (database + business logic) is up to however people prefer. You can split it up into however many layers you want.
The Next.js team also recommends using a DAL https://nextjs.org/blog/security-nextjs-server-components-actions#data-access-layer
I see, but besides this approach, isn’t there any other pattern? I feel that it would be interesting to centralize the actions like create, update, etc., in a class, already incorporating the SOLID principles, such as dependency inversion and so on... Of course, this would be for specific projects.