Project Structure Examples
Examples for organizing your Mendix project with folders and modules.
Creating Multi-Level Folder Structure
This example demonstrates how to create a comprehensive folder hierarchy in your Mendix module. It creates a three-level folder structure following common architectural patterns like domain-driven design with separate layers for domain logic, application logic, and touchpoints.
// Create a multi-level folder structure
const { projects } = studioPro.app.model;
const module = await projects.getModule('MySecondModule');
// Level 1: Main folders
const domainFolder = await projects.addFolder(module.$ID, 'Domain');
const appFolder = await projects.addFolder(module.$ID, 'App');
const touchpointFolder = await projects.addFolder(module.$ID, 'Touchpoint');
log(`✅ Created level 1 folders: Domain, App, Touchpoint`);
// Level 2: Domain subfolders
const customerFolder = await projects.addFolder(domainFolder.$ID, 'Customer');
const energyConnectionFolder = await projects.addFolder(domainFolder.$ID, 'EnergyConnection');
const meterReadingFolder = await projects.addFolder(domainFolder.$ID, 'MeterReading');
log(`✅ Created level 2 folders: Domain/Customer, Domain/EnergyConnection, Domain/MeterReading`);
// Level 2: App subfolders
const appCustomerFolder = await projects.addFolder(appFolder.$ID, 'Customer');
const appEnergyConnectionFolder = await projects.addFolder(appFolder.$ID, 'EnergyConnection');
const appMeterReadingFolder = await projects.addFolder(appFolder.$ID, 'MeterReading');
log(`✅ Created level 2 folders: App/Customer, App/EnergyConnection, App/MeterReading`);
// Level 2: Touchpoint subfolders
const touchpointCustomerFolder = await projects.addFolder(touchpointFolder.$ID, 'Customer');
const touchpointEnergyConnectionFolder = await projects.addFolder(touchpointFolder.$ID, 'EnergyConnection');
const touchpointMeterReadingFolder = await projects.addFolder(touchpointFolder.$ID, 'MeterReading');
log(`✅ Created level 2 folders: Touchpoint/Customer, Touchpoint/EnergyConnection, Touchpoint/MeterReading`);
// Level 3: Domain/Customer subfolders (FTN, GET, OPR, VAL)
const customerFTNFolder = await projects.addFolder(customerFolder.$ID, 'FTN');
const customerGETFolder = await projects.addFolder(customerFolder.$ID, 'GET');
const customerOPRFolder = await projects.addFolder(customerFolder.$ID, 'OPR');
const customerVALFolder = await projects.addFolder(customerFolder.$ID, 'VAL');
log(`✅ Created level 3 folders: Domain/Customer/FTN, GET, OPR, VAL`);
// Level 3: Domain/EnergyConnection subfolders (FTN, GET, OPR, VAL)
const energyConnectionFTNFolder = await projects.addFolder(energyConnectionFolder.$ID, 'FTN');
const energyConnectionGETFolder = await projects.addFolder(energyConnectionFolder.$ID, 'GET');
const energyConnectionOPRFolder = await projects.addFolder(energyConnectionFolder.$ID, 'OPR');
const energyConnectionVALFolder = await projects.addFolder(energyConnectionFolder.$ID, 'VAL');
log(`✅ Created level 3 folders: Domain/EnergyConnection/FTN, GET, OPR, VAL`);
// Level 3: Domain/MeterReading subfolders (FTN, GET, OPR, VAL)
const meterReadingFTNFolder = await projects.addFolder(meterReadingFolder.$ID, 'FTN');
const meterReadingGETFolder = await projects.addFolder(meterReadingFolder.$ID, 'GET');
const meterReadingOPRFolder = await projects.addFolder(meterReadingFolder.$ID, 'OPR');
const meterReadingVALFolder = await projects.addFolder(meterReadingFolder.$ID, 'VAL');
log(`✅ Created level 3 folders: Domain/MeterReading/FTN, GET, OPR, VAL`);
log(`🎉 Complete folder structure created!`);Folder Structure Created
This example creates the following hierarchy:
MySecondModule/
├── Domain/
│ ├── Customer/
│ │ ├── FTN/
│ │ ├── GET/
│ │ ├── OPR/
│ │ └── VAL/
│ ├── EnergyConnection/
│ │ ├── FTN/
│ │ ├── GET/
│ │ ├── OPR/
│ │ └── VAL/
│ └── MeterReading/
│ ├── FTN/
│ ├── GET/
│ ├── OPR/
│ └── VAL/
├── App/
│ ├── Customer/
│ ├── EnergyConnection/
│ └── MeterReading/
└── Touchpoint/
├── Customer/
├── EnergyConnection/
└── MeterReading/Key Concepts
Folder Hierarchy:
- Use
projects.addFolder(parentId, name)to create folders - First parameter is the parent container ID (module or folder)
- Folders can be nested to any depth
Architectural Patterns:
- Domain - Core business logic and domain models
- App - Application layer coordinating business processes
- Touchpoint - User interface and external integrations
Domain Subfolders:
- FTN - Functions (utility microflows)
- GET - Retrieve operations
- OPR - Operations (create, update, delete)
- VAL - Validation logic