How to use the Node.js Project Structure Generator
- 1. Name the projectUse lowercase letters and hyphens, like student-api.
- 2. Pick optionsJavaScript or TypeScript, database, tests, ESLint and Docker.
- 3. Download the ZIPUnzip, run npm install, copy .env.example to .env and npm run dev.
The structure explained
The skeleton separates responsibilities, the way most professional Node.js teams do:
routes/map URLs to controller functions.controllers/read the request and send the response.services/hold business logic, so it can be tested without HTTP.models/hold database schemas (created for MongoDB or PostgreSQL).middlewares/hold shared steps like the error handler.config/holds settings such as the database connection.
app.js builds the Express app and server.js starts it. Keeping them apart lets tests import the app without opening a port. Secrets go in .env, which is in .gitignore; .env.example shows which variables are needed.
Worked example
The defaults (student-api, JavaScript, CommonJS, MongoDB, tests on) give 11 files in 9 folders, with 3 dependencies (express, dotenv and mongoose) and 2 dev dependencies (jest and supertest). Empty folders like services/ and utils/ hold a .gitkeep file so Git keeps them. The health route works straight away:
npm install
cp .env.example .env
npm run dev
# open http://localhost:3000/api/healthnpm test runs a Supertest check that /api/health returns status ok. The dev script uses node --watch, built into Node 18.11+, so there is no need for nodemon. Choosing TypeScript adds tsconfig.json and uses tsx for development and tsc for the build.
Frequently asked questions
Which Node.js version do I need?
Node 18 or newer. Node 22 LTS is a good choice for new projects.
Are the package versions current?
They are recent versions with ^ ranges, so npm install picks the newest compatible release. Check npm for major updates now and then.
Is this the only right structure?
No, but routes, controllers, services and models is a widely used, easy-to-follow pattern for REST APIs.
Is the node.js project structure generator free?
Yes, it is free. Downloading your first project asks for your name and WhatsApp number once. After that, the node.js project structure generator and every other Uncodemy tool open with no form.