{"id":31813026,"url":"https://github.com/daffadevhosting/jekyll-studio-api","last_synced_at":"2026-04-29T16:09:32.250Z","repository":{"id":311716639,"uuid":"1044700577","full_name":"daffadevhosting/jekyll-studio-api","owner":"daffadevhosting","description":"Backend API Next.js dengan integrasi Gemini AI untuk Jekyll Studio webapp. API ini menyediakan endpoints lengkap untuk membuat, mengelola, dan meng-deploy Jekyll sites menggunakan AI.","archived":false,"fork":false,"pushed_at":"2025-08-30T01:58:21.000Z","size":313,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-11T07:46:50.069Z","etag":null,"topics":["docker-compose","gemini-ai","jekyll-ecosystem","nextjs"],"latest_commit_sha":null,"homepage":"https://jekyll-studio-api.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daffadevhosting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-26T04:54:33.000Z","updated_at":"2025-08-30T01:58:24.000Z","dependencies_parsed_at":"2025-08-26T07:07:29.365Z","dependency_job_id":"93df6db6-6cf7-4047-9f39-4d0c1aa77f97","html_url":"https://github.com/daffadevhosting/jekyll-studio-api","commit_stats":null,"previous_names":["daffadevhosting/jekyll-studio-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daffadevhosting/jekyll-studio-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daffadevhosting%2Fjekyll-studio-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daffadevhosting%2Fjekyll-studio-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daffadevhosting%2Fjekyll-studio-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daffadevhosting%2Fjekyll-studio-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daffadevhosting","download_url":"https://codeload.github.com/daffadevhosting/jekyll-studio-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daffadevhosting%2Fjekyll-studio-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32433083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","gemini-ai","jekyll-ecosystem","nextjs"],"created_at":"2025-10-11T07:46:24.207Z","updated_at":"2026-04-29T16:09:32.229Z","avatar_url":"https://github.com/daffadevhosting.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jekyll Studio API - Next.js Backend\n\nBackend API Next.js dengan integrasi Gemini AI untuk Jekyll Studio webapp. API ini menyediakan endpoints lengkap untuk membuat, mengelola, dan men-deploy Jekyll sites menggunakan AI.\n\nTerinspirasi dari **\"Firebase Studio, tapi untuk Jekyll\"** membangun fondasi backend yang solid dan canggih untuk melakukan persis seperti **Firebase Studio**.\n\n1.  **Backend Terkelola (Managed Backend)**: Sama seperti Firebase yang menyediakan backend siap pakai, proyek ini juga menyediakan API yang mengabstraksi semua kerumitan. Pengguna frontend tidak perlu tahu cara install Ruby, menjalankan `jekyll build`, atau mengelola Docker. Mereka tinggal klik satu tombol di UI.\n\n2.  **Fungsi Inti Yang Sudah Siap**:\n    * **\"Authentication/Database\" (Manajemen Situs)**: Punya sistem untuk membuat, melihat, dan menghapus \"proyek\" atau situs.\n    * **\"Hosting\" (Build \u0026 Serve)**: Punya endpoint untuk men-deploy (`jekyll serve`) dan membangun (`jekyll build`) situs.\n    * **\"Cloud Functions\" (AI \u0026 Kustomisasi)**: Menggunakan kekuatan AI dari **Gemini** sebagai \"fungsi cloud\" untuk men-generate seluruh struktur situs dari sebuah prompt, sesuatu yang sangat modern.\n    * **\"Storage\" (File Management)**: Punya API untuk eksplorasi, membaca, dan menulis file di dalam setiap situs Jekyll.\n\n---\n\n## 🚀 Features\n\n- ✅ **Gemini AI Integration** - Generate Jekyll sites dari natural language prompts\n- ✅ **Jekyll Container Management** - Automated Jekyll site creation dan building\n- ✅ **Real-time Updates** - WebSocket untuk live updates dan file changes\n- ✅ **File Management** - CRUD operations untuk Jekyll files\n- ✅ **Security** - Rate limiting, CORS, input validation\n- ✅ **Multi-site Support** - Handle multiple Jekyll sites simultaneously\n- ✅ **Live Preview** - Development server dengan live reload\n\n## 📋 Prerequisites\n\n- Node.js 18+\n- Docker \u0026 Docker Compose\n- Gemini AI API Key\n\n## ⚡ Quick Start\n\n### 1. Clone dan Setup\n```bash\ngit clone https://github.com/daffadevhosting/jekyll-studio-api.git\ncd jekyll-studio-api\n```\n\n### 2. Install Dependencies\n```bash\nnpm install\n```\n\n### 3. Environment Configuration\n```bash\ncp .env.example .env\n# Edit .env dengan your API keys\n```\n\n### 4. Start Development Server\n```bash\nnpm run dev\n```\n\n### 5. Start dengan Docker\n```bash\n# Start complete stack\ndocker-compose -f docker-compose.api.yml up -d\n\n# Start only API + Jekyll\ndocker-compose -f docker-compose.api.yml up api jekyll redis\n```\n\n## 📁 Project Structure\n\n```\njekyll-studio-api/\n├── pages/api/                 # Next.js API routes\n│   ├── sites/                # Site management endpoints\n│   ├── ai/                   # AI generation endpoints\n│   └── websocket.ts          # WebSocket server\n├── lib/                      # Core libraries\n│   ├── gemini.ts            # Gemini AI service\n│   ├── jekyll-manager.ts    # Jekyll operations manager\n│   └── utils.ts             # Utility functions\n├── middleware/               # Security middleware\n├── docker/                  # Docker configurations\n├── projects/                # Generated Jekyll sites\n└── templates/               # Jekyll templates\n```\n\n## 🔌 API Endpoints\n\n### Sites Management\n\n#### Create New Site\n```http\nPOST /api/sites/create\nContent-Type: application/json\n\n{\n  \"name\": \"my-blog\",\n  \"prompt\": \"Create a personal tech blog with dark theme and syntax highlighting\"\n}\n```\n\n#### List All Sites\n```http\nGET /api/sites\n```\n\n#### Get Site Details\n```http\nGET /api/sites/[id]\n```\n\n#### Delete Site\n```http\nDELETE /api/sites/[id]\n```\n\n### Site Operations\n\n#### Build Site\n```http\nPOST /api/sites/[id]/build\n```\n\n#### Start Development Server\n```http\nPOST /api/sites/[id]/serve\nContent-Type: application/json\n\n{\n  \"port\": 4001  // optional\n}\n```\n\n#### Stop Development Server\n```http\nDELETE /api/sites/[id]/serve\n```\n\n### File Management\n\n#### List Files\n```http\nGET /api/sites/[id]/files?path=/\n```\n\n#### Read File\n```http\nGET /api/sites/[id]/files?path=_config.yml\n```\n\n#### Update File\n```http\nPUT /api/sites/[id]/files\nContent-Type: application/json\n\n{\n  \"filePath\": \"_posts/2024-01-01-hello-world.md\",\n  \"content\": \"---\\nlayout: post\\ntitle: Hello World\\n---\\n\\nContent here...\"\n}\n```\n\n### AI Generation\n\n#### Generate Site Structure\n```http\nPOST /api/ai/generate\nContent-Type: application/json\n\n{\n  \"type\": \"site\",\n  \"prompt\": \"Create a portfolio website for a web developer\"\n}\n```\n\n#### Generate Component\n```http\nPOST /api/ai/generate\nContent-Type: application/json\n\n{\n  \"type\": \"component\",\n  \"prompt\": \"Create a hero section layout\",\n  \"context\": {\n    \"componentType\": \"layout\"\n  }\n}\n```\n\n#### Generate Styles\n```http\nPOST /api/ai/generate\nContent-Type: application/json\n\n{\n  \"type\": \"styles\",\n  \"prompt\": \"Modern dark theme with purple accents\"\n}\n```\n\n#### Improve Content\n```http\nPOST /api/ai/generate\nContent-Type: application/json\n\n{\n  \"type\": \"improve\",\n  \"prompt\": \"Make this more engaging\",\n  \"context\": {\n    \"content\": \"existing content here\",\n    \"improvements\": \"add more personality and examples\"\n  }\n}\n```\n\n## 🔌 WebSocket Events\n\n### Connect to WebSocket\n```javascript\nconst ws = new WebSocket('ws://localhost:8080');\n\nws.on('message', (data) =\u003e {\n  const event = JSON.parse(data);\n  console.log('Event:', event.type, event.data);\n});\n```\n\n### Event Types\n- `sites` - Initial sites list\n- `siteStatusChanged` - Site status updates\n- `fileChanged` - File change notifications\n- `siteBuilt` - Build completion notifications\n\n## 🛡️ Security Features\n\n### Rate Limiting\n- **API Calls**: 100 requests/minute\n- **AI Generation**: 10 requests/minute  \n- **Site Creation**: 5 sites/5 minutes\n\n### Input Validation\n- XSS protection\n- SQL injection prevention\n- File path traversal protection\n- Site name validation\n\n### CORS Configuration\n- Configurable allowed origins\n- Secure headers\n- Credential support\n\n## 🐳 Docker Deployment\n\n### Development\n```bash\ndocker-compose -f docker-compose.api.yml up -d\n```\n\n### Production\n```bash\n# With HTTPS and database\ndocker-compose -f docker-compose.api.yml --profile production --profile persistence up -d\n```\n\n### Services Included\n- **API**: Next.js application\n- **Jekyll**: Jekyll container for site operations\n- **Redis**: Caching and session storage\n- **Nginx**: Reverse proxy (production)\n- **PostgreSQL**: Data persistence (optional)\n- **FileBrowser**: File management UI (optional)\n\n## 🔧 Configuration\n\n### Environment Variables\n\n#### Required\n```bash\nGEMINI_API_KEY=your_gemini_api_key\nNEXTAUTH_SECRET=your_secure_secret\n```\n\n#### Optional\n```bash\n# Database\nDATABASE_URL=postgresql://user:pass@localhost:5432/jekyll_studio\n\n# Redis\nREDIS_URL=redis://localhost:6379\n\n# Security\nALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com\nRATE_LIMIT_WINDOW_MS=60000\nRATE_LIMIT_MAX_REQUESTS=100\n\n# Email (notifications)\nSMTP_HOST=smtp.gmail.com\nSMTP_PORT=587\nSMTP_USER=your_email@gmail.com\nSMTP_PASS=your_app_password\n```\n\n### Docker Compose Profiles\n- **Default**: API + Jekyll + Redis\n- **Production**: + Nginx with SSL\n- **Persistence**: + PostgreSQL database\n- **Tools**: + FileBrowser for file management\n\n## 📊 Usage Examples\n\n### Frontend Integration\n\n#### React/Next.js Frontend\n```javascript\n// Create new site\nasync function createSite(prompt) {\n  const response = await fetch('/api/sites/create', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({\n      name: 'my-site',\n      prompt: prompt\n    })\n  });\n  \n  return response.json();\n}\n\n// Watch site status\nconst ws = new WebSocket('ws://localhost:8080');\nws.onmessage = (event) =\u003e {\n  const data = JSON.parse(event.data);\n  if (data.type === 'siteStatusChanged') {\n    updateSiteStatus(data.data);\n  }\n};\n```\n\n#### Vue.js Integration\n```javascript\n// composables/useSites.js\nimport { ref, onMounted } from 'vue'\n\nexport function useSites() {\n  const sites = ref([])\n  const loading = ref(false)\n  \n  const createSite = async (siteData) =\u003e {\n    loading.value = true\n    try {\n      const response = await $fetch('/api/sites/create', {\n        method: 'POST',\n        body: siteData\n      })\n      sites.value.push(response.site)\n      return response\n    } finally {\n      loading.value = false\n    }\n  }\n  \n  const fetchSites = async () =\u003e {\n    const response = await $fetch('/api/sites')\n    sites.value = response.sites\n  }\n  \n  onMounted(fetchSites)\n  \n  return { sites, createSite, fetchSites, loading }\n}\n```\n\n### CLI Integration\n\n#### cURL Examples\n```bash\n# Create site\ncurl -X POST http://localhost:3000/api/sites/create \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"blog\", \"prompt\": \"Create a minimalist blog\"}'\n\n# Build site\ncurl -X POST http://localhost:3000/api/sites/{id}/build\n\n# Update file\ncurl -X PUT http://localhost:3000/api/sites/{id}/files \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"filePath\": \"index.md\", \"content\": \"# Hello World\"}'\n```\n\n#### Python Integration\n```python\nimport requests\nimport json\n\nclass JekyllStudioClient:\n    def __init__(self, base_url=\"http://localhost:3000\"):\n        self.base_url = base_url\n    \n    def create_site(self, name, prompt):\n        response = requests.post(\n            f\"{self.base_url}/api/sites/create\",\n            json={\"name\": name, \"prompt\": prompt}\n        )\n        return response.json()\n    \n    def build_site(self, site_id):\n        response = requests.post(\n            f\"{self.base_url}/api/sites/{site_id}/build\"\n        )\n        return response.json()\n    \n    def serve_site(self, site_id, port=None):\n        data = {\"port\": port} if port else {}\n        response = requests.post(\n            f\"{self.base_url}/api/sites/{site_id}/serve\",\n            json=data\n        )\n        return response.json()\n\n# Usage\nclient = JekyllStudioClient()\nsite = client.create_site(\"my-blog\", \"Create a tech blog with dark theme\")\nbuild_result = client.build_site(site['site']['id'])\nserve_result = client.serve_site(site['site']['id'])\n```\n\n## 🧪 Testing\n\n### Unit Tests\n```bash\nnpm run test\n```\n\n### Integration Tests\n```bash\nnpm run test:integration\n```\n\n### API Testing with Postman\nImport the Postman collection:\n```bash\ncurl -o jekyll-studio.postman_collection.json \\\n  https://raw.githubusercontent.com/your-repo/postman-collection.json\n```\n\n### Load Testing\n```bash\n# Install k6\nnpm install -g k6\n\n# Run load tests\nk6 run tests/load-test.js\n```\n\n## 🔍 Monitoring \u0026 Logging\n\n### Health Checks\n```http\nGET /api/health\n```\n\nResponse:\n```json\n{\n  \"status\": \"healthy\",\n  \"timestamp\": \"2024-01-01T00:00:00Z\",\n  \"services\": {\n    \"jekyll\": \"running\",\n    \"redis\": \"connected\",\n    \"database\": \"connected\"\n  }\n}\n```\n\n### Logs\n```bash\n# View API logs\ndocker-compose logs -f api\n\n# View Jekyll container logs\ndocker-compose logs -f jekyll\n\n# View all logs\ndocker-compose logs -f\n```\n\n### Metrics Endpoints\n```http\nGET /api/metrics\n```\n\n## 🚀 Production Deployment\n\n### 1. Environment Setup\n```bash\n# Production environment\ncp .env.example .env.production\n# Configure production values\n```\n\n### 2. Build Production Image\n```bash\ndocker build -t jekyll-studio-api:latest -f Dockerfile.api .\n```\n\n### 3. Deploy with Docker Compose\n```bash\n# Start production stack\ndocker-compose -f docker-compose.api.yml --profile production up -d\n```\n\n### 4. SSL Configuration\n```bash\n# Generate SSL certificates (Let's Encrypt)\ndocker run --rm -v ./nginx/ssl:/etc/letsencrypt \\\n  certbot/certbot certonly --webroot \\\n  -w /var/www/certbot -d yourdomain.com\n```\n\n### 5. Database Migration (if using PostgreSQL)\n```bash\ndocker-compose exec postgres psql -U jekyll_user -d jekyll_studio -f /app/migrations/init.sql\n```\n\n## 🔄 Backup \u0026 Recovery\n\n### Database Backup\n```bash\n# Backup PostgreSQL\ndocker-compose exec postgres pg_dump -U jekyll_user jekyll_studio \u003e backup.sql\n\n# Restore\ndocker-compose exec -T postgres psql -U jekyll_user jekyll_studio \u003c backup.sql\n```\n\n### Sites Backup\n```bash\n# Backup all sites\ntar -czf sites-backup.tar.gz projects/\n\n# Restore\ntar -xzf sites-backup.tar.gz\n```\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n#### 1. Gemini AI Error\n```\nError: GEMINI_API_KEY is required\n```\n**Solution**: Set your Gemini API key in `.env`\n\n#### 2. Docker Permission Error\n```\nError: Permission denied accessing /var/run/docker.sock\n```\n**Solution**: Add user to docker group\n```bash\nsudo usermod -aG docker $USER\n```\n\n#### 3. Port Already in Use\n```\nError: Port 3000 is already in use\n```\n**Solution**: Change port in `.env` or stop conflicting service\n\n#### 4. Jekyll Build Failed\n**Check logs**:\n```bash\ndocker-compose logs jekyll\n```\n\n### Debug Mode\n```bash\n# Enable debug logging\nDEBUG=jekyll-studio:* npm run dev\n```\n\n## 🤝 Contributing\n\n### Development Setup\n```bash\n# Clone repository\ngit clone https://github.com/daffadevhosting/jekyll-studio-api.git\ncd jekyll-studio-api\n\n# Install dependencies\nnpm install\n\n# Start development environment\nnpm run dev\n\n# Run tests\nnpm test\n```\n\n### Code Style\n- ESLint configuration\n- Prettier formatting\n- TypeScript strict mode\n\n### Pull Request Process\n1. Fork repository\n2. Create feature branch\n3. Add tests for new features\n4. Ensure all tests pass\n5. Update documentation\n6. Submit pull request\n\n## 📝 License\n\nCC0 1.0 Universal License - see [LICENSE](LICENSE) file for details.\n\n## 🔗 Links\n\n- **Frontend Repository**: [Jekyll Studio Frontend](https://github.com/daffadevhosting/jekyll-studio-frontend)\n- **Docker Images**: [Docker Hub](https://hub.docker.com/r/daffaaditya/jekyll-studio)\n- **Documentation**: [Full Documentation](https://docs.jekyll-studio.io)\n- **Issues**: [GitHub Issues](https://github.com/daffadevhosting/jekyll-studio-api/issues)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaffadevhosting%2Fjekyll-studio-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaffadevhosting%2Fjekyll-studio-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaffadevhosting%2Fjekyll-studio-api/lists"}