Project Templates

Understanding the different project structures and templates generated by Kickstart Express.

Template Overview

Kickstart Express generates different project structures based on your configuration choices. Each template is designed for specific use cases and development preferences.

Simple Structure

The simplest template with minimal configuration. Perfect for quick prototypes and learning.

JavaScript Simple

kickstart-express --name simple-js --language js

Generated Structure:

simple-js/
├── index.js              # Main server file
├── package.json          # Dependencies and scripts
├── .env                  # Environment variables
├── .gitignore           # Git ignore rules
└── README.md            # Project documentation

TypeScript Simple

kickstart-express --name simple-ts --language ts

Generated Structure:

simple-ts/
├── src/
│   └── index.ts         # Main server file
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
├── .env                 # Environment variables
├── .gitignore          # Git ignore rules
└── README.md           # Project documentation

Src Folder Structure

Organized structure with dedicated src folder. Better for medium-sized projects.

kickstart-express --name organized-project --language ts --src

Generated Structure:

organized-project/
├── src/
│   └── index.ts         # Main application file
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
├── .env                 # Environment variables
├── .gitignore          # Git ignore rules
└── README.md           # Project documentation

Key Features:

  • Clean separation of source code
  • Better organization for growing projects
  • Easy to maintain and understand
  • Standard practice in modern Node.js development

Structured Architecture

Enterprise-ready structure with separation of concerns. Perfect for larger applications and teams.

kickstart-express --name enterprise-api --language ts --structured

Generated Structure:

enterprise-api/
├── src/
│   ├── controllers/
│   │   └── calculator.controller.ts    # Request handlers
│   ├── routes/
│   │   └── calculator.route.ts         # Route definitions
│   ├── services/
│   │   └── calculator.service.ts       # Business logic
│   ├── models/
│   │   └── calculation.model.ts        # Data models/types
│   └── index.ts                        # Main application file
├── package.json                        # Dependencies and scripts
├── tsconfig.json                       # TypeScript configuration
├── .env                               # Environment variables
├── .gitignore                         # Git ignore rules
└── README.md                          # Project documentation

Architecture Components:

Controllers

Handle HTTP requests and responses. Manage request validation, call services, and format responses.

// calculator.controller.ts
export class CalculatorController {
  add(req: Request, res: Response) {
    // Handle add operation
  }
}

Routes

Define API endpoints and middleware. Connect URLs to controller methods.

// calculator.route.ts
router.post('/add', calculatorController.add);
router.get('/', calculatorController.getInfo);

Services

Contain business logic, data processing, and external API calls.

// calculator.service.ts
export class CalculatorService {
  add(a: number, b: number): number {
    return a + b;
  }
}

Models

Define data structures, interfaces, and type definitions.

// calculation.model.ts
export interface CalculationRequest {
  a: number;
  b: number;
}

export interface CalculationResponse {
  result: number;
}

Sample API:

The structured template includes a working calculator API:

# Get API info
GET /api/calculator
Response: { "message": "Calculator API is working!" }

# Add two numbers
POST /api/calculator/add
Body: { "a": 5, "b": 3 }
Response: { "result": 8 }

Docker Templates

Any template can include Docker configuration for containerized deployment.

kickstart-express --name docker-api --language ts --docker --structured

Additional Docker Files:

docker-api/
├── Dockerfile              # Container definition
├── docker-compose.yml      # Service composition
├── .dockerignore          # Docker ignore rules
├── src/                   # Application code
└── ...                    # Other project files

Dockerfile Features:

  • Multi-stage build for optimized production images
  • pnpm integration for fast dependency installation
  • Non-root user for security
  • Proper layer caching for faster builds

Docker Compose Features:

  • Development and production configurations
  • Volume mounting for live development
  • Environment variable management
  • Health checks and restart policies

Template Comparison

FeatureSimpleSrc FolderStructured
ComplexityLowMediumHigh
Learning CurveEasyEasyMedium
ScalabilityLimitedGoodExcellent
Team ProjectsSmallMediumLarge
Code OrganizationBasicGoodExcellent
Best ForPrototypes, LearningSmall to Medium AppsEnterprise, Large Apps

Generated Code Examples

Simple Template - index.ts

import express from 'express';
               import cors from 'cors';
                import dotenv from 'dotenv';
                 dotenv.config();
                  const app = express();
                  const PORT = process.env.PORT || 3000;

                  // Middleware
                  app.use(cors());
                  app.use(express.json());

                  // Routes
                  app.get('/', (req, res) => {
                    res.json({ message: 'Hello from Express!' });
                  });

                  app.listen(PORT, () => {
                    console.log("Server running on port", PORT);}");
                  });

Structured Template - Controller

import { Request, Response } from 'express';
import { CalculatorService } from '../services/calculator.service';
import { CalculationRequest } from '../models/calculation.model';

export class CalculatorController {
  private calculatorService: CalculatorService;

  constructor() {
    this.calculatorService = new CalculatorService();
  }

  public getInfo = (req: Request, res: Response): void => {
    res.json({ message: 'Calculator API is working!' });
  };

  public add = (req: Request, res: Response): void => {
    try {
      const { a, b }: CalculationRequest = req.body;
      const result = this.calculatorService.add(a, b);
      res.json({ result });
    } catch (error) {
      res.status(400).json({ error: 'Invalid input' });
    }
  };
}

Choosing the Right Template

✅ Use Simple Template When:

  • Learning Express.js fundamentals
  • Building quick prototypes or demos
  • Creating simple APIs with few endpoints
  • Working solo on small projects

✅ Use Src Folder Template When:

  • Building medium-sized applications
  • Working with a small team
  • Want better organization than simple but not full structure
  • Planning to grow the project over time

✅ Use Structured Template When:

  • Building enterprise or production applications
  • Working with large teams
  • Need clear separation of concerns
  • Planning complex business logic
  • Want to follow industry best practices

✅ Add Docker When:

  • Deploying to containerized environments
  • Working with microservices architecture
  • Need consistent development environments
  • Planning to use orchestration platforms (Kubernetes, Docker Swarm)