- The Express generator creates a familiar skeleton.
- There's no consensus on the right structure (e.g. 1, 2) but it doesn't matter from the framework's point of view.
- The project is structured as described here. The main idea is similar to Angular's generator: organize around features, not roles. Additionally:
- business logic is stored in an
app
folder - the
routes
folder is removed from the project root and instead routes are defined in their corresponding components
- business logic is stored in an
.
├── app
│ ├── errors
│ │ └── record-already-exists-error.js
│ ├── db
│ │ └── user
│ │ ├── user.js
│ │ └── user.test.js
│ ├── payments
│ │ ├── payments.js
│ │ ├── payments.routes.js
│ │ ├── payments.test.js
│ │ └── index.js
│ ├── users
│ │ ├── users.js
│ │ ├── users.routes.js
│ │ ├── users.test.js
│ │ └── index.js
│ └── utils
│ └─── response-parser
│ ├── response-parser.js
│ ├── response-parser.test.js
│ └── index.js
├── app.js
├── config
│ └── external-service-config.js
├── doc
│ └── mvp-proposal.md
├── COPYRIGHT.txt
├── package.json
├── README.md
Folder and files names use kebab-case
- e.g.
dummy-model
Classes use UpperCamelCase
- e.g.
DummyClass
Functions, variables and any others use lowerCamelCase
- e.g.
fetchData
config
- Configuration files.
- Usually JSON structured files or exported constants/functions.
app/db
- Database definitions.
- Schemas, models.
app/utils
- Reusable, generic purpose functions.
- Files are grouped by functionality (components) in folders.
- Each component should contain its related files.
- Files can be logically groupped into more folders (e.g.
external/users
andinternal/users
).