เว็บแอปสำหรับจัดการ "สายรหัส" ในรูปแบบต้นไม้ (Tree) รองรับการสร้าง/แก้ไขโครงสร้างสมาชิก, แชร์แบบลิงก์, และระบบสิทธิ์การเข้าถึงผ่าน Supabase Auth
- สร้างและจัดการต้นไม้สายรหัส (Tree CRUD)
- เพิ่ม/แก้ไข/ลบสมาชิกในสายรหัส (Node CRUD)
- แสดงผลแบบ Interactive Canvas (Drag & Drop + Auto Layout)
- แชร์ต้นไม้ด้วยลิงก์ (อ่านอย่างเดียว) และระบบสิทธิ์ผู้ใช้
- Auth ด้วย Supabase และ backend ตรวจสอบ JWT
- Frontend: Next.js (App Router), React, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Go, Connect RPC (gRPC-web compatible), PostgreSQL
- Database/Auth: Supabase
- Infra/Deploy: Docker, Render (backend), Vercel (frontend)
code-tree/
|- frontend/ # Next.js frontend
|- backend/ # Go backend (Connect RPC)
|- proto/ # Protobuf definitions
|- supabase/ # Supabase config + migrations + seed
|- deploy/docker/ # Dockerfiles for dev/prod
|- Makefile # Main task runner
`- DEPLOY.md # Production deployment guide
- Node.js 20+
- npm 10+
- Go 1.25+
- Docker Desktop (optional, for
docker compose) - Supabase CLI (optional, for local DB/migrations)
- Buf CLI (optional, for protobuf generation)
make(optional, used as shortcut commands)
ถ้าใช้ PowerShell แล้วขึ้น make is not recognized ให้ใช้คำสั่งแบบ manual ตาม README นี้ได้เลย (ไม่จำเป็นต้องมี make)
อ้างอิงตัวอย่างจาก backend/.env.example
PORT=8080
DATABASE_URL=postgresql://...
SUPABASE_URL=https://xxxxx.supabase.co
SUPABASE_JWT_SECRET=xxxxx
ALLOWED_ORIGINS=http://localhost:3000NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=xxxxx
NEXT_PUBLIC_GRPC_URL=http://localhost:8080cd frontend && npm install
cd ../backend && go mod downloadถ้ามี
makeอยู่แล้ว ใช้make setupได้เหมือนกัน
cd backend && copy .env.example .envจากนั้นสร้าง frontend/.env.local แล้วใส่ค่า:
NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=xxxxx
NEXT_PUBLIC_GRPC_URL=http://localhost:8080Terminal 1:
cd backend
go run cmd/server/main.goTerminal 2:
cd frontend
npm run devถ้ามี
makeอยู่แล้ว ใช้make devได้
จะได้:
- Frontend:
http://localhost:3000 - Backend health check:
http://localhost:8080/health
docker compose up --buildคำสั่งแบบ manual (ไม่ต้องใช้ make):
cd supabase && supabase startเริ่ม Supabase localcd supabase && supabase db resetreset DB และ apply migrationscd supabase && supabase gen types typescript --local > ../frontend/src/types/database.tsgenerate typescd supabase && supabase linklink Supabase remotecd supabase && supabase db pushpush migrations ไป remote
หรือถ้ามี make:
make db-startเริ่ม Supabase localmake db-resetreset DB และ apply migrationsmake db-mockreset DB + seed mock datamake db-typesgenerate TypeScript types ไปที่frontend/src/types/database.tsmake db-linklink Supabase remote projectmake db-pushpush migrations ไป remote
- แก้ไฟล์
.protoในproto/ - generate code (manual):
buf generateหรือใช้ make proto
ดูขั้นตอนละเอียดที่ DEPLOY.md (Supabase -> Render -> Vercel -> UptimeRobot)
- Backend endpoint:
/health - ตัวอย่าง:
curl http://localhost:8080/healthผลลัพธ์:
{"status":"ok","service":"code-tree-backend"}cd frontend && npm run devรัน frontendcd backend && go run cmd/server/main.goรัน backenddocker compose up --buildรันด้วย Docker Composecd supabase && supabase db resetreset local DBbuf generategenerate protobuf code
ถ้ามี make สามารถใช้ shortcut ใน Makefile ได้ทั้งหมด