Kittiwana Notify Platform

ระบบแจ้งเตือนแบบ Multi-Channel สำหรับองค์กร

API Running

ภาพรวมระบบ

Kittiwana Notify Platform เป็นระบบแจ้งเตือนภายในองค์กร พัฒนาและให้บริการโดย บริษัท สมาร์ทเพลส 304 ไอพี 3 จำกัด (ในเครือกลุ่มกิตติวนา) รองรับการส่งการแจ้งเตือนผ่านหลายช่องทาง

Tech Stack

  • Runtime: Node.js
  • Framework: Express.js 5
  • Database: SQL Server (Prisma ORM)
  • Auth: JWT (7 วัน)
  • Build: @vercel/ncc
  • Process: PM2

Security

  • JWT Authentication (7-day expiry)
  • Resource-level Authorization
  • Helmet + CORS Whitelist
  • Rate Limiting (100 req/15min)
  • Input Query Whitelist

Notification Channels

iOS (APNs) Active

Push Notification ผ่าน Apple Push Notification service

  • Library: node-apn
  • รองรับ title, body, badge, sound
  • Config เก็บใน DB (ApplicationIOSConfig)
  • รองรับ Sandbox + Production

Email (SMTP) Active

ส่งอีเมลผ่าน SMTP Server

  • Library: nodemailer
  • รองรับ HTML body, CC
  • Config ผ่าน Environment Variables

Android (FCM) Active

Push Notification ผ่าน Firebase Cloud Messaging

  • Library: firebase-admin
  • FCM HTTP v1 API
  • Config เก็บใน DB (ApplicationAndroidConfig)
  • รองรับ high priority + custom data

LINE Active

แจ้งเตือนผ่าน LINE Messaging API

  • Library: @line/bot-sdk
  • Push Message + Flex Message
  • Webhook — ลงทะเบียน user อัตโนมัติผ่าน Bot
  • Config เก็บใน DB (ApplicationLINEConfig)
  • รองรับ multi-user push

API Reference

ทุก endpoint (ยกเว้น /auth/*) ต้องมี JWT token หรือ API Key ใน header:

Authorization: Bearer <jwt_token>    (Mobile App)
Authorization: ApiKey <api_key>      (External System)

Authentication

MethodEndpointDescription
POST/auth/registerลงทะเบียน / เข้าสู่ระบบ
POST/auth/tokenVerifyตรวจสอบ JWT token

HRMS Info (ข้อมูลพนักงาน)

MethodEndpointDescription
GET/hrmsInfoดึงข้อมูลพนักงาน
POST/hrmsInfo/createสร้างข้อมูลพนักงาน
PUT/hrmsInfo/updateอัปเดตข้อมูลพนักงาน
DELETE/hrmsInfo/deleteลบข้อมูลพนักงาน

Notification Log

MethodEndpointDescription
GET/hrmsNotificationLogดึง notification log
POST/hrmsNotificationLog/createสร้าง notification log
PUT/hrmsNotificationLog/updateอัปเดต (mark read/unread)
PUT/hrmsNotificationLog/update/setIsRead/allMark all as read/unread
DELETE/hrmsNotificationLog/deleteลบ notification log

Device Token

MethodEndpointDescription
GET/hrmsStaticTokenดึง device token
POST/hrmsStaticToken/createลงทะเบียน device token
PUT/hrmsStaticToken/updateอัปเดต device token
DELETE/hrmsStaticToken/deleteลบ device token

Notification Sending

MethodEndpointDescription
POST/notify/sendส่ง notification ทุก platform (Unified API)
POST/ios/sendส่ง iOS push notification
POST/ios/badgeตั้งค่า badge count
POST/line/sendส่ง LINE push message
POST/line/flexส่ง LINE Flex Message
POST/android/sendส่ง Android push notification (FCM)
POST/line/webhook/:appCodeLINE Webhook (ลงทะเบียน user อัตโนมัติ, no auth)
POST/mail/sendส่ง email

Admin

MethodEndpointDescription
POST/admin/application/registerลงทะเบียน application + สร้าง API Key
POST/admin/application/regenerateKeyสร้าง API Key ใหม่
GET/admin/applicationดูรายการ application ทั้งหมด

Response Format

{
  "status": "SUCCESS",
  "data": { ... }
}

// Error
{
  "status": "ERROR",
  "message": "Error description"
}

Rate Limiting

API จำกัดที่ 100 requests ต่อ 15 นาที ต่อ IP — หากเกินจะได้ HTTP 429:

{
  "status": "ERROR",
  "message": "Too many requests, please try again later"
}

Development Roadmap

Phase 1: Bug Fixes & Stability COMPLETED

แก้ bug ทั้งหมด, standardize response format, รวม hardcoded values

Phase 2: Security Hardening COMPLETED

JWT expiration, resource-level auth, CORS whitelist, rate limiting, query whitelist, zod validation, request size limit

Phase 3: Performance & Optimization COMPLETED

Composite index, pagination, orderBy, APNs caching, concurrent scheduled tasks, code cleanup

Phase 4: New Features COMPLETED

LINE Notification, Android FCM, Notification Management, Soft Delete, Multi-Notify API, External System API (API Key auth)

Phase 5: Production Readiness ~20%

Health check, global error handler, .env.example — เหลือ: structured logging, Swagger, testing, PM2 config

Phase 6: Advanced Features NOT STARTED

WebSocket real-time, message queue (Bull/Redis), multi-tenant, analytics dashboard