Technical Documentation Overview

28 decembrie 2025
50 Vizualizฤƒri
6 min citire
Complete technical reference: system architecture, database schema, AI integration details, API endpoints, VPS provisioning, security features, deployment pipeline, and troubleshooting guide for developers.
# LiteHost Technical Documentation Complete technical reference for developers, system administrators, and technical users. ## System Architecture ### Infrastructure Stack - **Operating System**: Ubuntu 24.04 LTS - **Web Server**: Nginx 1.26.3 - **Application**: Laravel 11.47.0 (PHP 8.3) - **Database**: MySQL 8.0 - **Admin Panel**: Filament v3 - **Cache**: Redis (optional) - **Queue**: Laravel Queue with database driver ### Application Structure ``` litehost.carphatian.ro/ โ”œโ”€โ”€ app/ โ”‚ โ”œโ”€โ”€ Http/Controllers/ โ”‚ โ”‚ โ”œโ”€โ”€ FrontendController.php โ”‚ โ”‚ โ”œโ”€โ”€ OnboardingController.php โ”‚ โ”‚ โ””โ”€โ”€ VpsManagementController.php โ”‚ โ”œโ”€โ”€ Models/ โ”‚ โ”‚ โ”œโ”€โ”€ Post.php (blog system) โ”‚ โ”‚ โ”œโ”€โ”€ User.php โ”‚ โ”‚ โ””โ”€โ”€ VpsInstance.php โ”‚ โ””โ”€โ”€ Filament/ โ”‚ โ””โ”€โ”€ Clusters/VpsManagement/ (admin cluster) โ”œโ”€โ”€ resources/ โ”‚ โ”œโ”€โ”€ views/ โ”‚ โ”‚ โ”œโ”€โ”€ frontend/ (public pages) โ”‚ โ”‚ โ”œโ”€โ”€ onboarding/ (signup flow) โ”‚ โ”‚ โ””โ”€โ”€ layouts/ (templates) โ”‚ โ””โ”€โ”€ css/app.css (Tailwind) โ”œโ”€โ”€ routes/ โ”‚ โ””โ”€โ”€ web.php (all routes) โ””โ”€โ”€ database/ โ””โ”€โ”€ migrations/ ``` ## Database Schema ### Key Tables **users** - Authentication & accounts ```sql - id, name, email, password - email_verified_at - remember_token - created_at, updated_at ``` **posts** - Blog system ```sql - id, title, slug, content, excerpt - featured_image, status (draft/published) - user_id, category_id, published_at - translations (title, content, excerpt) - views, featured, allow_comments ``` **vps_instances** - VPS management (planned) ```sql - id, user_id, name, hostname - cpu, ram, storage - os, status (active/suspended) - ip_address, ssh_key - plan_tier (free/premium/pro) ``` **subscriptions** - Billing (in progress) ```sql - id, user_id, stripe_id - plan_name, status - trial_ends_at, ends_at - created_at, updated_at ``` ## AI Integration ### Website Builder AI **Planned Implementation:** - OpenAI GPT-4 for content generation - Natural language to HTML/CSS conversion - Chat-based editing interface - Template selection via conversation **API Endpoint (planned):** ```php POST /api/ai/generate-site { "business_type": "restaurant", "description": "Italian restaurant...", "pages": ["home", "menu", "contact"], "style": "modern, warm colors" } Response: { "site_id": "uuid", "pages": [...generated HTML...], "css": "...generated styles..." } ``` ### VPS AI Assistant **Implementation:** - SSH command interpreter - Natural language โ†’ Bash translation - System monitoring with AI insights - Automated troubleshooting **Example Flow:** ``` User: "Install WordPress" AI interprets: 1. apt update && apt install nginx php-fpm mysql-server 2. Create database 3. Download WordPress 4. Configure nginx 5. Set permissions ``` ### BYOK Integration **API Key Storage:** - Encrypted in database (AES-256) - Per-user key management - Support for multiple providers - Usage tracking per key **Supported Providers:** ```php 'providers' => [ 'openai' => [ 'models' => ['gpt-4', 'gpt-3.5-turbo'], 'endpoint' => 'https://api.openai.com/v1' ], 'anthropic' => [ 'models' => ['claude-3-opus', 'claude-3-sonnet'], 'endpoint' => 'https://api.anthropic.com/v1' ], 'google' => [ 'models' => ['gemini-pro'], 'endpoint' => 'https://generativelanguage.googleapis.com/v1' ] ] ``` ## API Endpoints (Planned) ### Website Builder API ``` POST /api/sites/create GET /api/sites/{id} PUT /api/sites/{id}/update DELETE /api/sites/{id} POST /api/sites/{id}/publish POST /api/ai/chat (edit via chat) ``` ### VPS Management API ``` POST /api/vps/provision GET /api/vps/{id} POST /api/vps/{id}/start POST /api/vps/{id}/stop POST /api/vps/{id}/restart GET /api/vps/{id}/stats POST /api/vps/{id}/backup ``` ### BYOK API ``` POST /api/keys/add GET /api/keys DELETE /api/keys/{id} GET /api/usage/stats POST /api/ai/custom (use your keys) ``` ## VPS Provisioning System ### Automated Deployment **Technologies:** - Proxmox VE API integration - Cloud-init for initialization - Ansible for configuration (optional) **Provisioning Steps:** 1. User selects plan & OS 2. API call to Proxmox 3. VM created (60 seconds) 4. Cloud-init configures: - Network settings - SSH keys - Firewall rules - AI assistant install 5. IP assigned 6. User notified **Resource Allocation:** ```php 'plans' => [ 'free' => [ 'cpu' => 0.25, // 25% of 1 core 'ram' => 512, // MB 'disk' => 1024, // MB (1GB) 'bandwidth' => 1000 // GB ], 'premium' => [ 'cpu' => 2, // 2 dedicated cores 'ram' => 4096, // 4GB 'disk' => 51200, // 50GB NVMe 'bandwidth' => 5000 ], 'professional' => [ 'cpu' => 4, 'ram' => 16384, // 16GB 'disk' => 204800, // 200GB 'bandwidth' => 10000 ] ] ``` ## Security Features ### Authentication - Laravel Sanctum for API tokens - Email verification required - Password reset via email - Optional 2FA (planned) ### VPS Security - SSH key authentication (no passwords) - UFW firewall auto-configured - Fail2ban for brute-force protection - Automatic security updates - Isolated network per user ### Data Protection - Database backups (daily) - VPS snapshots (hourly for Pro) - Encryption at rest - HTTPS enforced (Let's Encrypt) ### API Security - Rate limiting (10/min free, unlimited premium) - API key rotation - Request signing - IP whitelisting (Pro) ## Performance Optimization ### Caching Strategy ```php // Page caching Cache::remember('homepage', 3600, fn() => view('home')); // API response caching Cache::remember("ai:response:{$hash}", 86400, fn() => $ai->generate()); // Database query caching $posts = Cache::remember('blog:posts', 600, fn() => Post::published()->get() ); ``` ### CDN Integration (Planned) - Cloudflare for static assets - Image optimization - Global edge caching ### Database Optimization - Query indexing on frequently accessed columns - Lazy loading for relationships - Pagination for large datasets ## Monitoring & Logging ### System Monitoring - Server uptime tracking - Resource usage alerts - Error rate monitoring - Response time tracking ### Application Logging ```php // Laravel log channels 'channels' => [ 'daily' => [...], // Daily rotating logs 'slack' => [...], // Critical alerts to Slack 'sentry' => [...], // Error tracking ] ``` ### User Analytics - Page views - User journeys - Conversion tracking - AI usage metrics ## Deployment Pipeline ### Current Setup ```bash # Production server git pull origin main composer install --no-dev npm run build php artisan migrate --force php artisan config:cache php artisan route:cache php artisan view:cache sudo systemctl reload nginx ``` ### Planned CI/CD - GitHub Actions for automated testing - Staging environment - Blue-green deployments - Automated rollbacks ## Development Environment ### Local Setup ```bash git clone https://github.com/your-repo/litehost.git cd litehost composer install npm install cp .env.example .env php artisan key:generate php artisan migrate npm run dev php artisan serve ``` ### Environment Variables ```env APP_NAME="LiteHost" APP_ENV=local APP_URL=http://localhost:8000 DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=litehost # AI API Keys (optional for development) OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... # Stripe (for payments) STRIPE_KEY=pk_test_... STRIPE_SECRET=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_... ``` ## Troubleshooting ### Common Issues **500 Error on Shop Page:** - Check ProductController exists - Verify products table migration - Check error logs: `tail -f storage/logs/laravel.log` **Blog Not Loading:** - Ensure posts table has data - Check Post model relationships - Verify route defined: `php artisan route:list | grep blog` **VPS Not Provisioning:** - Check Proxmox API connectivity - Verify resource quotas - Check queue worker: `php artisan queue:work` **AI Not Responding:** - Verify API keys in .env - Check rate limits - Test API connection: `curl https://api.openai.com/v1/models -H "Authorization: Bearer $KEY"` ### Debug Commands ```bash # Clear all caches php artisan cache:clear php artisan config:clear php artisan route:clear php artisan view:clear # Check queue php artisan queue:work --tries=3 # Database console php artisan tinker # Run tests php artisan test ``` ## Contributing ### Code Standards - PSR-12 coding style - PHPDoc comments - Type hints required - Write tests for new features ### Git Workflow ```bash git checkout -b feature/new-feature git commit -m "Add: new feature description" git push origin feature/new-feature # Create pull request ``` ## Support & Resources - **Documentation**: https://docs.litehost.carphatian.ro - **API Reference**: https://api.litehost.carphatian.ro/docs - **GitHub**: https://github.com/litehost - **Discord**: https://discord.gg/litehost - **Email**: dev@litehost.carphatian.ro ## Roadmap **Q1 2025:** - Complete Stripe integration - Launch VPS provisioning - Deploy website builder MVP **Q2 2025:** - BYOK implementation - Mobile apps (iOS/Android) - Advanced AI features **Q3 2025:** - Team collaboration features - API marketplace - White-label options --- This documentation is regularly updated. Last updated: December 28, 2025

Distribuie articolul:

Articole Similare