Business Directory Reac Folder Structure

eyewebmaster | 6 days, 13 hours ago | Reac | 7 views

Here’s a best-practice folder structure tailored for a React Business Directory:

Perfect 👍 A business directory is feature-heavy (categories, listings, reviews, etc.), so the folder structure matters even more.
For something like a directory, I’d recommend a feature-based structure (domain-driven), so everything about "businesses", "categories", and "users" stays modular.

 

src/
 assets/               # logos, icons, images
 components/           # global reusable components (UI)
   ui/
     Button.jsx
     Input.jsx
     Card.jsx
   layout/
     Header.jsx
     Footer.jsx
     Sidebar.jsx

 features/             # feature-specific folders
   businesses/         
     components/
       BusinessCard.jsx
       BusinessList.jsx
       BusinessDetail.jsx
       BusinessForm.jsx
     hooks/
       useBusiness.js          # fetch all businesses
       useBusinessDetail.js    # fetch one
     services/
       businessApi.js          # API calls (CRUD)
     pages/
       BusinessListPage.jsx
       BusinessDetailPage.jsx
       AddBusinessPage.jsx

   categories/
     components/
       CategoryList.jsx
       CategoryFilter.jsx
     services/
       categoryApi.js
     pages/
       CategoryPage.jsx

   users/
     components/
       UserProfile.jsx
       UserDashboard.jsx
       LoginForm.jsx
       RegisterForm.jsx
     services/
       userApi.js
     hooks/
       useAuth.js
     pages/
       LoginPage.jsx
       RegisterPage.jsx
       DashboardPage.jsx

   reviews/
     components/
       ReviewForm.jsx
       ReviewList.jsx
     services/
       reviewApi.js
     hooks/
       useReviews.js

 hooks/                 # shared hooks
   useFetch.js
   usePagination.js
   useDebounce.js

 services/              # global API configs
   apiInstance.js       # axios instance
   authService.js       # auth helpers

 utils/                 # helper functions
   formatDate.js
   slugify.js

 context/               # React context providers
   AuthContext.jsx
   ThemeContext.jsx

 styles/                # global styles, Tailwind, etc.
   global.css

 pages/                 # route-level pages if not inside features
   HomePage.jsx
   AboutPage.jsx
   ContactPage.jsx

 App.jsx
 main.jsx
 

Comments (0)


Login to post a comment.

No comments yet. Be the first to comment!