
Next.js App/
├── node_modules/
├── public/
│ ├── favicon.ico
│ ├── images/
│ └── ...
├── src/
│ ├── app/
│ │ ├── (dashboard)
│ │ │ ├── layout.tsx
│ │ │ └── page.tsx
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── [slug]/
│ │ │ └── page.tsx
│ │ └── ...
│ ├── assets/
│ │ ├── svg/
│ │ ├── images/
│ │ └── ...
│ ├── components/
│ │ ├── ui/
│ │ │ ├── Button.tsx
│ │ │ ├── Input.tsx
│ │ │ └── Box.tsx
│ │ ├── layout/
│ │ │ ├── Navbar.tsx
│ │ │ └── Footer.tsx
│ │ └── page/
│ │ │ ├── DashboardHeader.tsx
│ │ │ └── HomePageServices.tsx
│ │ │ │ └── HomePageService.tsx
│ ├── lib/
│ │ ├── types.ts
│ │ └── utils.ts
│ ├── store/
│ │ ├── slices/
│ │ │ ├── authSlice.ts
│ │ │ └── userSlice.ts
│ │ ├── store.ts
│ │ └── types.ts
│ ├── styles/
│ │ └── custom.css
│ └── hooks/
│ │ ├── useAuth.ts
│ │ └── ...
├── eslint.config.mjs
├── next.config.ts
├── next-env.d.ts
├── package.json
├── postcss.config.mjs
├── README.md
└── tsconfig.jsonThis guide is here to help you understand the purpose of each folder and how to use them effectively in our front-end app, mainly for Next.js app. Let’s follow these conventions to keep our codebase centralized and scalable!.
- Purpose: Stores static files like images, favicon, and other assets served directly by Next.js.
- Usage: Add
favicon.ico,images/for media, and other static resources. Reference them with/filenamein your code.
- Purpose: Contains pages and layouts using Next.js.
- Usage:
layout.tsx: Define the root layout for the app or dashboard (e.g.,(dashboard)/layout.tsx).page.tsx: Create individual pages (e.g.,page.tsxfor home,[slug]/page.tsxfor dynamic routes).- Use subdirectories like
(dashboard)for feature-specific apps or sections.
- Purpose: Holds static assets like SVG icons and images.
- Usage:
svg/: Store SVG components (e.g.,Moon.tsx).images/: Place dynamic images or media files. Import or reference as needed in components.
- Purpose: Houses reusable UI components.
- Usage:
ui/: Generic components likeButton.tsx,Input.tsxfor universal use.layout/: Layout-specific components likeNavbar.tsx,Footer.tsx.page/: Page-specific components likeDashboardHeader.tsxorHomePageServices.tsx(with childHomePageService.tsx).
- Purpose: Contains utility functions, constants, and modules.
- Usage:
types.ts: Define shared TypeScript types and interfaces.utils.ts: Add utility functions (e.g.,formatDate,generateSlug).
- Purpose: Manages Redux state logic.
- Usage:
slices/: Create feature-specific slices (e.g.,authSlice.ts,userSlice.ts).store.ts: Configure the Redux store.types.ts: Define Redux-specific types.
- Purpose: Stores global and custom styles with Tailwind CSS.
- Usage:
custom.css: Add custom utility classes if needed.
- Purpose: Contains custom React hooks.
- Usage: Create hooks like
useAuth.tsfor reusable stateful logic.
- Follow the folder structure for consistency.
- Add new components to
components/with appropriate subfolders. - Use
lib/for reusable utilities andstore/for state management. - Document changes in
README.mdand update types inlib/types.tsas needed. - Avoid cluttering
app/with non-page files; use subdirectories for organization.
This structure ensures a centralized workflow, making it easy for your team to collaborate and scale the app.