# GOFLOW Admin OS v1.0 — Project Brief

> **Project**: GOFLOW Admin OS (Enterprise Control Center)
> **Domain**: `admin.goflow.click`
> **Priority**: P0 · Production Ready
> **Version**: 1.0 · 2026-08-07

## 1. ภาพรวม

GOFLOW Admin OS คือระบบควบคุมกลางของ GOFLOW ทั้งหมด — ใช้สำหรับเจ้าของระบบ, ทีมพัฒนา, ทีม Operation, ลูกค้าองค์กร และ Partner เพื่อบริหาร **GOFLOW Personal AI OS** และ **GOFLOW Enterprise AI OS** จากจุดเดียว

```
GOFLOW OS Ecosystem
├── Personal AI OS      → Dashboard, Family, Finance, Asset, Health, Knowledge
├── Enterprise AI OS    → AI Workforce, Knowledge RAG, Business OS, Marketplace
└── GOFLOW Admin OS     → admin.goflow.click (โครงการนี้)
```

## 2. เป้าหมาย (Goals)

1. เป็น **Command Center** เดียวที่เห็นสถานะทั้งระบบ (System Health, AI Usage, Revenue, Users)
2. บริหาร **Organization / User / Permission** แบบ RBAC ครบวงจร
3. บริหาร **AI Workforce** — สร้าง Agent, กำหนด Level L1–L5, Autonomy, Training, Evolution
4. บริหาร **Knowledge Center** — อัปโหลดเอกสาร, Tag, Version, Embedding, Search Index
5. รองรับ **การขายจริง** — Billing & Subscription (Personal ฟรี / Family 499 / Business 9,900 / Enterprise Custom)
6. มี **Developer Console** — API Keys, Endpoints, SDK, Webhook, Logs

## 3. ขอบเขต (Scope) — 12 หน้า

| # | หน้า | URL | ฟังก์ชันหลัก |
|---|---|---|---|
| 1 | Login | `/login` | ยืนยันตัวตนผ่าน GOFLOW Auth Service (JWT) |
| 2 | Dashboard | `/` | KPI: องค์กร 125 · ผู้ใช้ 25,430 · Agent 100 · API 2.4M + System Health + AI Usage |
| 3 | Organization | `/organizations` | บริษัท/สหกรณ์/จังหวัด/หน่วยงานรัฐ — Profile, Users, Agents, Subscription, Audit |
| 4 | User | `/users` | Personal / Enterprise / Admin / Developer / Partner — Role, Permission, Activity |
| 5 | AI Workforce | `/ai-workforce` | Agent หลัก EMP-AI-001..004 — Skill, Autonomy, Training, Performance, Evolution |
| 6 | Agent | `/agents` | สร้าง Agent ใหม่: Name, Role, Knowledge, Tools, Permission, Autonomy L1–L5 |
| 7 | Knowledge | `/knowledge` | เชื่อม docs/ + knowledge graph + Qdrant + RAG — Upload, Tag, Version, Embedding |
| 8 | Monitoring | `/monitoring` | VPS-1 Core / VPS-2 Data / VPS-3 AI + PM2 14 บริการ + Docker 6 containers |
| 9 | Security | `/security` | Audit Log, API Key, Permission, Login Attack, Backup, Compliance (PDPA/GDPR) |
| 10 | Billing | `/billing` | แพ็กเกจ 4 ระดับ + ใบแจ้งหนี้ |
| 11 | Developer | `/developer` | API Keys, Endpoints `/v1/*`, SDK, Webhook |
| 12 | Settings | `/settings` | ตั้งค่าระบบ, โดเมน, โซนเวลา, ภาษาบริการที่เชื่อม |

## 4. Tech Stack (ใช้ของเดิม)

| ชั้น | เทคโนโลยี |
|---|---|
| Frontend | Next.js 16 · React 19 · TypeScript · TailwindCSS v4 |
| Backend | Fastify · REST API · WebSocket |
| Database | PostgreSQL · Prisma · Redis · Qdrant (Vector) |
| AI | NEXUS AI API · Ollama · OpenAI · RAG · Embedding · Memory |
| Auth | GOFLOW Auth Service · JWT · RBAC · Permission Engine |
| Observability | Prometheus · Grafana · PM2 · Docker |
| Deploy | VPS 103.125.219.110 · nginx · Let's Encrypt (มี SSL แล้ว) |

## 5. โครงสร้าง Code ที่แนะนำ

```
/opt/goflow/apps/admin
├── app/
│   ├── dashboard/  organizations/  users/
│   ├── ai-workforce/  agents/  knowledge/
│   ├── monitoring/  security/  billing/
│   ├── developer/  settings/  login/
├── components/
│   ├── Sidebar.tsx  Header.tsx  MetricCard.tsx
│   ├── DataTable.tsx  Charts.tsx  AIStatus.tsx
├── lib/        (api client, auth, rbac)
└── styles/     (design tokens — Dark Enterprise)
```

> **หมายเหตุ**: ปัจจุบันจัดส่งเป็น **static HTML prototype** ที่ `apps/admin/` (ธีม Dark Enterprise เดียวกับ Portal) — ใช้เป็นต้นแบบ UI/UX และ Proof of Concept ก่อนย้ายเข้า Next.js

## 6. API ที่ต้องเชื่อม (ผ่าน GOFLOW Gateway)

| Endpoint | ใช้กับหน้า |
|---|---|
| `POST /v1/auth/login` | Login |
| `GET /v1/organizations` | Organization |
| `GET/POST /v1/users` | User |
| `GET/POST /v1/agents` | Agent / AI Workforce |
| `POST /v1/ai/chat` | NEXUS AI (ทุกหน้า) |
| `GET /v1/knowledge/search` | Knowledge |
| `GET /v1/metrics/system` | Monitoring |
| `GET /v1/billing/subscriptions` | Billing |

Base URL: `https://api.goflow.click/v1`

## 7. Acceptance Criteria (DoD)

- [ ] Login ผ่าน Auth Service จริง + RBAC แยกบทบาท
- [ ] Dashboard แสดงตัวเลขจาก API จริง (ไม่ hardcode)
- [ ] สร้าง Agent ได้จริง → เขียนลง DB → ขึ้นใน AI Workforce
- [ ] อัปโหลดเอกสาร → สร้าง Embedding → ค้นหา RAG ได้
- [ ] Monitoring ต่อ Prometheus/Grafana จริง
- [ ] ปลอดภัย: HTTPS, JWT expiry, Audit Log ทุกการกระทำ, Backup อัตโนมัติ
- [ ] Responsive — ใช้บนมือถือได้ (sidebar collapse)

## 8. Roadmap

| Phase | ระยะเวลา | งาน |
|---|---|---|
| P0 Prototype (static) | ✅ เสร็จแล้ว | 12 หน้า UI ครบ, deploy ที่ admin.goflow.click |
| P1 Core | 4–6 สัปดาห์ | Next.js + Auth จริง + Dashboard API จริง |
| P2 Management | 6–10 สัปดาห์ | Organization/User/Agent CRUD + RBAC |
| P3 Intelligence | 10–14 สัปดาห์ | Knowledge RAG + Monitoring + Billing จริง |

## 9. ทีมที่ต้องการ

Product Manager · Solution Architect · Frontend (Next.js) · Backend (Fastify) · AI Engineer · Data Engineer · DevOps · UI/UX · QA · Security

---
*เอกสารนี้ใช้เป็น: GitHub Project Brief · ใบเสนอทีมพัฒนา · ส่วนประกอบ Investor Deck*
