Deploying ChartDB
ChartDB is an open-source database design and visualization platform that enables teams to collaborate on database schemas in real-time. It provides an intuitive visual interface for creating, editing, and sharing database designs, with support for multiple database systems including PostgreSQL, MySQL, MongoDB, and more. ChartDB simplifies complex database architecture planning and documentation for developers, database administrators, and technical architects.
This guide will walk you through deploying ChartDB on Klutch.sh, a modern cloud platform that simplifies containerized application deployment. By the end of this guide, you’ll have a fully functional ChartDB instance ready for your team’s database design collaboration.
Why Deploy ChartDB on Klutch.sh?
Klutch.sh provides an excellent platform for hosting ChartDB:
- Docker-native deployment - Klutch.sh automatically detects and deploys Dockerized applications
- Real-time collaboration - Enable your team to design databases together with persistent storage
- Custom domains - Point your domain to your ChartDB instance for team access
- Environment configuration - Manage secrets and configuration through the dashboard
- Data persistence - Attach volumes for database designs and user data
- Scalability - Easily scale resources as your team grows
Prerequisites
Before deploying ChartDB on Klutch.sh, you’ll need:
- A Klutch.sh account (sign up for free)
- Access to the Klutch.sh dashboard
- A GitHub repository to store your ChartDB deployment configuration
- A custom domain (optional but recommended for team collaboration)
- Basic understanding of Docker and containerization
Deployment Steps
Create a Dockerfile
Create a
Dockerfilein the root of your repository to containerize ChartDB:FROM node:20-alpine# Install system dependenciesRUN apk add --no-cache \build-base \python3 \git \curl# Set working directoryWORKDIR /app# Clone ChartDB repositoryRUN git clone https://github.com/chartdb/chartdb.git . && \git checkout main# Install dependenciesRUN npm install# Build the applicationRUN npm run build# Create necessary directoriesRUN mkdir -p /app/data /app/exports# Expose portEXPOSE 3000# Health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"# Start the applicationCMD ["npm", "start"]Create Environment Configuration File
Create a
.env.examplefile to document required environment variables:# ChartDB Environment Configuration# Application SettingsNODE_ENV=productionHOST=0.0.0.0PORT=3000# Database ConfigurationDATABASE_URL=postgresql://chartdb:chartdbpass@localhost:5432/chartdbDATABASE_HOST=dbDATABASE_PORT=5432DATABASE_USER=chartdbDATABASE_PASSWORD=chartdbpassDATABASE_NAME=chartdb# Redis Configuration (for sessions and caching)REDIS_URL=redis://redis:6379# JWT ConfigurationJWT_SECRET=your-jwt-secret-here-change-in-productionJWT_EXPIRATION=7d# File Upload ConfigurationMAX_FILE_SIZE=52428800UPLOAD_DIR=/app/dataEXPORT_DIR=/app/exports# CORS SettingsCORS_ORIGIN=https://example-app.klutch.shCORS_CREDENTIALS=true# Email Configuration (Optional)SMTP_HOST=smtp.gmail.comSMTP_PORT=587SMTP_USER=your-email@gmail.comSMTP_PASSWORD=your-app-passwordSMTP_FROM=noreply@example-app.klutch.sh# AuthenticationENABLE_LOCAL_AUTH=trueENABLE_OAUTH=falseOAUTH_CLIENT_ID=OAUTH_CLIENT_SECRET=# AdministrationADMIN_EMAIL=admin@example.comADMIN_PASSWORD=change-me-in-production# LoggingLOG_LEVEL=info# Analytics (Optional)ENABLE_ANALYTICS=falseANALYTICS_TOKEN=# API Rate LimitingRATE_LIMIT_WINDOW=900000RATE_LIMIT_MAX_REQUESTS=100Create Application Configuration File
Create a
config.jsfile for application-specific settings:module.exports = {app: {name: 'ChartDB',version: '1.0.0',environment: process.env.NODE_ENV || 'production',port: process.env.PORT || 3000,host: process.env.HOST || '0.0.0.0'},database: {url: process.env.DATABASE_URL,host: process.env.DATABASE_HOST,port: parseInt(process.env.DATABASE_PORT) || 5432,user: process.env.DATABASE_USER,password: process.env.DATABASE_PASSWORD,database: process.env.DATABASE_NAME,pool: {min: 2,max: 10,idleTimeoutMillis: 30000,connectionTimeoutMillis: 2000}},redis: {url: process.env.REDIS_URL,retryStrategy: (times) => Math.min(times * 50, 2000),maxRetriesPerRequest: null},jwt: {secret: process.env.JWT_SECRET,expiresIn: process.env.JWT_EXPIRATION || '7d',algorithm: 'HS256'},fileUpload: {maxFileSize: parseInt(process.env.MAX_FILE_SIZE) || 52428800,uploadDir: process.env.UPLOAD_DIR || '/app/data',exportDir: process.env.EXPORT_DIR || '/app/exports',allowedMimeTypes: ['application/json','application/xml','image/svg+xml','text/plain']},cors: {origin: process.env.CORS_ORIGIN || 'http://localhost:3000',credentials: process.env.CORS_CREDENTIALS === 'true'},auth: {enableLocalAuth: process.env.ENABLE_LOCAL_AUTH === 'true',enableOAuth: process.env.ENABLE_OAUTH === 'true',oauthClientId: process.env.OAUTH_CLIENT_ID,oauthClientSecret: process.env.OAUTH_CLIENT_SECRET},rateLimit: {windowMs: parseInt(process.env.RATE_LIMIT_WINDOW) || 900000,max: parseInt(process.env.RATE_LIMIT_MAX_REQUESTS) || 100}};Create Database Initialization Script
Create an
init-db.shfile to set up the PostgreSQL database:#!/bin/bashset -eecho "Initializing ChartDB database..."# Wait for PostgreSQL to be readyuntil PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -U "$DATABASE_USER" -d "postgres" -c "\q"; doecho 'Waiting for postgres...'sleep 1doneecho "PostgreSQL is ready!"# Create database if it doesn't existPGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -U "$DATABASE_USER" -d "postgres" << EOFCREATE DATABASE $DATABASE_NAME;EOFecho "Database created!"# Run migrationsecho "Running database migrations..."npm run migrateecho "Database initialization complete!"Make it executable:
Terminal window chmod +x init-db.shCreate Docker Compose for Local Development
Create a
docker-compose.ymlfile for local development and testing (not used for Klutch.sh deployment):version: '3.8'services:chartdb:build: .container_name: chartdb-devports:- "3000:3000"environment:- NODE_ENV=development- DATABASE_URL=postgresql://chartdb:chartdbpass@db:5432/chartdb- DATABASE_HOST=db- DATABASE_USER=chartdb- DATABASE_PASSWORD=chartdbpass- DATABASE_NAME=chartdb- REDIS_URL=redis://redis:6379- JWT_SECRET=dev-secret-key-change-in-production- UPLOAD_DIR=/app/data- EXPORT_DIR=/app/exports- CORS_ORIGIN=http://localhost:3000- ADMIN_EMAIL=admin@localhost- ADMIN_PASSWORD=admin123depends_on:- db- redisvolumes:- ./data:/app/data- ./src:/app/srcnetworks:- chartdb-networkdb:image: postgres:16-alpinecontainer_name: chartdb-dbenvironment:- POSTGRES_USER=chartdb- POSTGRES_PASSWORD=chartdbpass- POSTGRES_DB=chartdbvolumes:- chartdb_db_data:/var/lib/postgresql/datanetworks:- chartdb-networkhealthcheck:test: ["CMD-SHELL", "pg_isready -U chartdb"]interval: 10stimeout: 5sretries: 5redis:image: redis:7-alpinecontainer_name: chartdb-redisnetworks:- chartdb-networkhealthcheck:test: ["CMD", "redis-cli", "ping"]interval: 10stimeout: 5sretries: 5volumes:chartdb_db_data:networks:chartdb-network:driver: bridgeCreate .gitignore File
Create a
.gitignorefile to exclude sensitive data from version control:# Environment files.env.env.local.env.*.local# Node.jsnode_modules/npm-debug.logyarn-error.logpackage-lock.jsonyarn.lock# Build artifactsdist/build/.next/out/# Data and uploadsdata/exports/uploads/# Database*.sqlite*.sqlite3# IDE.vscode/.idea/*.swp*.swo*~.DS_Store# Logslogs/*.log# Cache.cache/.turbo/Push Configuration to GitHub
Push your repository to GitHub with all configuration files:
Terminal window git add Dockerfile .env.example config.js init-db.sh \docker-compose.yml .gitignoregit commit -m "Initial ChartDB deployment configuration for Klutch.sh"git push origin mainDeploy on Klutch.sh
- Navigate to klutch.sh/app and log in to your dashboard
- Click Create New App
- Connect your GitHub repository containing the ChartDB deployment files (the Dockerfile will be automatically detected)
- Configure your application settings:
- Set your preferred app name
- Review the detected Dockerfile configuration
- Select a region for deployment
- Click Deploy to start the deployment process
- Monitor the deployment progress in the dashboard
- Wait for the deployment to complete and your app to become active
Configure Environment Variables
- In your app dashboard, navigate to Environment Variables section
- Add all required variables from your
.env.examplefile:DATABASE_URL: Your PostgreSQL connection stringREDIS_URL: Your Redis connection stringJWT_SECRET: Generate a secure secret withopenssl rand -base64 32CORS_ORIGIN: Set tohttps://example-app.klutch.sh(or your custom domain)ADMIN_EMAILandADMIN_PASSWORD: Your administrator credentials
- Click Save to apply the environment variables
- Your application will automatically restart with the new configuration
Configure Traffic Routes
- In your app dashboard, navigate to Traffic settings
- Select HTTP as the traffic type
- Set the internal port to 3000 (ChartDB Node.js server default)
- Configure any custom domain settings if you have a domain
- Save your traffic configuration
Attach Persistent Volumes
ChartDB requires persistent storage for database designs and exported files.
- In your app dashboard, navigate to Volumes settings
- Click Add Volume to create storage for database designs:
- Enter mount path:
/app/data - Set volume size to 20GB (adjust based on number of projects)
- Click Attach to create and mount the volume
- Enter mount path:
- Click Add Volume again for exported diagrams:
- Enter mount path:
/app/exports - Set volume size to 10GB (for exported files and backups)
- Click Attach to create and mount the volume
- Enter mount path:
Your ChartDB application will now be accessible at your configured domain or at
example-app.klutch.sh.
Initial Setup and Configuration
After deploying ChartDB on Klutch.sh, complete the initial setup to prepare your database design collaboration platform.
Access Your ChartDB Instance
- Navigate to
https://example-app.klutch.shin your web browser - You’ll see the ChartDB welcome page
- Click Sign Up to create your administrator account
- Enter your email and set a strong password
- Complete the email verification process
- Log in to your new ChartDB instance
Configure Your ChartDB Instance
Once logged in, configure these essential settings:
Workspace Settings:
- Set your workspace name and description
- Configure workspace branding
- Set up user roles and permissions
- Enable team collaboration features
Database Connections:
- Add connections to your production databases
- Configure connection strings for PostgreSQL, MySQL, MongoDB
- Set up SSL/TLS for secure connections
- Test database connectivity
Project Management:
- Create projects for different database schemas
- Organize projects by team or application
- Set project visibility (private, team, public)
- Configure project templates
Team Management:
- Invite team members to your workspace
- Assign roles (Owner, Admin, Editor, Viewer)
- Set up team-based project access
- Configure audit logging
Set Up User Authentication
To enable team collaboration securely:
- In your app dashboard, navigate to Authentication settings
- Configure email verification for new users
- Set password requirements
- Enable two-factor authentication for admins
- Configure session timeout policies
Configure Backup Strategy
To protect your database designs:
- In your app dashboard, navigate to Database settings
- Enable automated daily backups
- Set backup retention to at least 7 days
- Configure backup notifications
- Test backup restoration procedures
Set Up Export Integration (Optional)
For advanced features:
- Configure export destinations for database diagrams
- Set up automated exports to cloud storage
- Enable export formats (SQL, JSON, XML)
- Configure scheduled exports
Database Design Best Practices
Organizing Your Schemas
- Create separate projects for each major system or application
- Use consistent naming conventions across all schemas
- Document relationships between different database designs
- Maintain version history of schema changes
Collaboration Guidelines
- Use comments to document complex relationships
- Share read-only access for stakeholders
- Use the approval workflow for schema changes
- Maintain a changelog for tracking modifications
Performance Optimization
- Regularly index frequently queried columns
- Archive completed or deprecated schema projects
- Optimize query patterns before implementation
- Monitor schema complexity metrics
Deployment Best Practices
Security Measures
- Keep ChartDB updated to the latest version
- Use strong, unique passwords for all accounts
- Enable two-factor authentication for administrators
- Configure firewall rules to restrict access if needed
- Use HTTPS for all communications (automatic with Klutch.sh)
- Regularly review user access permissions
Monitoring and Maintenance
- Monitor disk usage for design and export storage
- Set up alerts for deployment failures
- Review logs regularly for errors or security issues
- Schedule maintenance windows for updates
- Test backup restoration procedures monthly
Scaling Considerations
As your team grows and creates more projects:
- Increase volume sizes proactively before running out of space
- Monitor database performance and optimize indexes
- Archive old or completed projects
- Consider implementing database sharding for large schemas
- Implement caching strategies for frequently accessed designs
Accessing ChartDB
Once deployment is complete and configured:
- Team members access ChartDB at your configured domain or
example-app.klutch.sh - Users can create and manage database schema projects
- Real-time collaboration enables simultaneous editing
- Export functionality allows saving designs in multiple formats
- Admin panel provides workspace and user management
Troubleshooting Deployment Issues
Application Won’t Start
Check the following:
- Verify all required environment variables are set
- Ensure database connection string is correct
- Check that Redis is accessible
- Review application logs in the dashboard
Database Connection Errors
Steps to resolve:
- Verify DATABASE_URL environment variable format
- Ensure database is running and accessible
- Check database user credentials
- Verify network connectivity between services
Storage Issues
Possible solutions:
- Verify persistent volumes are properly attached
- Check available disk space on volumes
- Ensure
/app/datadirectory has write permissions - Archive old projects to free up space
Performance Issues
Optimization steps:
- Increase application memory allocation
- Enable Redis caching
- Optimize database queries
- Review and optimize schema files
- Consider upgrading to higher performance storage
Advanced Configuration
Environment Variables for Customization
You can customize ChartDB behavior with these environment variables:
# Session ConfigurationSESSION_TIMEOUT=3600SESSION_SECRET=your-session-secret
# Database Connection PoolDB_POOL_MIN=2DB_POOL_MAX=10DB_IDLE_TIMEOUT=30000
# File Upload RestrictionsMAX_FILE_SIZE=52428800MAX_CONCURRENT_UPLOADS=5
# Feature FlagsENABLE_REAL_TIME_COLLAB=trueENABLE_VERSION_HISTORY=trueENABLE_COMMENTS=trueENABLE_EXPORTS=true
# Performance TuningCACHE_TTL=3600REDIS_MAX_RETRIES=3DB_QUERY_TIMEOUT=30000Custom Domain Setup
To use a custom domain with your ChartDB instance:
- In your Klutch.sh dashboard, navigate to Domains
- Add your custom domain
- Follow the DNS configuration instructions
- Update your environment variables with the new domain:
CORS_ORIGIN=https://your-domain.com
- Save and redeploy your application
Import Existing Database Schemas
If importing from another tool or existing databases:
- Export your current database schema (DDL scripts)
- Upload the SQL file to ChartDB
- Use the import feature to create visual representations
- Verify all tables and relationships are correctly imported
- Share the project with your team
Additional Resources
Learn more about ChartDB and Klutch.sh:
- ChartDB GitHub Repository - Source code and contribution guidelines
- ChartDB Documentation - Comprehensive platform documentation
- ChartDB Issue Tracker - Report bugs and request features
- Klutch.sh Official Website - Learn more about the deployment platform
- Klutch.sh Documentation - Platform guides and API reference
Conclusion
You now have a fully functional ChartDB instance running on Klutch.sh! Your collaborative database design platform is ready for your team to use for schema planning, visualization, and documentation.
With the robust infrastructure provided by Klutch.sh and the powerful features of ChartDB, you can streamline database design workflows and improve team collaboration. Remember to:
- Keep your application updated with the latest ChartDB releases
- Monitor system performance and storage usage regularly
- Maintain regular backups of your database designs
- Follow security best practices for team authentication
- Scale your infrastructure as your team and projects grow
For additional support or questions about deploying ChartDB on Klutch.sh, refer to the documentation and community resources linked above.