Folder Structure
NeatNode provides different folder structures for JavaScript and TypeScript templates, each optimized for clarity and scalability.
JavaScript Templates — Typical Structure
Used by Basic (JS), REST API (JS), and Socket.IO (JS) templates.
<project-root>/
├── package.json
├── server.js
└── src/
├── app.js
├── config/
├── controllers/
├── models/
├── routes/
├── services/
├── middleware/
└── utils/This structure follows a layer-based architecture, separating concerns clearly.
JavaScript Template Folders /src
controllers/
Request handlers mapped to routes.
routes/
Defines API endpoints.
services/
Business logic and database interactions.
models/
Mongoose schemas or DB models.
middleware/
Auth, validation, and error handling.
utils/
Shared helpers like ApiError, ApiResponse, CatchAsync.
TypeScript Templates — Module-Based Structure
Used by Basic (TS) and all upcoming TypeScript templates.
<project-root>/
├── package.json
├── tsconfig.json
├── src/
│ ├── app.ts
│ ├── server.ts
│ ├── config/
│ ├── modules/
│ │ └── user/
│ │ ├── user.controller.ts
│ │ ├── user.service.ts
│ │ ├── user.route.ts
│ │ ├── user.model.ts
│ │ └── user.types.ts
│ ├── middleware/
│ └── utils/
└── dist/Each module owns its logic, making large codebases easier to scale and maintain.
Root Files
| File | Purpose |
|---|---|
| package.json | Dependencies and scripts |
| server.js / server.ts | Application entry point |
| app.js / app.ts | Express configuration |
| tsconfig.json | TypeScript compiler configuration |
| .env / .env.example | Environment variables |
TypeScript Template Folders /src
modules/
Feature-based modules. Each module contains its own controller, service, routes, and model.
Example:
modules/user/
├── user.controller.ts
├── user.service.ts
├── user.route.ts
├── user.model.ts
└── user.types.tsconfig/
Database, logger, environment setup.
middleware/
Typed middleware (auth, validation, errors).
utils/
Typed helpers, error classes, response wrappers.
Template Variations
| Template | Structure Type | Notes |
|---|---|---|
| Basic (JS) | Layer-based | Minimal Express setup |
| REST API (JS) | Layer-based | Auth + validation |
| Socket.IO (JS) | Layer-based | Adds socket config |
| Basic (TS) | Module-based | Strict typing |
| REST API (TS) | Module-based | (Coming soon) |
| Socket.IO (TS) | Module-based | (Coming soon) |
Extending the Structure
You can safely add new folders in both JS and TS templates:
src/
┣ jobs/ # Background jobs
┣ validators/ # Custom schema validation
┗ scripts/ # Seeding or CLI scriptsRequest Flow Comparison
JavaScript (Layer-Based)
Route → Controller → Service → Model → ResponseTypeScript (Module-Based)
Route → Controller → Service → Model → Response
(all inside one module)✅ Summary
- JS templates → layer-based structure
- TS templates → module-based structure
- Same concepts, different organization
- Easy to scale, easy to understand
[!TIP] Once you understand one template, switching between JS and TS is straightforward.