Previously, I used this structure:
/features/feature-1
|-- /server
| |-- /actions # server actions
| |-- /queries # database fetches with Prisma
|-- /components # reusable components for the feature
|-- /hooks # hooks for queries/mutations with react-query
|-- /lib and /utils # business logic and utilities
|-- /api # API calls used by react-query hooks
The problem I ran into was about shared business logic or utils across multiple features, since it’s not ideal to import files directly between features. To solve this, I created an /entities folder that contains all the business logic and utils for each feature, so they can be imported wherever needed—even across different features.
How do you usually handle this? If you have numerous features (10–20), each with many files (hooks, API, components, constants, server actions, server queries, etc.) and some shared code, how do you organize it?
Thanks so much for the support you’ve been giving!