This plugin for Visual Paradigm automates the creation of a TypeScript back-end service. It analyzes the active ER diagram to identify entities and relationships and generates a REST API using Express and TypeORM. The generated service is compatible with databases such as MSSQL, MySQL, and PostgreSQL.
- Entity Analysis: Scans the ER diagram for entities and their relationships.
- TypeScript Code Generation: Generates TypeORM entities and their mappings.
- Express API Creation: Builds RESTful APIs for the entities, including CRUD operations.
- Database Compatibility: Tested with MSSQL, MySQL, and PostgreSQL.
- Customizable Output: Allows directory selection for saving the generated code.
- Visual Paradigm (latest version recommended)
- Node.js (version 16 or later)
- TypeScript
- TypeORM
- Supported database (MSSQL, MySQL, PostgreSQL)
-
Clone this repository or download the plugin file.
-
Open Visual Paradigm
-
Navigate to the Help tab in the top menu and select Install Plugin.
-
In the Install Plugin dialog box, choose one of the following options:
- Install from a zip of plugin: Select this if you have the plugin packaged as a
.zip
file. - Install from a folder of plugins: Use this if you have the plugin extracted into a folder.
- Manually copy the plugin folder(s) to the following directory: Copy the plugin files to the directory shown in the dialog box (e.g.,
C:\Users\<YourUser>\AppData\Roaming\VisualParadigm\plugins
).
- Install from a zip of plugin: Select this if you have the plugin packaged as a
-
After selecting the appropriate option, click Next and follow the on-screen instructions.
-
Once the installation is complete, restart Visual Paradigm to activate the plugin.
- Open Visual Paradigm and load your ER diagram.
- Activate the plugin from the Plugins menu.
- Select the desired output directory for the generated code.
- The plugin will generate:
- TypeScript files for each entity and their relationships.
- RESTful API endpoints using Express.
- Database configuration using TypeORM.
- A postman collection containing sample requests for every endpoint exposed by the api.
Here’s an example structure of the generated project:
project/
├── src/
│ ├── controllers/
│ │ ├── DataprovidersController.ts
│ │ ├── ForecastsourcesController.ts
│ │ ├── LocationGenericController.ts
│ │ ├── MeasurementStationController.ts
│ │ ├── MeteoForecastsController.ts
│ │ ├── MeteoObservationsController.ts
│ │ ├── MeteoObservationSourcesController.ts
│ │ ├── MeteoStationOperatorsController.ts
│ │ ├── NGPointsPlaceholderController.ts
│ │ ├── PhysicalQuantitiesController.ts
│ │ ├── PhysicalQuantityAliasesController.ts
│ │ ├── ResolutionCodeController.ts
│ │ ├── RESStationGroupController.ts
│ │ ├── UnitsOfMeasurementAliasesController.ts
│ │ └── UnitsOfMeasurementController.ts
│ ├── entities/
│ │ ├── DataProviders.ts
│ │ ├── ForecastSources.ts
│ │ ├── LocationGeneric.ts
│ │ ├── MeasurementStation.ts
│ │ ├── MeteoForecasts.ts
│ │ ├── MeteoObservations.ts
│ │ ├── MeteoObservationSources.ts
│ │ ├── MeteoStationOperators.ts
│ │ ├── NGPoints_Placeholder.ts
│ │ ├── PhysicalQuantities.ts
│ │ ├── PhysicalQuantityAliases.ts
│ │ ├── ResolutionCode.ts
│ │ ├── RESStationGroup.ts
│ │ ├── UnitsOfMeasurement.ts
│ │ └── UnitsOfMeasurementAliases.ts
│ ├── routes/
│ │ ├── DataprovidersRoutes.ts
│ │ ├── ForecastsourcesRoutes.ts
│ │ ├── LocationGenericRoutes.ts
│ │ ├── MeasurementStationRoutes.ts
│ │ ├── MeteoForecastsRoutes.ts
│ │ ├── MeteoObservationsRoutes.ts
│ │ ├── MeteoObservationSourcesRoutes.ts
│ │ ├── MeteoStationOperatorsRoutes.ts
│ │ ├── NGPointsPlaceholderRoutes.ts
│ │ ├── PhysicalQuantitiesRoutes.ts
│ │ ├── PhysicalQuantityAliasesRoutes.ts
│ │ ├── ResolutionCodeRoutes.ts
│ │ ├── RESStationGroupRoutes.ts
│ │ ├── UnitsOfMeasurementAliasesRoutes.ts
│ │ └── UnitsOfMeasurementRoutes.ts
│ ├── app.ts
│ ├── index.ts
│ ├── ormconfig.ts
│ └── typeMapper.ts
├── .env
├── Common - MeteoData_Postman_Collection.json
├── nodemon.json
├── package.json
└── tsconfig.json
To configure the API, create a .env
file in the root directory with the following structure:
# Database configuration
DB_TYPE={{DB TYPE}}
DB_HOST={{DB HOST}}
DB_PORT={{DB PORT}}
DB_USERNAME={{USERNAME}}
DB_PASSWORD={{PASSWORD}}
DB_NAME={{SCHEMA NAME}}
# Server configuration
PORT={{EXPRESS SERVER PORT}}
# Database configuration
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=your_password
DB_NAME=your_database
# Server configuration
PORT=3000
The ormconfig.ts
file reads these environment variables to configure the database connection:
const ormconfig: DataSourceOptions = {
type: process.env.DB_TYPE as 'mysql' | 'postgres' | 'mssql',
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
synchronize: true, // Automatically syncs database schema
logging: true, // Enables logging
entities: [
Resstationgroup,
Resolutioncode,
Measurementstation,
NgpointsPlaceholder,
// Add other entity classes here
],
// Additional options for specific databases
/* Use in case of MS SQL */
/*
options: {
encrypt: false, // Enables encryption
trustServerCertificate: true, // Allows self-signed certificates
},
extra: {
integratedSecurity: false, // Use for Windows Authentication
connectionTimeout: 30000,
},
*/
};
export default ormconfig;
The PORT
variable from the .env
file is used to configure the Express server's listening port.
To test the plugin:
- Load a sample ER diagram in Visual Paradigm.
- Run the plugin and inspect the generated code.
- Deploy the code locally using:
npm install npm run dev
- Access the API at
http://localhost:3000
. - Import the postman collection and test the api.