# Node Express Boilerplate: architecture diagram of hagopj13/node-express-boilerplate

> A starter REST API for Node.js: it gives a new project user sign-up, login with tokens, email verification and password reset, and user management out of the box, backed by a MongoDB database. It also ships a small command that copies the starter into a new project.

- Repository: https://github.com/hagopj13/node-express-boilerplate/tree/179ae84efec61b14206d0305d941daed6c6d07f9
- Commit: 179ae84efec61b14206d0305d941daed6c6d07f9
- Interactive map: https://repoladder.com/hagopj13/node-express-boilerplate/179ae84efec61b14206d0305d941daed6c6d07f9
- Built: 2026-11-05 with RepoLadder 0\.0.0+core.6dd7643f72a5131154161002db629f0b09925488

## Components

### Web API

Receives requests from apps and browsers, checks who is asking and whether the input is valid, and sends back answers.

backend. 15 files, 874 lines.

- **Routes**: The URL map for version 1 of the API: auth, users and the interactive API docs. (4 files)
  - Files: `src/routes/v1/auth.route.js`, `src/routes/v1/docs.route.js`, `src/routes/v1/index.js`, `src/routes/v1/user.route.js`
- **Input checks**: Joi schemas that reject malformed request bodies, params and queries before they reach the handlers. (4 files)
  - Files: `src/validations/auth.validation.js`, `src/validations/custom.validation.js`, `src/validations/index.js`, `src/validations/user.validation.js`
- **Guards & errors**: Express middleware for JWT auth and role checks, rate limiting on auth routes, validation, and turning errors into JSON responses. (4 files)
  - Files: `src/middlewares/auth.js`, `src/middlewares/error.js`, `src/middlewares/rateLimiter.js`, `src/middlewares/validate.js`
- **Handlers**: Thin request handlers that call the services and shape the HTTP response. (3 files)
  - Files: `src/controllers/auth.controller.js`, `src/controllers/index.js`, `src/controllers/user.controller.js`

### Accounts & tokens

The actual rules: registering and finding users, issuing and checking login and reset tokens, and sending account emails.

backend. 5 files, 351 lines.

- Files: `src/services/auth.service.js`, `src/services/email.service.js`, `src/services/index.js`, `src/services/token.service.js`, `src/services/user.service.js`

### Database records

Mongoose models for users and tokens, plus plugins that add paging and clean JSON output.

backend. 6 files, 228 lines.

- Files: `src/models/index.js`, `src/models/plugins/index.js`, `src/models/plugins/paginate.plugin.js`, `src/models/plugins/toJSON.plugin.js`, `src/models/token.model.js`, `src/models/user.model.js`

### Server setup

Starts the server, wires Express with security middleware and Passport, loads settings from the environment, and defines API docs and logging.

backend. 9 files, 250 lines.

- Files: `src/app.js`, `src/config/config.js`, `src/config/logger.js`, `src/config/morgan.js`, `src/config/passport.js`, `src/config/roles.js`, `src/config/tokens.js`, `src/docs/swaggerDef.js`, `src/index.js`

### Shared helpers

Small helpers used everywhere: an API error type, an async wrapper for handlers, and object picking.

backend. 3 files, 33 lines.

- Files: `src/utils/ApiError.js`, `src/utils/catchAsync.js`, `src/utils/pick.js`

### Project generator

The create-nodejs-express-app command that clones this starter into a new folder.

backend. 1 file, 97 lines.

- Files: `bin/createNodejsApp.js`

## Connections

### Top rung

- Web API → Shared helpers: 8 imports
- Web API → Server setup: 5 imports
- Accounts & tokens → Server setup: 5 imports
- Accounts & tokens → Database records: 3 imports
- Server setup → Web API: 3 imports
- Database records → MongoDB: 2 uses
- Accounts & tokens → Web API: 2 calls
- Web API → MongoDB: 1 uses
- Accounts & tokens → Email provider: 1 uses
- Server setup → MongoDB: 1 uses
- Accounts & tokens → Shared helpers: 3 imports (minor)
- Web API → Accounts & tokens: 2 imports (minor)
- Database records → Server setup: 2 imports (minor)
- Server setup → Database records: 1 imports (minor)
- Server setup → Shared helpers: 1 imports (minor)

### Web API

- Handlers → Shared helpers: 4 imports
- Guards & errors → Shared helpers: 4 imports
- Routes → Guards & errors: 4 imports
- Guards & errors → Server setup: 3 imports
- Routes → Handlers: 2 imports
- Routes → Input checks: 2 imports
- Accounts & tokens → Routes: 2 calls
- Guards & errors → MongoDB: 1 uses
- Handlers → Accounts & tokens: 2 imports (minor)
- Routes → Server setup: 2 imports (minor)
- Server setup → Guards & errors: 2 imports (minor)
- Server setup → Routes: 1 imports (minor)

## Outside services

- **Email provider** (email): sends email
- **MongoDB** (database): database

---

Generated by RepoLadder from the same model as the interactive map. Machine-readable: https://repoladder.com/hagopj13/node-express-boilerplate/179ae84efec61b14206d0305d941daed6c6d07f9/map.json
