Synaplan
Open-source AI platform for companies: self-hosted AI agents, GDPR-compliant chatbot widget, RAG knowledge base, WhatsApp and Outlook AI, MCP, multi-model routing. Docker, Kubernetes or hosted in Germ
ระบบเบิก-รับ-คืน-ซ่อม พาเลทของโรงงาน ผ่านเว็บและ LINE
Translation pending
BusinessTypeScript · PLpgSQLGitHub @nspproductionOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Loading the full README. The saved excerpt is shown below.
Stack: Next.js 16 (App Router, TypeScript) · Prisma 6 · Supabase (Postgres + Storage) · LINE LIFF + Messaging API · Tailwind CSS 4 · Noto Sans Thai สถานะ: MVP เสร็จสมบูรณ์ — auth, master data CRUD, request lifecycle (create/approve/reject/fulfill/cancel), stock ledger, adjustments, dashboard, audit log, LINE Flex notifications, attachment uploadRead the full README ↗
ระบบจัดการการเบิก-คืน-ซ่อม-ตัดจำหน่ายพาเลทหมุนเวียนในโรงงาน
Stack: Next.js 16 (App Router, TypeScript) · Prisma 6 · Supabase (Postgres) · Tailwind CSS 4 · Resend (Email) · Noto Sans Thai
| URL | ผู้ใช้ |
|---|---|
/ | หน้าแรก (เลือกพอร์ทัล) |
/app | พนักงาน — สร้างคำขอ, ดูสถานะ, อนุมัติ |
/manage | Admin / Pallet Manager — Dashboard, จัดการข้อมูล, รายงาน |
/auth/login | เข้าสู่ระบบ (ใช้ได้ทั้ง 2 ฝั่ง) |
/auth/register | สมัครใช้งาน (public) |
/auth/forgot-password | ลืมรหัสผ่าน |
/auth/reset-password | รีเซ็ตรหัสผ่าน |
npm install
.env.localcp .env.example .env.local
เปิด .env.local แล้วกรอกค่าจริง:
# Supabase → Settings → Database → Connection string
# ใช้ Transaction pooler (port 6543) สำหรับ runtime
DATABASE_URL=postgresql://postgres.<ref>:<pass>@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=1
# ใช้ Direct connection (port 5432) สำหรับ prisma migrate เท่านั้น
DIRECT_URL=postgresql://postgres.<ref>:<pass>@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres
# Supabase → Settings → API
SUPABASE_URL=https://<ref>.supabase.co
SUPABASE_ANON_KEY=<anon-key>
SUPABASE_SERVICE_ROLE_KEY=<service-role-key>
# App
APP_URL=http://localhost:3000
# สร้าง SESSION_SECRET ด้วย PowerShell:
# [Convert]::ToBase64String((1..32 | % { Get-Random -Max 256 }))
SESSION_SECRET=<random-32-char-secret>
# Email — ถ้ายังไม่พร้อมใส่ dummy ไปก่อน ระบบยังทำงานได้
RESEND_API_KEY=re_dummy
[email protected]
# Cron — ใช้ random string ใดก็ได้ (ใน local ไม่ถูกเรียก)
CRON_SECRET=any-local-secret
หมายเหตุ: Prisma CLI อ่าน
.envไม่ใช่.env.local— ต้องรันผ่านnpm run db:*เสมอ อย่ารันnpx prismaตรงๆ
# สร้าง Prisma Client
npm run db:generate
# Apply migration สร้างตาราง
npm run db:migrate:deploy
# ใส่ข้อมูลตัวอย่าง (แผนก, ประเภทพาเลท, user ทดสอบ, ยอดสต็อกเริ่มต้น)
npm run db:seed
ข้อมูล seed ที่ได้:
| ชื่อ | Role | สถานะ | |
|---|---|---|---|
[email protected] | Admin | ADMIN | ACTIVE |
[email protected] | หัวหน้าคลังพาเลท ทดสอบ | PALLET_MANAGER | ACTIVE |
[email protected] | พนักงานพัสดุ ทดสอบ | REQUESTER | ACTIVE |
[email protected] | พนักงานผลิต ทดสอบ | REQUESTER | ACTIVE |
[email protected] | พนักงานจ่ายสินค้า ทดสอบ | REQUESTER | ACTIVE |
Seed users ยังไม่มีรหัสผ่าน ใช้ dev-login (dev เท่านั้น) หรือรันคำสั่งด้านล่างเพื่อตั้งรหัสผ่าน
# รูปแบบ: npm run create-admin -- <email> <password> [ชื่อเต็ม]
npm run create-admin -- [email protected] MyPassword123 "ผู้ดูแลระบบ"
npm run dev
เปิด browser:
http://localhost:3000 — หน้าแรกhttp://localhost:3000/auth/login → เข้าสู่ระบบด้วย admin / MyPassword123http://localhost:3000/auth/register → สมัครใช้งาน (public)http://localhost:3000/app → พอร์ทัลพนักงานgit init
git add .
git commit -m "feat: initial pallet system"
git remote add origin https://github.com/<username>/<repo>.git
git push -u origin main
ตรวจสอบว่า
.gitignoreมี.env.local(มีอยู่แล้วใน default Next.js gitignore)
pallet-system (ถ้า repo มี folder นี้)prisma generate && next build)Settings → Environment Variables → ใส่ค่าทั้งหมด (เปลี่ยนจาก local เฉพาะที่ระบุ):
| Key | ค่าสำหรับ Production |
|---|---|
DATABASE_URL | pooled connection (port 6543) ของ Supabase project |
DIRECT_URL | direct connection (port 5432) |
SUPABASE_URL | เหมือน local |
SUPABASE_ANON_KEY | เหมือน local |
SUPABASE_SERVICE_ROLE_KEY | เหมือน local |
APP_URL | https://your-app.vercel.app |
SESSION_SECRET | random ใหม่ (ไม่ซ้ำกับ local) |
RESEND_API_KEY | API key จาก resend.com |
RESEND_FROM | อีเมลที่ verify domain แล้ว เช่น [email protected] |
CRON_SECRET | random ใหม่ สำหรับ cron job |
กด Deploy รอ build เสร็จ (~3 นาที)
รันจากเครื่อง local โดยชี้ไปที่ Production DB:
# Windows PowerShell
$env:DATABASE_URL = "postgresql://postgres.<ref>:<pass>@...supabase.com:6543/postgres?pgbouncer=true&connection_limit=1"
$env:DIRECT_URL = "postgresql://postgres.<ref>:<pass>@...supabase.com:5432/postgres"
npx dotenv-cli -e .env.local -- prisma migrate deploy
npx dotenv-cli -e .env.local -- tsx prisma/seed.ts
npx dotenv-cli -e .env.local -- tsx scripts/create-admin.ts ADMIN-001 StrongPassword123 "ผู้ดูแลระบบ"
หรือตั้ง
DIRECT_URLชั่วคราวใน.env.localให้ชี้ production แล้วรันnpm run db:migrate:deployก็ได้
vercel.json ตั้ง cron ส่ง email จาก outbox ทุก 1 นาทีไว้แล้ว:
{ "path": "/api/cron/send-emails", "schedule": "* * * * *" }
Cron จะทำงานอัตโนมัติหลัง deploy — ตรวจสอบได้ที่ Vercel Dashboard → Functions → Cron Jobs
| คำสั่ง | ทำอะไร |
|---|---|
npm run dev | Dev server |
npm run build | Production build |
npm run lint | ESLint |
npm run typecheck | TypeScript check |
npm test | Vitest unit tests |
npm run test:e2e | Playwright E2E tests (ต้อง server รันอยู่) |
npm run db:generate | Generate Prisma Client |
npm run db:migrate | สร้าง + apply migration (dev) |
npm run db:migrate:deploy | Apply migration ที่มีอยู่ (prod/CI) |
npm run db:seed | โหลด seed data |
npm run db:studio | เปิด Prisma Studio |
npm run db:reset | รีเซ็ต DB ทั้งหมด (ระวัง: ลบข้อมูล) |
npm run create-admin -- <code> <pass> [name] | สร้าง/อัปเดต admin user |
# ติดตั้ง browser (ครั้งแรกเท่านั้น)
npx playwright install chromium
# รัน (ต้องมี dev server รันอยู่ หรือตั้ง PLAYWRIGHT_BASE_URL)
npm run test:e2e
# รัน authenticated tests (ต้องมี user ใน DB)
E2E_ADMIN_USER=ADMIN-001 E2E_ADMIN_PASS=MyPassword123 npm run test:e2e
app/
page.tsx หน้าแรก (เลือกพอร์ทัล)
layout.tsx root layout + Noto Sans Thai
globals.css Tailwind v4 tokens
_components/ UI components ร่วม
portal/ พอร์ทัลพนักงาน (mobile-first, max-w-md)
page.tsx หน้าแรก (session auth → เมนู)
requests/ รายการคำขอ + สร้างใหม่ + รายละเอียด
approvals/ คิวรออนุมัติ + ประวัติ
balance/ ยอดสต็อกในคลัง
warehouse-ops/ จัดการคลัง (ซ่อม, ตัดจำหน่าย)
admin/ Admin console
page.tsx Dashboard (KPI, รายงาน, filter, trend chart)
requests/ จัดการคำขอ
users/ จัดการผู้ใช้
departments/ จัดการแผนก
pallet-types/ จัดการประเภทพาเลท
approval-routes/ ตั้ง approval route
adjustments/ ปรับยอดสต็อก
audit-logs/ Audit log
operating-hours/ ช่วงเวลาทำรายการ
auth/ หน้า login, register, forgot/reset-password
api/ Route Handlers
auth/ me, admin-login, logout
requests/ CRUD + approve/reject/editAndApprove
warehouse-ops/ summary, repair, write-off
dashboard/ summary, export (.xlsx)
cron/ send-emails (cron job)
lib/
auth/ session, current-user, password
services/ business logic (request, warehouse, dashboard, export, email)
prisma.ts Prisma singleton
http/respond.ts ok/fail helpers
prisma/
schema.prisma
seed.ts
migrations/
tests/
setup.ts Vitest global mock
*.test.ts Unit tests (56 tests)
e2e/ Playwright E2E tests
scripts/
create-admin.ts สร้าง admin user
P1012: Environment variable not found: DIRECT_URLPrisma อ่าน .env ไม่ใช่ .env.local — ใช้ npm scripts เสมอ:
npm run db:migrate # ✅
npx prisma migrate dev # ❌ จะเจอ P1012
Can't reach database serverDIRECT_URL ใน Vercel ต้องชี้ port 5432 (direct) ไม่ใช่ 6543 (pooled) — Prisma ใช้ DIRECT_URL ตอน build เพื่อ introspect schema
SESSION_SECRET ต่างกัน = ผู้ใช้ถูก logoutถ้าเปลี่ยน SESSION_SECRET ใน Vercel → session เดิมทั้งหมดจะ invalid — ผู้ใช้ต้อง login ใหม่
RESEND_API_KEY และ RESEND_FROM ใน Vercel Environment VariablesRESEND_FROM ต้องผ่านการ verify ใน Resend dashboardnpm run db:studionpm run db:reset # ลบทุกตาราง + re-migrate + seed อัตโนมัติ
README.md ต้องอัปเดตทุกครั้งที่มีการเปลี่ยนแปลงที่กระทบขั้นตอน run/deploy: