Folder Structure
1. Layer-based Structure (by type of file)
project-root/
├─ controllers/
│ ├─ userController.js
│ └─ authController.js
├─ models/
│ ├─ user.js
│ └─ order.js
├─ routes/
│ ├─ userRoutes.js
│ └─ authRoutes.js
├─ services/
│ ├─ emailService.js
│ └─ paymentService.js
├─ utils/
│ └─ logger.js
├─ config/
│ └─ dbConfig.js
├─ constants/
│ ├─ roles.js
│ └─ paymentStatus.js
├─ app.js
└─ package.json2. Feature-based Structure (by feature/module)
3. Hybrid Structure (recommended for real-world apps)
Tips for All Structures
Last updated