ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Add resource tier enforcement and UI for WordPress creation
Juan Denisc7444a88f5f7
diff --git a/backend/app/api/system.py b/backend/app/api/system.pyindex 45577c7c..3557fb7f 100644--- a/backend/app/api/system.py+++ b/backend/app/api/system.py@@ -2,10 +2,11 @@ import osimport timeimport urllib.requestimport json-from flask import Blueprint, jsonify, current_app+from flask import Blueprint, jsonify, request, current_appfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.models import Userfrom app.services.system_service import SystemService+from app.services.resource_tier_service import ResourceTierService# Cache for update check (to avoid hitting GitHub API too often)_update_cache = {@@ -200,6 +201,27 @@ def health_check():}), 200+@system_bp.route('/resource-tier', methods=['GET'])+@jwt_required()+def get_resource_tier():+ """+ Get server resource tier information.++ Returns tier, specs, and feature permissions based on server resources.+ Results are cached for 1 hour unless refresh=true is passed.+ """+ current_user_id = get_jwt_identity()+ user = User.query.get(current_user_id)++ if user.role != 'admin':+ return jsonify({'error': 'Admin access required'}), 403++ force_refresh = request.args.get('refresh', 'false').lower() == 'true'+ tier_info = ResourceTierService.get_tier_info(force_refresh=force_refresh)++ return jsonify(tier_info), 200++@system_bp.route('/time', methods=['GET'])@jwt_required()def get_server_time():diff --git a/backend/app/api/wordpress_sites.py b/backend/app/api/wordpress_sites.pyindex b4f4f2be..8bc82bab 100644--- a/backend/app/api/wordpress_sites.py+++ b/backend/app/api/wordpress_sites.py@@ -19,6 +19,7 @@ from app.services.wordpress_service import WordPressServicefrom app.services.wordpress_env_service import WordPressEnvServicefrom app.services.db_sync_service import DatabaseSyncServicefrom app.services.git_wordpress_service import GitWordPressService+from app.services.resource_tier_service import ResourceTierServicewordpress_sites_bp = Blueprint('wordpress_sites', __name__)@@ -56,6 +57,23 @@ def create_site():user_id = get_jwt_identity()data = request.get_json()+ # Check resource tier - block creation on lite tier servers+ tier_info = ResourceTierService.get_tier_info()+ if not tier_info['features']['wordpress_create']:+ min_req = ResourceTierService.get_minimum_requirements()+ return jsonify({+ 'error': 'Server resources insufficient for WordPress',+ 'reason': 'wordpress_blocked',+ 'specs': tier_info['specs'],+ 'tier': tier_info['tier'],+ 'minimum_requirements': min_req,+ 'message': (+ f"WordPress site creation requires at least {min_req['cpu_cores']} CPU cores "+ f"and {min_req['ram_gb']}GB RAM. Your server has {tier_info['specs']['cpu_cores']} core(s) "+ f"and {tier_info['specs']['ram_gb']}GB RAM. Consider upgrading your server."+ )+ }), 403+# Validate required fieldsrequired = ['name', 'domain', 'db_name', 'db_user', 'db_password', 'admin_email']missing = [f for f in required if not data.get(f)]diff --git a/backend/app/services/resource_tier_service.py b/backend/app/services/resource_tier_service.pynew file mode 100644index 00000000..43ed226d--- /dev/null+++ b/backend/app/services/resource_tier_service.py@@ -0,0 +1,184 @@+"""+Resource Tier Service++Determines server resource tier based on CPU and RAM, and controls+feature availability accordingly.++Tiers:+- lite: 1 CPU core OR <2GB RAM - Limited features (no WordPress creation)+- standard: 2-3 cores, 2-4GB RAM - Most features enabled+- performance: 4+ cores, >4GB RAM - All features enabled+"""++import time+import psutil++# Module-level cache with 1-hour TTL+_tier_cache = {+ 'data': None,+ 'timestamp': 0,+ 'ttl': 3600 # 1 hour+}+++class ResourceTierService:+ """Service for determining server resource tier and feature availability."""++ TIER_LITE = 'lite'+ TIER_STANDARD = 'standard'+ TIER_PERFORMANCE = 'performance'++ # Minimum requirements for WordPress+ MIN_CORES_FOR_WORDPRESS = 2+ MIN_RAM_GB_FOR_WORDPRESS = 2++ @classmethod+ def get_tier_info(cls, force_refresh=False):+ """+ Get resource tier information including specs, tier, and feature permissions.++ Args:+ force_refresh: If True, bypass cache and recalculate++ Returns:+ dict: {+ 'tier': 'lite'|'standard'|'performance',+ 'specs': {'cpu_cores': int, 'ram_gb': float, 'ram_bytes': int},+ 'features': {'wordpress_create': bool, ...},+ 'cached': bool+ }+ """+ global _tier_cache++ current_time = time.time()+ cache_valid = (+ _tier_cache['data'] is not None and+ (current_time - _tier_cache['timestamp']) < _tier_cache['ttl']+ )++ if cache_valid and not force_refresh:+ return {**_tier_cache['data'], 'cached': True}++ # Get system specs+ specs = cls._get_system_specs()++ # Calculate tier+ tier = cls._calculate_tier(specs)++ # Get features for this tier+ features = cls._get_features_for_tier(tier, specs)++ result = {+ 'tier': tier,+ 'specs': specs,+ 'features': features,+ 'cached': False+ }++ # Update cache+ _tier_cache['data'] = {+ 'tier': tier,+ 'specs': specs,+ 'features': features+ }+ _tier_cache['timestamp'] = current_time++ return result++ @classmethod+ def _get_system_specs(cls):+ """+ Get system CPU and RAM specifications using psutil.++ Returns:+ dict: {'cpu_cores': int, 'ram_gb': float, 'ram_bytes': int}+ """+ cpu_cores = psutil.cpu_count(logical=False) or psutil.cpu_count(logical=True) or 1+ memory = psutil.virtual_memory()+ ram_bytes = memory.total+ ram_gb = round(ram_bytes / (1024 ** 3), 2)++ return {+ 'cpu_cores': cpu_cores,+ 'ram_gb': ram_gb,+ 'ram_bytes': ram_bytes+ }++ @classmethod+ def _calculate_tier(cls, specs):+ """+ Determine tier based on system specs.++ Tier determination:+ - Lite: 1 core OR <2GB RAM+ - Performance: 4+ cores AND >4GB RAM+ - Standard: Everything else (2-3 cores, 2-4GB RAM)++ Args:+ specs: dict from _get_system_specs()++ Returns:+ str: 'lite', 'standard', or 'performance'+ """+ cpu_cores = specs['cpu_cores']+ ram_gb = specs['ram_gb']++ # Lite tier: single core or very low RAM+ if cpu_cores < 2 or ram_gb < 2:+ return cls.TIER_LITE++ # Performance tier: high resources+ if cpu_cores >= 4 and ram_gb > 4:+ return cls.TIER_PERFORMANCE++ # Standard tier: moderate resources+ return cls.TIER_STANDARD++ @classmethod+ def _get_features_for_tier(cls, tier, specs):+ """+ Get feature permissions based on tier and specs.++ Args:+ tier: The calculated tier string+ specs: System specs dict++ Returns:+ dict: Feature permission flags+ """+ # WordPress creation requires minimum resources+ can_create_wordpress = (+ specs['cpu_cores'] >= cls.MIN_CORES_FOR_WORDPRESS and+ specs['ram_gb'] >= cls.MIN_RAM_GB_FOR_WORDPRESS+ )++ return {+ 'wordpress_create': can_create_wordpress,+ 'wordpress_manage': True, # Always allow managing existing sites+ 'docker': True, # Docker available on all tiers+ 'databases': True, # Database management available on all tiers+ }++ @classmethod+ def can_create_wordpress(cls):+ """+ Quick check if WordPress site creation is allowed.++ Returns:+ bool: True if WordPress creation is permitted+ """+ tier_info = cls.get_tier_info()+ return tier_info['features']['wordpress_create']++ @classmethod+ def get_minimum_requirements(cls):+ """+ Get the minimum requirements for WordPress creation.++ Returns:+ dict: {'cpu_cores': int, 'ram_gb': int}+ """+ return {+ 'cpu_cores': cls.MIN_CORES_FOR_WORDPRESS,+ 'ram_gb': cls.MIN_RAM_GB_FOR_WORDPRESS+ }diff --git a/frontend/.env.development b/frontend/.env.developmentindex 8ed0e6b4..644678f2 100644--- a/frontend/.env.development+++ b/frontend/.env.development@@ -1 +1 @@-VITE_API_URL=http://localhost:5000+VITE_API_URL=http://localhost:5000/api/v1diff --git a/frontend/index.html b/frontend/index.htmlindex d1199ba5..4db11b39 100644--- a/frontend/index.html+++ b/frontend/index.html@@ -3,7 +3,9 @@<head><meta charset="UTF-8" />- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="icon" type="image/x-icon" href="/favicon.ico" />+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="ServerKit - Server Management Dashboard" /><title>ServerKit</title>diff --git a/frontend/public/favicon-16x16.png b/frontend/public/favicon-16x16.pngnew file mode 100644index 00000000..00248b94Binary files /dev/null and b/frontend/public/favicon-16x16.png differdiff --git a/frontend/public/favicon-32x32.png b/frontend/public/favicon-32x32.pngnew file mode 100644index 00000000..2e751b60Binary files /dev/null and b/frontend/public/favicon-32x32.png differdiff --git a/frontend/public/favicon.ico b/frontend/public/favicon.iconew file mode 100644index 00000000..cb0748f3Binary files /dev/null and b/frontend/public/favicon.ico differdiff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex b762641b..39c01340 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -3,6 +3,7 @@ import { BrowserRouter as Router, Routes, Route, Navigate, useLocation } from 'rimport { AuthProvider, useAuth } from './contexts/AuthContext';import { ToastProvider } from './contexts/ToastContext';import { ThemeProvider } from './contexts/ThemeContext';+import { ResourceTierProvider } from './contexts/ResourceTierContext';import { ToastContainer } from './components/Toast';import DashboardLayout from './layouts/DashboardLayout';import Dashboard from './pages/Dashboard';@@ -188,10 +189,12 @@ function App() {<PageTitleUpdater /><ThemeProvider><AuthProvider>- <ToastProvider>- <AppRoutes />- <ToastContainer />- </ToastProvider>+ <ResourceTierProvider>+ <ToastProvider>+ <AppRoutes />+ <ToastContainer />+ </ToastProvider>+ </ResourceTierProvider></AuthProvider></ThemeProvider></Router>diff --git a/frontend/src/assets/ServerKitLogo.svg b/frontend/src/assets/ServerKitLogo.svgnew file mode 100644index 00000000..bd8461b4--- /dev/null+++ b/frontend/src/assets/ServerKitLogo.svg@@ -0,0 +1,15 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 2048 2048">+ <defs>+ <linearGradient id="brandGradient" x1="0%" y1="0%" x2="100%" y2="100%">+ <stop offset="0%" stop-color="#6366f1"/>+ <stop offset="100%" stop-color="#4f46e5"/>+ </linearGradient>+ </defs>+ <path fill="url(#brandGradient)" d="M169.61,1878.37c-58.74-56.76-93.82-135.58-99.4-217.52l.07-1284.1C80.47,209.28,209.08,77.66,377.92,70.27l1289.92-.07c173.25,6.73,300.76,139.7,309.9,311.19l.06,1279.44c-10.02,173.54-152.93,308.11-325.14,316.88l-1255.02.07c-87.51-5.09-165.43-38.95-228.02-99.43ZM1600.9,819.3v-69.2l1.69-1.47c59.31,8.75,119.93-21.99,131.77-83.73-.72-71.44,5.91-148.48,1.5-219.58-3.43-55.29-41.89-95.55-97.11-100.61-413.15,1.13-826.62-1.98-1239.58,1.56-51.76,10.06-83.97,47.53-87.04,100.22-3.95,67.93,2.93,139.76.2,208.09,4.42,37.49,26.63,70.13,61.53,85.02,23.73,10.12,47.78,10.56,73.24,9.92v68.04l-1.74,1.74h-40.71c-45.8,0-92.81,51.61-92.51,97.07,3.38,69-4.35,142.03.06,210.56,3.45,53.53,45.33,92.53,98.22,96.01,9.99.66,24.77-1.69,33.78-.05,1.3.24,2.18.59,2.91,1.74v68.04c-24.94.44-50.51-.87-73.69,9.47-33.62,15-57.82,47.15-61.08,84.31-5.99,68.38,4.22,144.71-.21,213.92,3.28,52.32,44.65,90.9,95.96,95.95h1229.5c51.94-2.48,94.76-42.48,98.27-94.8,4.66-69.44-3.58-144.06-.06-214.04-3.42-45.19-36.88-83.18-81.39-91.91-17.66-3.46-35.59-3-53.51-2.9v-69.79c25.25-.07,50.09,2.08,73.69-8.31,33.21-14.62,58.51-47.53,61.21-84.17,5.14-69.51-3.85-145.06.06-215.21.59-44-45.85-95.91-90.19-95.91h-44.78Z"/>+ <path fill="url(#brandGradient)" d="M1645.86,904.61c3.93,3.68,5.98,9.92,6.26,15.26l-.03,202.43c-1.99,12.99-7.56,18.2-20.23,20.58-366.99.71-735.14,1.01-1102.74.1-34.1-.08-74.96,3.4-108.21.86-12.89-.98-23.01-8.16-24.86-21.66-3.47-25.29,2.96-56.74-.82-82.67,4.31-38.56-3.36-82.85.71-120.78,1.27-11.82,9.02-18.56,20.49-20.22l1209.55-.18c6.82.6,14.7,1.41,19.9,6.28ZM1209.84,975.47c-55.44,6.6-51.14,94.89,7.75,93.93,63.57-1.04,59.56-101.94-7.75-93.93ZM1365.67,975.45c-61.66,8.44-45.2,107.48,17.76,92.2,56.18-13.63,41.64-100.33-17.76-92.2ZM1496.63,1056.16c43.4,42.6,108.56-24.61,64.2-68.27-43.1-42.42-108.68,24.61-64.2,68.27Z"/>+ <path fill="url(#brandGradient)" d="M415.4,1373.21l1215.01-.13c25.54,2.02,22.46,28.97,22.91,48.11,1.15,49.88,1.8,107.07-.04,157.09-.77,21.02-.79,36.94-26.17,38.94l-1211.71-.32c-7.31-1.22-17.24-9.74-19.19-16.87-2.27-69.63-2.66-140.15.23-209.73,2.3-9.69,9.95-14.4,18.96-17.1ZM1250.4,1462.9c-43.81-44.48-111.6,23.9-65.76,67.51,43.96,41.83,107.52-25.1,65.76-67.51ZM1528.49,1449.01c-62.25,2.08-59.67,94.67.89,93.82,62.28-.87,57.86-95.78-.89-93.82ZM1405.09,1529.54c43.25-43.24-20.92-110.55-65.3-67.04-43.23,42.39,21.83,110.51,65.3,67.04Z"/>+ <path fill="url(#brandGradient)" d="M1645.85,661.88c-4.26,4.57-12.49,7.41-18.74,7.43l-1209.54-.18c-11-1.22-20.4-10.28-21.65-21.38-1.98-17.63-1.14-44.43-1.24-62.82-.16-30.33.12-61.22.39-91.85.13-14.24-.86-35.49.95-48.78,1.42-10.46,10.9-18.83,21.37-19.34l1215.38.15c9.9,1.79,17.37,9.17,19.32,19.06v201.29c-.4,5.39-2.54,12.44-6.25,16.42ZM1339.61,513.81c-22.99,22.96-15.41,64.43,15.44,76.2,40.12,15.3,76.94-24.03,59.6-63.09-13.09-29.5-52.45-35.68-75.05-13.11ZM1207.49,500.91c-44.94,6.5-51.92,79.05-2.34,91.29,71.33,17.61,80.68-102.62,2.34-91.29ZM1519.2,500.91c-48.7,7.04-50.02,89.18,6.69,92.72,66.96,4.19,64.61-103.04-6.69-92.72Z"/>+ <polygon fill="url(#brandGradient)" points="1518.32 1222.89 1518.18 1293.71 1516.56 1293.93 531.45 1293.8 529.04 1292.74 528.53 1222.89 1518.32 1222.89"/>+ <polygon fill="url(#brandGradient)" points="1518.32 749.51 1518.32 819.3 529.69 819.3 529.69 748.34 1518.32 749.51"/>+</svg>diff --git a/frontend/src/assets/favicon/favicon-16x16.png b/frontend/src/assets/favicon/favicon-16x16.pngnew file mode 100644index 00000000..00248b94Binary files /dev/null and b/frontend/src/assets/favicon/favicon-16x16.png differdiff --git a/frontend/src/assets/favicon/favicon-32x32.png b/frontend/src/assets/favicon/favicon-32x32.pngnew file mode 100644index 00000000..2e751b60Binary files /dev/null and b/frontend/src/assets/favicon/favicon-32x32.png differdiff --git a/frontend/src/assets/favicon/favicon.ico b/frontend/src/assets/favicon/favicon.iconew file mode 100644index 00000000..cb0748f3Binary files /dev/null and b/frontend/src/assets/favicon/favicon.ico differdiff --git a/frontend/src/components/ResourceGate.jsx b/frontend/src/components/ResourceGate.jsxnew file mode 100644index 00000000..47f34961--- /dev/null+++ b/frontend/src/components/ResourceGate.jsx@@ -0,0 +1,125 @@+import React from 'react';+import { AlertTriangle, Cpu, HardDrive, Server, ArrowUpCircle } from 'lucide-react';+import { useResourceTier } from '../contexts/ResourceTierContext';++const ResourceGate = ({ children, feature = 'wordpress_create' }) => {+ const {+ tier,+ specs,+ features,+ loading,+ isLiteTier,+ canCreateWordPress+ } = useResourceTier();++ // While loading, show nothing or a skeleton+ if (loading) {+ return children;+ }++ // Check if the specific feature is blocked+ const isBlocked = feature === 'wordpress_create' && !canCreateWordPress;++ if (!isBlocked) {+ return children;+ }++ // Minimum requirements+ const minCores = 2;+ const minRamGb = 2;++ return (+ <div className="resource-gate">+ <div className="resource-gate-container">+ <div className="resource-gate-icon">+ <AlertTriangle size={48} />+ </div>++ <h2 className="resource-gate-title">Server Resources Insufficient</h2>++ <p className="resource-gate-description">+ WordPress site creation requires more server resources than currently available.+ Your server is classified as a <strong>Lite</strong> tier server.+ </p>++ <div className="resource-gate-specs">+ <div className="resource-gate-spec-card current">+ <div className="resource-gate-spec-header">+ <Server size={18} />+ <span>Your Server</span>+ </div>+ <div className="resource-gate-spec-items">+ <div className="resource-gate-spec-item">+ <Cpu size={16} />+ <span className="spec-label">CPU Cores</span>+ <span className="spec-value insufficient">+ {specs?.cpu_cores || '?'}+ </span>+ </div>+ <div className="resource-gate-spec-item">+ <HardDrive size={16} />+ <span className="spec-label">RAM</span>+ <span className="spec-value insufficient">+ {specs?.ram_gb || '?'} GB+ </span>+ </div>+ </div>+ </div>++ <div className="resource-gate-spec-arrow">+ <ArrowUpCircle size={24} />+ </div>++ <div className="resource-gate-spec-card required">+ <div className="resource-gate-spec-header">+ <Server size={18} />+ <span>Minimum Required</span>+ </div>+ <div className="resource-gate-spec-items">+ <div className="resource-gate-spec-item">+ <Cpu size={16} />+ <span className="spec-label">CPU Cores</span>+ <span className="spec-value">{minCores}+</span>+ </div>+ <div className="resource-gate-spec-item">+ <HardDrive size={16} />+ <span className="spec-label">RAM</span>+ <span className="spec-value">{minRamGb}+ GB</span>+ </div>+ </div>+ </div>+ </div>++ <div className="resource-gate-recommendation">+ <h4>Recommendation</h4>+ <p>+ Upgrade your server to at least <strong>{minCores} CPU cores</strong> and{' '}+ <strong>{minRamGb}GB RAM</strong> to enable WordPress site creation.+ A <strong>Standard</strong> or <strong>Performance</strong> tier server+ is recommended for optimal WordPress performance.+ </p>+ </div>++ <div className="resource-gate-tiers">+ <div className={`resource-gate-tier ${tier === 'lite' ? 'current' : ''}`}>+ <div className="tier-name">Lite</div>+ <div className="tier-specs">1 core or <2GB RAM</div>+ <div className="tier-wp">WordPress: Blocked</div>+ </div>+ <div className={`resource-gate-tier ${tier === 'standard' ? 'current' : ''}`}>+ <div className="tier-name">Standard</div>+ <div className="tier-specs">2-3 cores, 2-4GB RAM</div>+ <div className="tier-wp allowed">WordPress: Allowed</div>+ </div>+ <div className={`resource-gate-tier ${tier === 'performance' ? 'current' : ''}`}>+ <div className="tier-name">Performance</div>+ <div className="tier-specs">4+ cores, >4GB RAM</div>+ <div className="tier-wp allowed">WordPress: Allowed</div>+ </div>+ </div>+ </div>+ </div>+ );+};++export default ResourceGate;diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsxindex a4fd9d27..d6c0c0a6 100644--- a/frontend/src/components/Sidebar.jsx+++ b/frontend/src/components/Sidebar.jsx@@ -2,6 +2,7 @@ import React from 'react';import { NavLink } from 'react-router-dom';import { useAuth } from '../contexts/AuthContext';import { Github, Star } from 'lucide-react';+import ServerKitLogo from '../assets/ServerKitLogo.svg';const Sidebar = () => {const { user, logout } = useAuth();@@ -10,9 +11,7 @@ const Sidebar = () => {<aside className="sidebar"><div className="brand-section"><div className="brand-logo">- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2.5">- <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>- </svg>+ <img src={ServerKitLogo} alt="ServerKit" width="28" height="28" /></div><span className="brand-text">ServerKit</span></div>diff --git a/frontend/src/contexts/AuthContext.jsx b/frontend/src/contexts/AuthContext.jsxindex 1a4290ad..0a86c26e 100644--- a/frontend/src/contexts/AuthContext.jsx+++ b/frontend/src/contexts/AuthContext.jsx@@ -102,6 +102,7 @@ export function AuthProvider({ children }) {const value = {user,+ setUser,loading,login,register,diff --git a/frontend/src/contexts/ResourceTierContext.jsx b/frontend/src/contexts/ResourceTierContext.jsxnew file mode 100644index 00000000..ed7a4691--- /dev/null+++ b/frontend/src/contexts/ResourceTierContext.jsx@@ -0,0 +1,69 @@+import React, { createContext, useContext, useState, useEffect } from 'react';+import api from '../services/api';+import { useAuth } from './AuthContext';++const ResourceTierContext = createContext(null);++export function ResourceTierProvider({ children }) {+ const { isAuthenticated, isAdmin } = useAuth();+ const [tierInfo, setTierInfo] = useState(null);+ const [loading, setLoading] = useState(true);+ const [error, setError] = useState(null);++ useEffect(() => {+ if (isAuthenticated && isAdmin) {+ fetchTierInfo();+ } else {+ setLoading(false);+ }+ }, [isAuthenticated, isAdmin]);++ async function fetchTierInfo(forceRefresh = false) {+ try {+ setLoading(true);+ setError(null);+ const endpoint = forceRefresh+ ? '/system/resource-tier?refresh=true'+ : '/system/resource-tier';+ const data = await api.request(endpoint);+ setTierInfo(data);+ } catch (err) {+ console.error('Failed to fetch resource tier:', err);+ setError(err.message || 'Failed to fetch resource tier');+ } finally {+ setLoading(false);+ }+ }++ async function refresh() {+ return fetchTierInfo(true);+ }++ const value = {+ tier: tierInfo?.tier || null,+ specs: tierInfo?.specs || null,+ features: tierInfo?.features || {},+ cached: tierInfo?.cached || false,+ loading,+ error,+ refresh,+ canCreateWordPress: tierInfo?.features?.wordpress_create ?? true,+ isLiteTier: tierInfo?.tier === 'lite',+ isStandardTier: tierInfo?.tier === 'standard',+ isPerformanceTier: tierInfo?.tier === 'performance',+ };++ return (+ <ResourceTierContext.Provider value={value}>+ {children}+ </ResourceTierContext.Provider>+ );+}++export function useResourceTier() {+ const context = useContext(ResourceTierContext);+ if (!context) {+ throw new Error('useResourceTier must be used within a ResourceTierProvider');+ }+ return context;+}diff --git a/frontend/src/pages/Login.jsx b/frontend/src/pages/Login.jsxindex 96652387..58affc30 100644--- a/frontend/src/pages/Login.jsx+++ b/frontend/src/pages/Login.jsx@@ -2,6 +2,7 @@ import React, { useState, useRef, useEffect } from 'react';import { useNavigate, Link } from 'react-router-dom';import { useAuth } from '../contexts/AuthContext';import api from '../services/api';+import ServerKitLogo from '../assets/ServerKitLogo.svg';const Login = () => {const [email, setEmail] = useState('');@@ -222,9 +223,7 @@ const Login = () => {<div className="auth-card"><div className="auth-header"><div className="brand-logo">- <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>- </svg>+ <img src={ServerKitLogo} alt="ServerKit" width="40" height="40" /></div><h1>ServerKit</h1><p>Sign in to your account</p>diff --git a/frontend/src/pages/Register.jsx b/frontend/src/pages/Register.jsxindex 67034e55..1eef052d 100644--- a/frontend/src/pages/Register.jsx+++ b/frontend/src/pages/Register.jsx@@ -1,6 +1,7 @@import React, { useState } from 'react';import { useNavigate, Link } from 'react-router-dom';import { useAuth } from '../contexts/AuthContext';+import ServerKitLogo from '../assets/ServerKitLogo.svg';const Register = () => {const [email, setEmail] = useState('');@@ -43,9 +44,7 @@ const Register = () => {<div className="auth-card"><div className="auth-header"><div className="brand-logo">- <svg viewBox="0 0 24 24" width="32" height="32" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/>- </svg>+ <img src={ServerKitLogo} alt="ServerKit" width="40" height="40" /></div><h1>ServerKit</h1><p>Create your account</p>diff --git a/frontend/src/pages/WordPress.jsx b/frontend/src/pages/WordPress.jsxindex 6c1a51e6..04018cc6 100644--- a/frontend/src/pages/WordPress.jsx+++ b/frontend/src/pages/WordPress.jsx@@ -2,10 +2,13 @@ import React, { useState, useEffect } from 'react';import { Plus, RefreshCw } from 'lucide-react';import wordpressApi from '../services/wordpress';import { useToast } from '../contexts/ToastContext';+import { useResourceTier } from '../contexts/ResourceTierContext';import { WordPressSiteCard, CreateSiteModal } from '../components/wordpress';+import ResourceGate from '../components/ResourceGate';const WordPress = () => {const toast = useToast();+ const { canCreateWordPress, isLiteTier } = useResourceTier();const [sites, setSites] = useState([]);const [loading, setLoading] = useState(true);const [showCreateModal, setShowCreateModal] = useState(false);@@ -110,6 +113,17 @@ const WordPress = () => {</div>);+ // Show resource gate if on lite tier and no sites exist+ if (isLiteTier && sites.length === 0 && !loading) {+ return (+ <div className="docker-page-new wordpress-page">+ <ResourceGate feature="wordpress_create">+ <div />+ </ResourceGate>+ </div>+ );+ }+return (<div className="docker-page-new wordpress-page"><div className="docker-page-header">@@ -120,7 +134,12 @@ const WordPress = () => {</div></div><div className="docker-page-actions">- <button className="btn btn-primary" onClick={() => setShowCreateModal(true)}>+ <button+ className="btn btn-primary"+ onClick={() => setShowCreateModal(true)}+ disabled={!canCreateWordPress}+ title={!canCreateWordPress ? 'Server resources insufficient for WordPress creation' : ''}+ ><Plus size={16} /> New Site</button></div>diff --git a/frontend/src/styles/layout/_sidebar.less b/frontend/src/styles/layout/_sidebar.lessindex 6d99386f..26a11679 100644--- a/frontend/src/styles/layout/_sidebar.less+++ b/frontend/src/styles/layout/_sidebar.less@@ -32,12 +32,14 @@.brand-logo {width: 28px;height: 28px;- background: linear-gradient(135deg, @accent-primary, darken(@accent-primary, 10%));- border-radius: @radius-lg;display: grid;place-items: center;- color: white;- box-shadow: 0 4px 12px @accent-shadow;+ flex-shrink: 0;++ img {+ width: 100%;+ height: 100%;+ }}.brand-text {diff --git a/frontend/src/styles/pages/_wordpress.less b/frontend/src/styles/pages/_wordpress.lessindex 2d166f7c..01cc9d1d 100644--- a/frontend/src/styles/pages/_wordpress.less+++ b/frontend/src/styles/pages/_wordpress.less@@ -1132,3 +1132,214 @@}}}++// ============================================+// RESOURCE GATE - BLOCKED STATE UI+// ============================================++.resource-gate {+ display: flex;+ align-items: center;+ justify-content: center;+ min-height: 60vh;+ padding: @space-6;+}++.resource-gate-container {+ max-width: 700px;+ text-align: center;+}++.resource-gate-icon {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 80px;+ height: 80px;+ background: fade(@color-warning, 12%);+ border-radius: 50%;+ color: @color-warning;+ margin-bottom: @space-5;+}++.resource-gate-title {+ font-size: @font-size-xl;+ font-weight: @font-weight-bold;+ color: @text-primary;+ margin: 0 0 @space-3;+}++.resource-gate-description {+ font-size: @font-size-base;+ color: @text-secondary;+ margin: 0 0 @space-6;+ line-height: 1.6;++ strong {+ color: @color-warning;+ font-weight: @font-weight-semibold;+ }+}++.resource-gate-specs {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-4;+ margin-bottom: @space-6;++ @media (max-width: 600px) {+ flex-direction: column;+ gap: @space-3;+ }+}++.resource-gate-spec-arrow {+ color: @text-tertiary;++ @media (max-width: 600px) {+ transform: rotate(90deg);+ }+}++.resource-gate-spec-card {+ background: @bg-card;+ border: 1px solid @border-subtle;+ border-radius: @radius-lg;+ padding: @space-4;+ min-width: 200px;++ &.current {+ border-color: fade(@color-danger, 40%);+ background: fade(@color-danger, 4%);+ }++ &.required {+ border-color: fade(@color-success, 40%);+ background: fade(@color-success, 4%);+ }+}++.resource-gate-spec-header {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: @space-2;+ font-size: @font-size-sm;+ font-weight: @font-weight-semibold;+ color: @text-primary;+ margin-bottom: @space-3;+ padding-bottom: @space-2;+ border-bottom: 1px solid @border-subtle;+}++.resource-gate-spec-items {+ display: flex;+ flex-direction: column;+ gap: @space-2;+}++.resource-gate-spec-item {+ display: flex;+ align-items: center;+ gap: @space-2;+ font-size: @font-size-sm;++ svg {+ color: @text-tertiary;+ flex-shrink: 0;+ }++ .spec-label {+ color: @text-secondary;+ flex: 1;+ }++ .spec-value {+ font-weight: @font-weight-semibold;+ color: @color-success;+ font-family: @font-family-mono;++ &.insufficient {+ color: @color-danger;+ }+ }+}++.resource-gate-recommendation {+ background: @bg-tertiary;+ border: 1px solid @border-subtle;+ border-radius: @radius-lg;+ padding: @space-4;+ margin-bottom: @space-6;+ text-align: left;++ h4 {+ font-size: @font-size-sm;+ font-weight: @font-weight-semibold;+ color: @text-primary;+ margin: 0 0 @space-2;+ }++ p {+ font-size: @font-size-sm;+ color: @text-secondary;+ margin: 0;+ line-height: 1.5;++ strong {+ color: @text-primary;+ }+ }+}++.resource-gate-tiers {+ display: grid;+ grid-template-columns: repeat(3, 1fr);+ gap: @space-3;++ @media (max-width: 600px) {+ grid-template-columns: 1fr;+ }+}++.resource-gate-tier {+ background: @bg-card;+ border: 1px solid @border-subtle;+ border-radius: @radius-md;+ padding: @space-3;+ text-align: center;++ &.current {+ border-color: @color-warning;+ background: fade(@color-warning, 6%);+ }++ .tier-name {+ font-size: @font-size-sm;+ font-weight: @font-weight-bold;+ color: @text-primary;+ margin-bottom: @space-1;+ }++ .tier-specs {+ font-size: @font-size-xs;+ color: @text-tertiary;+ margin-bottom: @space-2;+ }++ .tier-wp {+ font-size: @font-size-xs;+ font-weight: @font-weight-medium;+ color: @color-danger;+ padding: 2px 8px;+ background: fade(@color-danger, 10%);+ border-radius: @radius-sm;+ display: inline-block;++ &.allowed {+ color: @color-success;+ background: fade(@color-success, 10%);+ }+ }+}diff --git a/scripts/dev/setup-wsl.sh b/scripts/dev/setup-wsl.shindex bb6bd149..b7f01767 100644--- a/scripts/dev/setup-wsl.sh+++ b/scripts/dev/setup-wsl.sh@@ -46,23 +46,25 @@ source venv/bin/activatepip install --upgrade pip -qpip install -r requirements.txt -q-# Create instance directory in WSL-native location (SQLite doesn't work on /mnt/c)-mkdir -p ~/.serverkit+# Create instance directorymkdir -p instance-# Create .env with WSL-compatible database path-cat > .env << EOF+# Create .env if it doesn't exist (don't overwrite existing config)+if [ ! -f .env ]; then+ cat > .env << EOFFLASK_ENV=developmentFLASK_DEBUG=1-SECRET_KEY=dev-secret-key-DATABASE_URL=sqlite:///$HOME/.serverkit/serverkit.db+SECRET_KEY=dev-secret-key-change-in-production+JWT_SECRET_KEY=jwt-secret-key-change-in-production+DATABASE_URL=sqlite:///instance/serverkit.dbEOF+fiecho -e "${GREEN}Done!${NC}"echo -e "${YELLOW}[5/6] Setting up frontend...${NC}"cd "$PROJECT_ROOT/frontend"npm install-[ ! -f .env.development ] && echo "VITE_API_URL=http://localhost:5000" > .env.development+[ ! -f .env.development ] && echo "VITE_API_URL=http://localhost:5000/api/v1" > .env.developmentecho -e "${GREEN}Done!${NC}"echo -e "${YELLOW}[6/6] Creating admin user...${NC}"@@ -74,15 +76,15 @@ sys.path.insert(0, os.getcwd())try:from app import create_app, dbfrom app.models.user import User- from werkzeug.security import generate_password_hashapp = create_app()with app.app_context():db.create_all()admin = User.query.filter_by(username='admin').first()if admin:- admin.password = generate_password_hash('admin')+ admin.set_password('admin')else:- admin = User(username='admin', email='admin@localhost', password=generate_password_hash('admin'), is_admin=True)+ admin = User(username='admin', email='admin@localhost', role='admin', is_active=True)+ admin.set_password('admin')db.session.add(admin)db.session.commit()print("Admin user ready!")