Enterprise-grade web-based management tool for QEMU KVM virtual machines.
# Clone and setup
git clone <repository-url>
cd kvm-ui
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start services
docker compose up -d
# Run migrations
docker compose exec app npm run migrate
# Create admin user
curl -X POST http://localhost:3000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "your-password"}'
# Access application
open http://localhost:3000Good news! Your existing v1.0 frontend works without any changes. v2.0 maintains full backward compatibility while adding a modern API.
- β Legacy endpoints work as-is
- β Cookie-based authentication maintained
- β Same response formats
- π Modern API with
/apiprefix available - π JWT token authentication
- π Better error handling and validation
See BACKWARD_COMPATIBILITY.md for details.
- Modern Architecture: TypeScript + Clean Architecture patterns
- JWT Authentication: Secure token-based authentication with RBAC ready
- API-First Design: RESTful API with OpenAPI/Swagger documentation
- Security: Rate limiting, input validation, helmet security headers
- Logging: Structured logging with Winston
- Health Checks: Comprehensive health check endpoints
- Database Migrations: Automated schema migrations
- Queue System: Background job processing for long-running operations
- Testing: Jest-based testing framework
- Code Quality: ESLint, Prettier, Husky pre-commit hooks
-
Clone the repository
git clone <repository-url> cd kvm-ui
-
Configure environment variables
cp .env.example .env # Edit .env with your configuration -
Build Docker image and get SSH public key
docker compose build app # The build will display an SSH public key # Copy this key for the next step
-
Add SSH public key to KVM host
# On your KVM host: mkdir -p ~/.ssh echo "ssh-ed25519 <YOUR_PUBLIC_KEY_FROM_BUILD> kvm-ui@buildkitsandbox" >> ~/.ssh/authorized_keys chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys # Or use the helper script to retrieve the key: ./scripts/show-ssh-key.sh
-
Start the services
docker compose up -d
-
Run database migrations
docker compose exec app npm run migrate -
Create admin user
curl -X POST http://localhost:3000/api/auth/register \ -H "Content-Type: application/json" \ -d '{"username": "admin", "password": "your-secure-password"}'
-
Install dependencies
npm install
-
Setup environment
cp .env.example .env # Edit .env with your configuration -
Run database migrations
npm run migrate
-
Start development server
npm run dev
-
Build for production
npm run build npm start
Once the server is running, visit:
- API Documentation:
http://localhost:3000/api/docs - Health Check:
http://localhost:3000/api/health
POST /api/auth/register- Register new user (only first user)POST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user info
POST /api/vm/update-ip- Update VM IP addressDELETE /api/vm/delete-ip- Delete VM recordPOST /api/vm/resize-disk- Resize VM diskPOST /api/vm/expose-ssh- Expose SSH to publicPOST /api/vm/expose-service- Expose service to publicPOST /api/vm/check-ip- Check IP availabilityGET /api/vm/list- List all VMs
GET /api/health- Basic health checkGET /api/health/detailed- Detailed health check
kvm-ui/
βββ src/
β βββ config/ # Configuration files
β βββ controllers/ # Request handlers
β βββ middlewares/ # Express middlewares
β βββ repositories/ # Data access layer
β βββ routes/ # API routes
β βββ services/ # Business logic layer
β βββ types/ # TypeScript types
β βββ utils/ # Utility functions
β βββ validators/ # Request validators
β βββ queues/ # Job queue definitions
β βββ workers/ # Job workers
β βββ app.ts # Express app setup
β βββ server.ts # Server entry point
βββ migrations/ # Database migrations
βββ tests/ # Test files
βββ public/ # Static files
βββ script/ # Shell scripts
βββ docker-compose.yaml # Docker setup
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage- JWT Authentication: Token-based authentication
- Rate Limiting: Prevent brute force attacks
- Input Validation: Joi-based request validation
- Helmet: Security headers
- CORS: Cross-origin resource sharing configuration
- Password Hashing: Bcrypt for secure password storage
# Basic health check
curl http://localhost:3000/api/health
# Detailed health check
curl http://localhost:3000/api/health/detailedLogs are stored in the logs/ directory:
all.log- All logserror.log- Error logs only
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Type checking
npm run typecheckHusky is configured to run lint-staged before commits:
# Setup pre-commit hooks
npm run preparedocker build -t kvm-ui:latest .docker compose up -ddocker compose logs -f appdocker compose downSee .env.example for all available configuration options:
SSH_HOST- Target QEMU KVM host IPSSH_USER- SSH user for KVM hostJWT_SECRET- Secret key for JWT tokensDB_HOST,DB_USER,DB_PASSWORD- PostgreSQL configurationREDIS_HOST,REDIS_PASSWORD- Redis configuration
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
ISC
# Check PostgreSQL is running
docker compose ps postgres
# View PostgreSQL logs
docker compose logs postgres# Check Redis is running
docker compose ps redis
# View Redis logs
docker compose logs redis# Re-run migrations
docker compose exec app npm run migrateFor issues and questions, please open an issue on GitHub.