Overview
Node Blueprint generates a well-organized project structure that follows modern Node.js best practices. The structure is designed to be scalable, maintainable, and follows separation of concerns principles.Directory Structure
Here’s the complete directory structure generated by Node Blueprint:The exact structure varies based on your selected options (framework, ORM, authentication).
Core Directories
src/
The main source directory containing all application code.
src/config/
Configuration files for various aspects of your application:
env.ts- Environment variable configuration and validationcors.ts- CORS policy configuration (Express)logger.ts- Winston logger configuration (Express)db.ts- Database connection setup (Mongoose)
src/controllers/
Request handlers that process incoming requests and return responses:
health-controller.ts- Health check endpointsuser-controller.ts- User-related request handlersauth-controller.ts- Authentication endpoints (if JWT auth enabled)
src/routes/
Route definitions that map URLs to controllers:
health-routes.ts- Health check routesuser-routes.ts- User management routesauth-routes.ts- Authentication routes (if JWT auth enabled)
src/middlewares/
Express middleware functions:
cors-middleware.ts- CORS handlingerror-middleware.ts- Global error handlinghelmet-middleware.ts- Security headers
src/services/
Business logic and data access layer:
auth-services.ts- Authentication and authorization logic (if JWT auth enabled)
src/validations/
Request validation schemas:
auth-validations.ts- Authentication request validators (if JWT auth enabled)
src/enums/
TypeScript enumerations for type-safe constants:
role-enum.ts- User role definitionstoken-enum.ts- Token type definitions (if JWT auth enabled)
Database-Specific Structure
Drizzle ORM
When using Drizzle, these files are generated:Prisma ORM
When using Prisma, these files are generated:Mongoose ORM
When using Mongoose, these files are generated:Root Files
src/app.ts
The Express application setup file. This is where:
- Middleware is configured
- Routes are registered
- Error handling is set up
- View engine is configured
src/server.ts
The server entry point that:
- Loads environment variables
- Creates the HTTP server
- Connects to the database
- Starts listening on the configured port
- Handles graceful shutdown
src/router.ts
The main router that aggregates all route modules.
Configuration Files
.env
Environment variables for different configurations:
Never commit
.env files to version control. Use .env.example for documentation.tsconfig.json
TypeScript compiler configuration optimized for Node.js development.
.gitignore
Pre-configured to ignore:
node_modules/.envfiles- Build output
- Log files
- IDE configurations
Docker Support
If Docker is enabled, these files are generated:Dockerfile- Multi-stage Docker build configurationdocker-compose.yml- Docker Compose setup with database services.dockerignore- Files to exclude from Docker context
Best Practices
- Keep related code together - Group files by feature when your project grows
- Use absolute imports - Configure path aliases in
tsconfig.jsonfor cleaner imports - Separate concerns - Controllers handle HTTP, services handle business logic, models handle data
- Type everything - Leverage TypeScript’s type system for better code quality
- Environment-specific configs - Use
.envfiles for different environments