Tech Stack
ทุก library ที่ใช้ในระบบ พร้อม version (อ้างอิงจาก package.json จริง) และเหตุผลที่เลือก
Backend — apps/api
| Library | Version | บทบาท / เหตุผลที่เลือก |
|---|---|---|
| Node.js | >= 20.0.0 (engines) | LTS, native fetch, top-level await, ES2022 |
| NestJS | ^11.0.0 | Opinionated framework — DI + decorators + module system → maintainable เมื่อโตเกิน 20+ modules. Alternative: Express ตรง ๆ แต่ขาด structure |
| @nestjs/platform-express | ^11.0.0 | Express adapter (อนุรักษ์นิยมกว่า Fastify, ecosystem กว้างกว่า) |
| @nestjs/config | ^4.0.0 | Env var loader + Joi validation schema |
| @nestjs/jwt | ^11.0.0 | JWT signing/verification — wrap jsonwebtoken |
| @nestjs/passport + passport-jwt | ^11.0.0 / ^4.0.1 | Strategy pattern สำหรับ Bearer token |
| @nestjs/swagger | ^11.0.0 | Auto-generate OpenAPI 3 จาก decorators — เปิดเฉพาะ non-prod |
| @nestjs/event-emitter | ^3.0.0 | In-process event bus (สำหรับ webhook trigger, audit, …) |
| Prisma | ^6.0.0 | Type-safe ORM, migration tool, ใช้กับ PostgreSQL pooled + direct URL ได้สะอาด. Alternative: TypeORM (decorator-based แต่ type ไม่แข็งเท่า), Drizzle (ใหม่กว่า, ecosystem เล็กกว่า) |
| @prisma/client | ^6.0.0 | Generated client |
| bcrypt | ^6.0.0 | Password hashing (SALT_ROUNDS=12) |
| class-validator | ^0.14.1 | DTO validation via decorators (@IsString(), @IsUUID(), …) |
| class-transformer | ^0.5.1 | DTO ↔ plain object transformation |
| joi | ^18.2.1 | Validation schema สำหรับ env vars เท่านั้น (Nest ConfigModule integration) |
| exceljs | ^4.4.0 | Generate .xlsx reports |
| pdfkit | ^0.15.0 | Generate PDF labels / receipts |
| multer | ^2.1.1 | File upload (multipart/form-data) |
| @aws-sdk/client-s3 + s3-request-presigner | ^3.1054.0 | S3-compatible client สำหรับ Cloudflare R2 (presigned URLs) |
| uuid | ^11.0.0 | UUID v4 generation (idempotency keys, request IDs) |
| rxjs | ^7.8.1 | Required by NestJS (interceptors) |
| reflect-metadata | ^0.2.2 | Required by NestJS DI |
Frontend — apps/web + apps/admin
ทั้งสอง app ใช้ stack เหมือนกันทุก library (ตั้งใจให้เรียนรู้ง่ายสำหรับทีม dev)
| Library | Version | บทบาท / เหตุผลที่เลือก |
|---|---|---|
| React | ^19.0.0 | UI library — chosen สำหรับ ecosystem + team familiarity. Concurrent features (Suspense, Transitions) ใช้ได้ |
| react-dom | ^19.0.0 | DOM renderer |
| Vite | ^6.0.0 | Build tool — instant HMR, esbuild dep prebundle, native ESM. Alternative: Next.js (เกินจำเป็นเพราะไม่ต้อง SSR), CRA (deprecated) |
| react-router-dom | ^7.0.0 | Client-side routing — data router แต่ใช้แบบ traditional <Routes> |
| @tanstack/react-query | ^5.60.0 | Server state management — cache invalidation, refetching, optimistic update. Alternative: SWR (เล็กกว่า) / Redux Toolkit Query (overkill) |
| axios | ^1.7.0 | HTTP client — interceptor pattern เหมาะกับ JWT inject + 401 redirect |
| tailwindcss | ^3.4.0 | Utility CSS — pair กับ Sarabun font (Thai-friendly). Alternative: CSS Modules / styled-components |
| autoprefixer + postcss | ^10.4.0 / ^8.4.0 | PostCSS pipeline |
| i18next + react-i18next | ^24.0.0 / ^15.0.0 | Runtime i18n — รองรับการสลับภาษาไทย ↔ อังกฤษโดยไม่ reload |
| lucide-react | ^0.460.0 | Icon set (tree-shakable SVG) |
| react-hot-toast | ^2.6.0 | Toast notifications (wrapper ใน lib/toast.ts) |
| TypeScript | ^5.7.0 | Type safety |
ทำไมไม่ใช้ form library?
form ในระบบส่วนใหญ่เป็น CRUD modal — ใช้ useState ตรง ๆ พอแล้ว ไม่ต้อง React Hook Form / Formik. ผลลัพธ์: bundle เล็กลง, learning curve ต่ำ
Docs — apps/docs
| Library | Version | บทบาท |
|---|---|---|
| VitePress | ^1.5.0 | Static-site generator สำหรับ markdown — Vite + Vue under-the-hood, build เร็ว, search ในตัว |
Infra / DevOps
| Tool | Version | บทบาท |
|---|---|---|
| pnpm | >= 9.0.0 (engines) | Workspace + package manager — disk-efficient (hard links), strict, fast |
| pnpm-workspace.yaml | — | กำหนด apps/* + packages/* เป็น workspaces |
| Cloudflare Pages | — | Hosting frontend (3 projects: wms-dev, wms-admin, wms-docs) |
| Render.com | Free tier | Hosting backend NestJS (Singapore, auto-sleep หลัง 15 นาที) |
| Supabase | — | Managed PostgreSQL 16 + PgBouncer (pooled) |
| Cloudflare R2 | — | S3-compatible object storage (no egress fees) |
| GitHub | — | Source control (private repo, push to master triggers Render redeploy) |
| Docker Compose | 3.9 | Local-only stack (postgres + redis + api) สำหรับ dev ที่ไม่อยากใช้ Supabase |
Testing & Dev Tooling
| Library | Version | บทบาท |
|---|---|---|
| Jest | ^29.7.0 | Unit/e2e test runner (backend) |
| ts-jest | ^29.2.0 | TS preset |
| @nestjs/testing | ^11.0.0 | TestingModule สำหรับ DI ใน tests |
| ts-node | ^10.9.0 | รัน Prisma seed + scripts ตรง ๆ |
| ESLint | (via @nestjs/cli) | Linting |
เวอร์ชั่นโดยรวม
- TypeScript ใช้
^5.7.0ทุก app - ทุก React app ใช้
type: "module"(ESM) - API ใช้ CommonJS เพื่อ compatibility กับ NestJS CLI