Universal CRUD Generator - Database-first code generation tool with Settings page, ORM selection, and advanced filtering
A powerful, database-first CRUD generator for Node.js applications. UCG provides an interactive CLI and web dashboard to generate models, controllers, services, and API endpoints for your database tables with comprehensive Swagger/OpenAPI documentation.
- Database-First Approach: Introspect existing databases to generate code
- Multiple Database Support: PostgreSQL, MySQL, SQLite, MongoDB
- Multiple ORM Support: Prisma, Sequelize, Mongoose adapters
- TypeScript & JavaScript: Choose your preferred language during setup
- Comprehensive Swagger Documentation: Auto-generated OpenAPI specs with examples
- Web Dashboard: Interactive UI for code generation served from node_modules
- CLI Tools: ucg init and ucg quick-setup commands
- Pluggable Architecture: Easy to add new databases and ORMs
- Modern UI: Clean, responsive dashboard with preview capabilities
- No File Pollution: Everything served from the plugin, minimal host project changes
``bash`
npm install ucg@latest
Get the latest features and improvements with comprehensive Swagger documentation:
`bash`
npm install ucg@beta
`bash`
npm install ucg@1.2.1-beta.1
| Version | Features | Database Support | TypeScript | Swagger Docs |
| -------------- | -------------------------------------------------- | ---------------------------------- | ---------- | ------------ |
| 1.2.1-beta.1 | ๐ฅ Latest - TypeScript CRUD fix + Complete Swagger | PostgreSQL, MySQL, SQLite, MongoDB | โ
Full | โ
Complete |1.2.1-beta.7
| | Complete Swagger documentation | PostgreSQL, MySQL, SQLite, MongoDB | โ | โ
Complete |1.2.1-beta.6
| | Previous beta | PostgreSQL, MySQL, SQLite, MongoDB | โ | โ ๏ธ Basic |1.2.0
| | Stable release | PostgreSQL, MySQL, SQLite, MongoDB | โ | โ Limited |
- latest - Stable releasebeta
- - Beta releases with new featuresalpha
- - Development releases
`bashInstall in your existing Node.js project
npm install ucg
$3
`bash
Create a new project with UCG pre-configured
npx ucg quick-setupFollow the prompts, then:
cd your-project-name
npm install
npm startVisit http://localhost:3000/ucg/setup
`๐ ๏ธ Usage
$3
####
ucg initAdds UCG to an existing Node.js project by mounting the router.
`bash
npx ucg init [--json] # --json for machine-readable output
`####
ucg quick-setupCreates a new Node.js project with UCG pre-configured.
`bash
npx ucg quick-setup [--json]
`$3
After running
ucg init or ucg quick-setup, these URLs will be available:-
/ucg/setup - First-time configuration wizard
- /ucg/login - Dashboard login
- /ucg/dashboard - Main dashboard with table overview
- /ucg/generate/model - Model generator
- /ucg/generate/crud - CRUD generator
- /ucg/api-docs - Auto-generated API documentation๐๏ธ Database Support
UCG supports multiple databases with comprehensive adapters:
$3
- Prisma: Full introspection, model generation, CRUD operations, Swagger docs
- Sequelize: Table structure detection, model/controller generation, Swagger docs
- Mongoose: Mock adapter (demonstrates architecture)
$3
- Prisma: Full introspection, model generation, CRUD operations, Swagger docs
- Sequelize: Table structure detection, model/controller generation
- TypeORM: Coming soon
$3
- Prisma: Full introspection, model generation, CRUD operations, Swagger docs
- Sequelize: Table structure detection, model/controller generation
- Better-SQLite3: Coming soon
$3
- Prisma: Full document introspection, schema generation, CRUD operations, Swagger docs
- Mongoose: Native MongoDB adapter with full ODM support
- Native Driver: Coming soon
$3
| Database | Introspection | CRUD Generation | Swagger Docs | Relationships | Migrations |
| ---------- | ------------- | --------------- | ------------ | ------------- | ---------- |
| PostgreSQL | โ
| โ
| โ
| โ
| โ
|
| MySQL | โ
| โ
| โ
| โ
| โ
|
| SQLite | โ
| โ
| โ
| โ
| โ
|
| MongoDB | โ
| โ
| โ
| โ
| โ ๏ธ |
$3
#### PostgreSQL
`javascript
{
"database": "postgresql",
"orm": "prisma",
"credentials": {
"host": "localhost",
"port": 5432,
"database": "myapp",
"user": "postgres",
"password": "password"
}
}
`#### MySQL
`javascript
{
"database": "mysql",
"orm": "prisma",
"credentials": {
"host": "localhost",
"port": 3306,
"database": "myapp",
"user": "root",
"password": "password"
}
}
`#### SQLite
`javascript
{
"database": "sqlite",
"orm": "prisma",
"credentials": {
"database": "./data/app.db"
}
}
`#### MongoDB
`javascript
{
"database": "mongodb",
"orm": "prisma",
"credentials": {
"host": "localhost",
"port": 27017,
"database": "myapp",
"user": "admin",
"password": "password"
}
}
`$3
The database-first folder structure makes it easy to add new databases:
`
src/databases/
โโโ postgresql/ # PostgreSQL adapters
โ โโโ prisma/ # Prisma adapter
โ โโโ sequelize/ # Sequelize adapter
โ โโโ mongoose/ # Mock adapter
โโโ mysql/ # MySQL adapters
โ โโโ prisma/ # Prisma adapter
โ โโโ sequelize/ # Sequelize adapter
โโโ sqlite/ # SQLite adapters
โ โโโ prisma/ # Prisma adapter
โ โโโ sequelize/ # Sequelize adapter
โโโ mongodb/ # MongoDB adapters
โโโ prisma/ # Prisma adapter
โโโ mongoose/ # Mongoose adapter
`๐จ Generated Code Structure
UCG generates clean, production-ready code:
`
your-project/
โโโ src/
โ โโโ controllers/ # Express controllers with full CRUD
โ โโโ services/ # Business logic layer
โ โโโ routes/ # Express routes with middleware
โ โโโ models/ # ORM models (Prisma/Sequelize/etc)
โ โโโ validation/ # Input validation middleware
โ โโโ tests/ # Unit tests for generated code
`๐ง Configuration
UCG stores its configuration in
node_modules/ucg/.ucg/config.json - no files are created in your project root.$3
`json
{
"database": "postgresql",
"orm": "prisma",
"credentials": {
"host": "localhost",
"port": 5432,
"database": "myapp",
"user": "postgres",
"tablePrefix": "app_"
},
"user": {
"email": "admin@example.com"
}
}
`๐ฆ API Generation & Swagger Documentation
$3
For each model, UCG generates RESTful endpoints with comprehensive Swagger documentation:
`
GET /models # List with pagination (clean - no filter examples)
GET /models/:id # Get by ID
POST /models # Create new (with request/response examples)
PUT /models/:id # Update (with request/response examples)
DELETE /models/:id # Delete (with response examples)
`$3
UCG generates comprehensive OpenAPI 3.0 specifications with:
#### โ
Clean GET Operations
- Pagination parameters only
- No cluttered filter examples
- Clear response schemas
#### โ
Rich POST/PUT/DELETE Operations
- Detailed request body examples
- Response examples for all status codes
- Error handling documentation
#### โ
Complete Component Schemas
- Model definitions with examples
- Error response schemas
- Pagination metadata schemas
#### โ
Database-Specific Adaptations
- MongoDB: ObjectId format handling
- PostgreSQL/MySQL/SQLite: Integer ID autoincrement
- All databases: Consistent schema patterns
$3
`yaml
Clean GET endpoint (no examples)
/users:
get:
summary: Get all users
parameters:
- name: page
in: query
schema:
type: integer
- name: limit
in: query
schema:
type: integer
responses:
'200':
description: Users retrieved successfullyRich POST endpoint (with examples)
/users:
post:
summary: Create a new user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserCreate'
example:
name: "John Doe"
email: "john@example.com"
age: 30
responses:
'201':
description: User created successfully
content:
application/json:
example:
id: 1
name: "John Doe"
email: "john@example.com"
age: 30
createdAt: "2024-01-01T00:00:00Z"
`$3
- Pagination: Built-in pagination support with metadata
- Validation: Input validation middleware with error responses
- Relationships: Foreign key relationships populated automatically
- Error Handling: Consistent error responses across all endpoints
- Status Codes: Proper HTTP status codes (200, 201, 400, 404, 500)
- Content Types: JSON request/response handling
๐ TypeScript Support
UCG now supports TypeScript code generation! Choose your preferred language during setup and UCG will generate fully typed code.
$3
During setup (CLI or Web Dashboard), you'll be prompted to select:
- JavaScript - Traditional ES6+ JavaScript
- TypeScript - Fully typed TypeScript with interfaces
$3
When TypeScript is selected, UCG generates:
`typescript
// user.controller.ts
import { Request, Response } from "express";
import { UserService } from "../services/user.service";export class UserController {
private userService: UserService;
constructor() {
this.userService = new UserService();
}
async getAll(req: Request, res: Response): Promise {
// Type-safe implementation
}
}
// user.service.ts
import { PrismaClient, User } from "@prisma/client";
export class UserService {
private prisma: PrismaClient;
constructor() {
this.prisma = new PrismaClient();
}
async findAll(page: number = 1, limit: number = 10): Promise {
// Type-safe queries
}
}
`$3
- โ
Full Type Safety: All generated code uses proper TypeScript types
- โ
Express Types:
Request, Response, and middleware types
- โ
ORM Types: Prisma Client types, Sequelize model types
- โ
Interface Definitions: Custom interfaces for DTOs and responses
- โ
Generics Support: Type-safe generic implementations
- โ
Auto-Configuration: Automatic tsconfig.json generation
- โ
Dependency Management: Auto-installs TypeScript and @types packages$3
UCG automatically creates a
tsconfig.json when TypeScript is selected:`json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["src/*/"],
"exclude": ["node_modules", "dist"]
}
`$3
You can switch between JavaScript and TypeScript at any time:
1. Via Web Dashboard: Go to Settings โ Language Selection
2. Via CLI: Run
npx ucg init again and choose a different language
3. Manual: Update .ucg/config.json and set "language": "typescript" or "language": "javascript"$3
TypeScript code generation works seamlessly with Swagger documentation:
- All types are properly documented in OpenAPI schemas
- Request/response examples include TypeScript interfaces
- Type-safe API endpoints with full documentation
$3
TypeScript files (
.ts) cannot be directly executed by Node.js. You have several options:#### Option 1: Using ts-node (Recommended for Development)
`bash
Install ts-node
npm install --save-dev ts-node @types/nodeRun your server
npx ts-node server.jsOr add to package.json scripts:
{
"scripts": {
"dev": "ts-node server.js",
"start": "node dist/server.js"
}
}
`#### Option 2: Using tsx (Fastest)
`bash
Install tsx (faster than ts-node)
npm install --save-dev tsxRun your server
npx tsx server.jsOr add to package.json:
{
"scripts": {
"dev": "tsx server.js",
"start": "tsx server.js"
}
}
`#### Option 3: Compile to JavaScript
`bash
Compile TypeScript
npx tscRun compiled JavaScript
node dist/server.jsAdd build script to package.json:
{
"scripts": {
"build": "tsc",
"start": "node dist/server.js",
"dev": "tsc --watch"
}
}
`$3
#### Error: Cannot find module './src/routes/xxx.routes.js'
This means UCG generated
.ts files, but your code is trying to require .js files.Solution 1: Regenerate Index Route
`bash
Update UCG to latest version
npm update ucgDelete old index file
rm src/routes/index.jsRegenerate any CRUD (this will create correct index.ts)
Visit /ucg/generate/crud and regenerate
`Solution 2: Use ts-node or tsx
`bash
npm install --save-dev tsx
npx tsx server.js
`#### Mixing TypeScript Routes with JavaScript Server
If you have a JavaScript
server.js but TypeScript routes:`javascript
// server.js (JavaScript)
const express = require("express");
const app = express();// Use require.resolve to handle .ts files with ts-node
if (require.resolve("./src/routes/index.ts")) {
const routes = require("./src/routes/index.ts");
app.use("/api", routes.default || routes);
}
// Then run with: npx ts-node server.js
`Or convert your server to TypeScript:
`typescript
// server.ts (TypeScript)
import express from "express";
import routes from "./src/routes/index";const app = express();
app.use("/api", routes);
// Run with: npx tsx server.ts
`$3
1. Always use a TypeScript runner (
ts-node, tsx) or compile before running
2. Keep tsconfig.json in sync with your project structure
3. Install type definitions for all dependencies: npm install --save-dev @types/express @types/node
4. Use ESM imports in TypeScript for better type support
5. Compile for production to avoid runtime overhead๐งช Testing & Validation
$3
`bash
Test the plugin itself
npm testTest Swagger documentation templates
node test-swagger-documentation.jsTest with real databases
node real-database-test.jsTest SQLite with rich data
node sqlite-focus-test.js
`$3
UCG generates unit tests for all generated code:
`bash
Test generated code in your project
npm test # Run tests for generated models/controllers
`$3
UCG includes comprehensive validation testing:
#### โ
Template Validation
- All 6 database adapter templates validated
- Swagger documentation completeness checked
- HTTP method coverage verified
#### โ
Database Testing
- Real database connection testing
- CRUD operation validation
- Relationship handling verification
#### โ
Integration Testing
- Dashboard functionality
- API endpoint generation
- Swagger UI integration
$3
Before publishing, test the package:
`bash
Create tarball
npm packInstall in test project
cd /path/to/test-project
npm install /path/to/ucg-1.2.1-beta.7.tgzTest functionality
npx ucg init
Visit /ucg/setup and test dashboard
Generate models and test API endpoints
`$3
Test with multiple databases using Docker:
`bash
PostgreSQL
docker run --name test-postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres:15MySQL
docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql:8MongoDB
docker run --name test-mongo -p 27017:27017 -d mongo:7
`๐ฏ Development
$3
`
ucg/
โโโ package.json
โโโ bin/ucg # CLI entry point
โโโ src/
โ โโโ index.js # Main exports
โ โโโ server.js # Standalone server (dev)
โ โโโ cli/ # CLI implementations
โ โ โโโ init.js
โ โ โโโ quick-setup.js
โ โโโ databases/ # Database-first adapters
โ โ โโโ postgresql/
โ โ โโโ prisma/ # Prisma adapter
โ โ โโโ sequelize/ # Sequelize adapter
โ โ โโโ mongoose/ # Mongoose adapter
โ โโโ ui/ # Web dashboard
โ โ โโโ routes/ # Express routes
โ โ โโโ views/ # Handlebars templates
โ โ โโโ static/ # CSS/JS assets
โ โโโ lib/ # Utilities
โ โ โโโ config.js # Configuration management
โ โ โโโ utils.js # Helper functions
โ โโโ tests/ # Unit tests
โโโ .ucg-config.example.json # Example configuration
โโโ README.md
`$3
`bash
Clone and setup
git clone
cd ucg
npm installRun development server
npm run devRun tests
npm testLint code
npm run lint
`๐ Security
- Password Hashing: User passwords hashed with bcrypt
- Configuration Security: Database credentials stored in plugin directory
- Input Validation: All generated endpoints include validation
- No Secrets: No hardcoded secrets in the repository
๐ API Reference
$3
When you run
ucg init, it adds these lines to your app:`javascript
// CommonJS
const ucg = require("ucg");
app.use("/ucg", ucg.router);// ES Modules
import ucg from "ucg";
app.use("/ucg", ucg.router);
`$3
`javascript
const { router } = require("ucg");
const configManager = require("ucg/src/lib/config");
const utils = require("ucg/src/lib/utils");// Mount UCG in your app
app.use("/admin/ucg", router);
// Access configuration
const config = await configManager.getConfig();
// Use utilities
const modelName = utils.tableNameToModelName("user_profiles");
`๐ฃ๏ธ Roadmap & Changelog
$3
- โ
Complete Swagger Documentation: Comprehensive OpenAPI specs for all database adapters
- โ
Clean GET Operations: No cluttered filter examples, pagination params only
- โ
Rich POST/PUT/DELETE: Detailed request/response examples for all mutations
- โ
Multi-Database Support: PostgreSQL, MySQL, SQLite, MongoDB with full CRUD
- โ
Database-Specific Handling: ObjectId for MongoDB, integer IDs for SQL databases
- โ
Template Validation: All 6 adapters pass comprehensive testing
- โ
Real Database Testing: Validated with Docker containers and rich test data
$3
#### 1.2.1-beta.6
- โ
Multi-database support foundation
- โ
Basic Swagger documentation
- โ ๏ธ Limited API examples
#### 1.2.0 - Stable Release
- โ
PostgreSQL + Prisma/Sequelize support
- โ
Web dashboard with modern UI
- โ
Model and CRUD generation
- โ
CLI tools (
init, quick-setup)
- โ Limited Swagger documentation$3
#### Next Release (1.2.2)
- Enhanced UI: Code editor with syntax highlighting
- Bulk Operations: Generate multiple models at once
- Custom Templates: User-defined code templates
- Migration Tools: Database schema migration support
#### Future Enhancements (1.3.0+)
- More ORMs: TypeORM, Knex.js, DrizzleORM
- GraphQL Generation: Auto-generated GraphQL schemas and resolvers
- API Versioning: Support for multiple API versions
- Advanced Relationships: Many-to-many, polymorphic relationships
- Performance: Query optimization and caching
- Testing: Generated test suites with coverage reports
#### UI/UX Improvements
- Dark Mode: Theme switching capability
- Mobile Responsive: Full mobile dashboard support
- Real-time Preview: Live code preview as you configure
- Diff Viewer: Compare generated code changes
- Export/Import: Configuration backup and restore
$3
- 1.2.0 โ 1.2.1: Configuration format updated for multi-database support
- 1.1.x โ 1.2.0: Dashboard routes restructured, CLI commands updated
๐ค Contributing
We welcome contributions! Here's how to get started:
$3
1. Fork the repository
2. Create a feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature)
5. Open a Pull Request$3
`bash
Clone and setup
git clone https://github.com/your-repo/ucg.git
cd ucg
npm installRun development server
npm run devRun tests
npm testLint code
npm run lintTest Swagger documentation
node test-swagger-documentation.jsTest with real databases
node real-database-test.js
`$3
1. Create Database Folder
`
src/databases/your-database/
โโโ prisma/ # Prisma adapter
โโโ sequelize/ # Sequelize adapter
โโโ your-orm/ # Your ORM adapter
`2. Implement Required Interface
Each adapter must implement:
`javascript
// Database connection and introspection
async introspectTables(connectionConfig)
async testConnection(connectionConfig) // Code generation
async generateModelCode(table, options)
async generateCRUD(model, options)
// Swagger documentation
generateSwaggerComponents(model)
generateSwaggerPaths(model)
`3. Add Swagger Documentation
- Component schemas with examples
- Clean GET operations (no filter examples)
- Rich POST/PUT/DELETE operations with examples
- Database-specific ID handling (ObjectId vs integer)
4. Create Tests
`javascript
// Add to test-swagger-documentation.js
// Add real database test cases
// Validate generated code works
`$3
1. Create ORM Adapter Folder
`
src/databases/database-name/your-orm/
โโโ index.js # Main adapter
โโโ introspection.js # Database introspection
โโโ generator.js # Code generation
โโโ templates/ # Code templates
โโโ model.js
โโโ controller.js
โโโ service.js
โโโ routes.js
``2. Follow Template Patterns
- Study existing adapters (Prisma, Sequelize)
- Use consistent naming conventions
- Include comprehensive Swagger documentation
- Handle relationships properly
- Write tests for new database adapters
- Test with real databases using Docker
- Validate Swagger docs are complete and correct
- Check generated code compiles and works
- Follow existing patterns for consistency
- Use ES6+ features
- Follow existing patterns
- Add JSDoc comments for public functions
- Use meaningful variable names
- Keep functions small and focused
- Update README.md for new features
- Add JSDoc comments for new functions
- Include examples in pull requests
- Update roadmap if adding major features
MIT License - see LICENSE file for details.
- ๐ Full Documentation
- ๐ Quick Start Guide
- ๐๏ธ Database Setup
- ๐ API Reference
- ๐ Bug Reports
- ๐ก Feature Requests
- ๐ฌ Discussions
- ๐ค Contributing Guide
- ๐ Check the FAQ
- ๐ Search existing issues
- ๐ฌ Start a discussion
- ๐ง Email: support@ucg-generator.com
- ๐ฆ NPM Package
- ๐ท๏ธ Releases
- ๐ Changelog
---
Made with โค๏ธ by the UCG team
๐ Star us on GitHub if UCG helps with your projects!
๐ Happy coding with Universal CRUD Generator!