Docus Logo
Getting Started

Project Structure

Learn about the project structure of Charcole.

Global structure

Charcole is a Nodejs template that reduces your effort to create the base structure and modules again and again.

When you create a new Charcole project with npx create-charcole@latest my-project, you get:

my-project/
├── src/                         # Main application source code
│   ├── app.js / app.ts          # Express app initialization
│   ├── server.js / server.ts    # Application entry point (server bootstrap)
│   │
│   ├── config/                  # Environment & app configuration
│   │   ├── env.js / env.ts
│   │   └── index.js / index.ts
│   │
│   ├── modules/                 # Feature-based modules (e.g. auth)
│   │   └── auth/
│   │       ├── auth.controller.js / .ts
│   │       ├── auth.service.js / .ts
│   │       └── auth.routes.js / .ts
│   │
│   ├── repositories/            # Database access & data-layer logic
│   │
│   ├── middlewares/             # Global & route middlewares
│   │   └── errorHandler.js / .ts
│   │
│   ├── routes/                  # Route aggregation
│   │   ├── index.js / index.ts  # Registers all application routes
│   │   └── protected.js / .ts   # Routes requiring authentication
│   │
│   ├── utils/                   # Shared utility/helper functions
│   │
│   └── types/ (TS only)         # Global TypeScript types
│
├── .env.example                 # Environment variables template
├── .gitignore
├── package.json                 # Dependencies and scripts
├── tsconfig.json (TS only)
└── README.md

JavaScript vs TypeScript

Charcole (v ≥ 2) supports both JavaScript and TypeScript out of the box.

  • JavaScript projects
    • Use .js files
    • Do not include tsconfig.json
  • TypeScript projects
    • Use .ts files
    • Include tsconfig.json
    • Provide stricter typing and better DX The folder structure remains identical for both options.