Package Exports
- ucg
- ucg/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ucg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
UCG - Universal CRUD Generator
Express.js CRUD API Generator - Create production-ready REST APIs with authentication, RBAC, and comprehensive Swagger documentation.
๐ Two Ways to Use UCG
Method 1: Add to Existing Project
Install UCG in your existing Express.js project:
# In your existing project directory
npm install ucg
# Dependencies are installed automatically
# Start UCG Dashboard
npx ucg start
# Open browser: http://localhost:3000/ucg
# Complete setup wizard and generate CRUDs visuallyMethod 2: Quick Setup (New Project)
Create a complete project from scratch:
# In an empty directory
npm install ucg@beta quick-setup
# Or with options
npm install ucg@beta quick-setup --name my-api --db postgres
# Start your API
npm start
# Open UCG Dashboard: http://localhost:3000/ucg๐ฏ What You Get
UCG generates complete enterprise-grade APIs with optional authentication:
๐ง Core CRUD Generation
- Database Models (Sequelize, TypeORM, Knex.js)
- REST Controllers with full CRUD operations
- Express Routes with middleware integration
- Input Validation (express-validator)
- Swagger Documentation (auto-generated)
- Unit Tests (Jest test suites)
๐ Optional Authentication System (47 endpoints)
When you choose to generate Auth CRUD, you get:
Authentication Endpoints (10)
POST /api/auth/register # User registration
POST /api/auth/login # User login
POST /api/auth/refresh # Refresh JWT token
POST /api/auth/forgot-password # Request password reset
POST /api/auth/reset-password # Reset password with token
POST /api/auth/verify-email # Verify email address
POST /api/auth/resend-verification # Resend verification email
GET /api/auth/me # Get current user profile
PUT /api/auth/change-password # Change password
POST /api/auth/logout # Logout userRBAC System (23 endpoints)
# Users (4 endpoints)
GET /api/users # List users with filtering
GET /api/users/:id # Get user by ID
PUT /api/users/:id # Update user
DELETE /api/users/:id # Delete user
# Roles (7 endpoints)
GET /api/roles # List all roles
POST /api/roles # Create new role
GET /api/roles/:id # Get role details
PUT /api/roles/:id # Update role
DELETE /api/roles/:id # Delete role
POST /api/roles/:id/clone # Clone role
GET /api/roles/stats # Role statistics
# Permissions (10 endpoints)
GET /api/permissions # List permissions
POST /api/permissions # Create permission
GET /api/permissions/:id # Get permission
PUT /api/permissions/:id # Update permission
DELETE /api/permissions/:id # Delete permission
POST /api/permissions/bulk # Bulk operations
GET /api/permissions/resources # Resource permissions
POST /api/permissions/check # Check user permissions
GET /api/permissions/user/:id # User permissions
DELETE /api/permissions/bulk-delete # Bulk delete
# Permission Groups (6 endpoints)
GET /api/permission-groups # List permission groups
POST /api/permission-groups # Create group
GET /api/permission-groups/:id # Get group
PUT /api/permission-groups/:id # Update group
DELETE /api/permission-groups/:id # Delete group
GET /api/permission-groups/stats # Group statisticsMulti-Tenant Companies (10 endpoints)
GET /api/companies # List companies
POST /api/companies # Create company
GET /api/companies/:id # Get company
PUT /api/companies/:id # Update company
DELETE /api/companies/:id # Delete company
GET /api/companies/:id/users # Company users
POST /api/companies/:id/users # Add user to company
DELETE /api/companies/:id/users/:userId # Remove user
GET /api/companies/:id/settings # Company settings
GET /api/companies/stats # Company statisticsEmail System (4 endpoints)
POST /api/email/send # Send email
POST /api/email/send-template # Send template email
GET /api/email/templates # List templates
POST /api/email/templates # Create template๐ฅ๏ธ UCG Dashboard (GUI)
After installation, access the visual interface:
- Start Dashboard:
npx ucg start - Open Browser: http://localhost:3000/ucg
- Complete Setup: Follow the setup wizard
- Generate CRUDs: Use visual interface to create APIs
Dashboard Features:
- ๐ฏ Visual CRUD Generator - Point-and-click API creation
- ๐๏ธ Database Management - Visual schema designer
- ๐ API Overview - See all generated endpoints
- ๐ง Configuration - Manage settings visually
- ๐ Documentation - Interactive API docs
๐ป CLI Usage
Setup Commands
# Initialize UCG in your project (required for first use)
ucg init
# Check project status
ucg status
# Start dashboard
ucg startGeneration Commands
# Generate basic CRUD
ucg generate crud --model User --table users
# Generate Auth CRUD (complete authentication system)
ucg generate auth
# Generate specific model
ucg generate model --table productsDatabase Commands
# Run migrations
ucg migrate
# Seed database
ucg seed
# Test email configuration (if using auth)
ucg test:email๐ Usage Examples
Example 1: Generate Basic CRUD
Via Dashboard (Recommended)
- Open http://localhost:3000/ucg
- Click "Generate CRUD"
- Enter model details:
- Model:
Product - Table:
products - Fields:
name, price, description
- Model:
- Click "Generate"
Via CLI
ucg init # Complete setup first
ucg generate crud --model Product --table productsGenerated endpoints:
GET /api/products # List products
POST /api/products # Create product
GET /api/products/:id # Get product
PUT /api/products/:id # Update product
DELETE /api/products/:id # Delete productExample 2: Generate Auth CRUD
Via Dashboard (Recommended)
- Open http://localhost:3000/ucg
- Click "Generate Auth System"
- Configure:
- Database credentials
- JWT secrets
- Email settings (optional)
- Click "Generate Complete Auth System"
Via CLI
ucg init # Complete setup first
ucg generate auth # Generates all 47 auth endpointsGenerated: Complete authentication system with 47 endpoints!
๐๏ธ Database Setup
Supported Databases
- PostgreSQL (recommended)
- MySQL
- SQLite (development)
Setup Steps
# 1. Create database (PostgreSQL example)
createdb my_api_db
# 2. Configure environment
cp .env.example .env
# Edit .env with your database credentials
# 3. Run migrations
ucg migrate
# 4. Seed initial data (optional)
ucg seedEnvironment Configuration
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/my_db
# JWT (required for auth CRUD)
JWT_SECRET=your-super-secure-secret-minimum-32-characters
JWT_REFRESH_SECRET=your-refresh-secret-minimum-32-characters
# Email (required for auth CRUD)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-16-digit-app-password
EMAIL_FROM=your-email@gmail.com๐ง Email Configuration (For Auth CRUD)
Gmail Setup (5 minutes)
- Enable 2-Factor Authentication in Google Account
- Go to Google Account โ Security โ App Passwords
- Generate password for "Mail"
- Use the 16-digit code in your
.env:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-16-digit-app-password
EMAIL_FROM=your-email@gmail.comTest Email Configuration
ucg test:email๐งช Testing Your APIs
1. Basic API Test
# Health check
curl http://localhost:3000/health
# List generated APIs
curl http://localhost:3000/api2. Auth System Test (if generated)
# Register user
curl -X POST http://localhost:3000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"Test123!","name":"Test User"}'
# Login
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"Test123!"}'
# Use JWT token for protected endpoints
curl -X GET http://localhost:3000/api/users \
-H "Authorization: Bearer YOUR_JWT_TOKEN"3. CRUD API Test
# Create product (example)
curl -X POST http://localhost:3000/api/products \
-H "Content-Type: application/json" \
-d '{"name":"iPhone","price":999,"description":"Smartphone"}'
# List products
curl http://localhost:3000/api/products๐ API Documentation
Swagger UI
Visit http://localhost:3000/docs for interactive API documentation with:
- ๐ Complete endpoint list
- ๐งช Interactive testing
- ๐ Request/response examples
- ๐ Authentication testing
Postman Collection
UCG automatically generates Postman collections for all APIs.
๐ Production Deployment
Environment Variables
NODE_ENV=production
PORT=3000
DATABASE_URL=your-production-database-url
JWT_SECRET=your-production-jwt-secret
SMTP_HOST=your-production-smtp-serverDocker Deployment
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]Deploy Commands
# Build for production
npm run build
# Start production server
npm start
# Run migrations in production
NODE_ENV=production ucg migrateโ Troubleshooting
Common Issues
Missing dependencies error?
# Reinstall UCG
npm uninstall ucg && npm install ucgDatabase connection error?
# Check .env database settings
# Ensure database exists
# Run: ucg migrateEmail not working?
# Check SMTP settings in .env
# For Gmail: Use App Password, not regular password
# Test: ucg test:emailUCG Dashboard not loading?
# Complete setup first
ucg init
# Then start dashboard
ucg start๐ง Advanced Configuration
Custom Middleware
// Add to your Express app
app.use('/api', yourCustomMiddleware);
app.use('/api', require('ucg').routes);Custom Templates
UCG supports custom code templates for specific requirements.
Database Migrations
UCG automatically generates and runs migrations for all CRUD operations.
๐ Support & Documentation
- GitHub: https://github.com/jithvar/ucg
- Issues: Report bugs
- Dashboard: Complete setup wizard and docs at
/ucg - API Docs: Interactive documentation at
/docs
๐ License
MIT License - see LICENSE file for details.
Made with โค๏ธ by Jithvar Consultancy Services
UCG - From zero to production-ready APIs in minutes!