# CodeHub — System Guide & Architecture > **ฉบับเต็ม** — อธิบายทุกอย่างที่ AI ใหม่ต้องรู้ + ทำไมมีบางอย่างในระบบ --- ## 🎯 1. CodeHub คืออะไร **CodeHub** = แพลตฟอร์ม **"versioned code repository + AI-readable instructions"** ที่ **https://codehub.sj88ai.com** - เก็บทุก project พร้อม screenshots, AI prompts/responses, source code - 31 projects / 65+ versions / 200+ files / 90K+ lines - FastAPI backend (26 endpoints) + MCP server (13 tools) + nginx - Kawaii pink theme (sj88ai.com-inspired) ใช้ CSS เดียวกันทั้งเว็บ - ไม่มี password gate บนหน้าหลัก (admin token แยก) --- ## 📁 2. โครงสร้างไฟล์ — ต้องเข้าใจ ### บน VPS `5.231.28.248` ``` /opt/codeship/ship.py ← SHIP SCRIPT (canonical) — symlink ไป /workspace/ship.py /workspace/ship.py ← symlink → /opt/codeship/ship.py (AI รัน path นี้) /mnt/16tb/codehub/ ← 16TB XFS storage ├── api/ FastAPI (systemd: codehub-api) │ ├── app.py 26 endpoints │ ├── db.py, models.py SQLAlchemy │ └── mcp.py 13 MCP tools ├── builder/generate.py Static site generator (idempotent) ├── templates/*.py Python f-string → HTML ├── projects// SOURCE OF TRUTH (filesystem) │ ├── project.json icon/category/desc/tags │ └── versions/vX.Y/ │ ├── meta.json required: {version, date, user_cmd, ai_response, what_changed, ...} │ ├── code/ raw source files │ └── screenshots/ PNG/JPG ├── apps// DEPLOYED APP FILES (served by nginx directly) ├── www/ GENERATED static output ├── www-static/ Hand-written pages (preserved during rebuild) └── .cache/ SQLite + FTS5 ``` ### Key file paths | Path | Purpose | AI Action | |---|---|---| | `/workspace/ship.py` | Ship script | `python3 /workspace/ship.py ...` | | `/opt/codeship/ship.py` | Real script (symlinked) | Don't modify directly | | `/mnt/16tb/codehub/` | CodeHub root | All CodeHub data | | `/mnt/16tb/codehub/projects//` | Project source of truth | Read/write meta.json here | | `/mnt/16tb/codehub/apps//` | Deployed app files | Drop index.html here | | `/mnt/16tb/codehub/www/` | Generated output | **DO NOT EDIT MANUALLY** (regenerated by builder) | | `/etc/nginx/sites-available/codehub.sj88ai.com.conf` | nginx config | Source of truth | | `/etc/nginx/sites-enabled/codehub.sj88ai.com.conf` | nginx active | Symlink of above (or edited copy) | --- ## 🎨 3. The ONE THEME RULE **ALL pages use ONE CSS file: `/assets/base.css`** (670 lines, 28KB) - Has CSS variables in `:root` — change variable → all pages update - Components: nav, hero, buttons, cards, pills, tables, code blocks, lock screen, alerts, callouts - Fonts: Plus Jakarta Sans (body) + JetBrains Mono (code) - Colors: kawaii pink (`--accent: #ec4899`) **To style a new page**: add `` and use the classes (`.btn`, `.card`, `.pill`, etc.). DO NOT write inline `