{"id":50908032,"url":"https://github.com/anucha-tk/sr-be-node-nest","last_synced_at":"2026-06-16T07:02:39.405Z","repository":{"id":357749553,"uuid":"1237889284","full_name":"anucha-tk/sr-be-node-nest","owner":"anucha-tk","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-14T04:25:44.000Z","size":1851,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T06:36:58.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anucha-tk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T15:52:08.000Z","updated_at":"2026-05-14T04:25:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/anucha-tk/sr-be-node-nest","commit_stats":null,"previous_names":["anucha-tk/sr-be-node-nest"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/anucha-tk/sr-be-node-nest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fsr-be-node-nest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fsr-be-node-nest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fsr-be-node-nest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fsr-be-node-nest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anucha-tk","download_url":"https://codeload.github.com/anucha-tk/sr-be-node-nest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anucha-tk%2Fsr-be-node-nest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34393305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-16T07:02:38.383Z","updated_at":"2026-06-16T07:02:39.399Z","avatar_url":"https://github.com/anucha-tk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Supplier Revenue Dashboard (SR-BE-NODE-NEST)\n\nระบบหลังบ้านประสิทธิภาพสูง สำหรับประมวลผลข้อมูลรายได้และจัดการใบแจ้งหนี้ (Invoices) พร้อมระบบตรวจสอบ (Audit Trail) และความปลอดภัยระดับองค์กร\n\n## 🚀 เทคโนโลยีที่ใช้ (Tech Stack)\n\n- **Framework:** NestJS (v11)\n- **Runtime:** Node.js (v24) / [Bun](https://bun.sh/) (Recommended for development scripts)\n- **Database:** PostgreSQL (v17) ผ่าน Prisma (v7.8.0)\n- **Messaging:** Kafka (v4)\n- **Search Engine:** Elasticsearch (v9.4.0) + Kibana (v9.4.0)\n- **Observability:**\n  - **Metrics:** Prometheus + prom-client\n  - **Tracing:** OpenTelemetry + Jaeger\n  - **Logging:** Pino + Nestjs-Pino\n- **Auth:** Keycloak (v26) + API Keys (Dual Auth)\n- **Validation:** Zod + Nestjs-Zod\n- **Infra:** Docker Compose\n\n## 🛠️ เริ่มต้นใช้งาน (Getting Started)\n\n### 1. สิ่งที่ต้องเตรียม (Prerequisites)\n\n- Node.js v24 ขึ้นไป\n- [Bun](https://bun.sh/) (แนะนำสำหรับการรันสคริปต์และ Quality Gate ที่รวดเร็ว)\n- Docker \u0026 Docker Compose\n\n### 2. ตั้งค่า Environment\n\nคัดลอกไฟล์ต้นแบบและตั้งค่าตัวแปรต่างๆ:\n\n```bash\ncp .env.example .env\n```\n\n### 3. รันระบบ Infrastructure\n\nเริ่มต้นฐานข้อมูล PostgreSQL, Keycloak, Kafka และ Jaeger ด้วย Docker:\n\n```bash\ndocker compose up -d\n```\n\n\u003e [!NOTE]\n\u003e **Keycloak Auto-Provisioning:** ระบบถูกตั้งค่าให้นำเข้า (Import) การตั้งค่า Realm, Client, Roles และ Users โดยอัตโนมัติจากโฟลเดอร์ `keycloak-init` เมื่อเริ่มต้นระบบครั้งแรก\n\n### 4. ติดตั้งและเริ่มรันแอปพลิเคชัน\n\n```bash\n# 1. ติดตั้ง dependencies\nbun install  # หรือ npm install\n\n# 2. Sync database schema และ generate Prisma client\nbun run prisma:push\nbun run prisma:generate\n\n# 3. สร้าง API Key สำหรับใช้งานครั้งแรก\nbun scripts/seed-api-key.mjs\n\n# 4. (ทางเลือก) สร้างข้อมูลทดสอบ 1,000,000 รายการ\nbun run seed:million\n\n# 5. เริ่มรันเซิร์ฟเวอร์ในโหมดพัฒนา\nbun run start:dev\n```\n\n## 📊 การตรวจสอบระบบ (Observability)\n\nระบบมาพร้อมกับความสามารถในการตรวจสอบแบบ Real-time:\n\n1. **System Pulse Dashboard:** แสดงผล Metrics สำคัญ (CPU, Memory, Traffic) แบบสดๆ ผ่าน WebSocket ในหน้า UI\n2. **Prometheus Metrics:** ดูข้อมูลดิบได้ที่ `/v1/observability/metrics-summary`\n3. **Jaeger Tracing:** ติดตาม Flow ของ Request และ Kafka Events ได้ที่ [http://localhost:16686](http://localhost:16686)\n4. **Audit Trail:** ระบบบันทึกการเปลี่ยนแปลงที่สำคัญทั้งหมดในฐานข้อมูล\n\n## 🔐 ระบบยืนยันตัวตน (Authentication)\n\nระบบรองรับการยืนยันตัวตน 2 รูปแบบ (**Dual Authentication**):\n\n### 1. Keycloak (JWT Token)\n\nใช้สำหรับการเข้าใช้งานผ่านหน้าจอ (Browser) โดยมีผู้ใช้เริ่มต้นดังนี้:\n\n- **Admin:** `test` / `12345678`\n- **Supplier:** `supplier` / `12345678`\n\n**วิธีขอ Token ผ่าน Terminal:**\n\n```bash\ncurl --location 'http://localhost:8080/realms/sr-realm/protocol/openid-connect/token' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'client_id=sr-be-client' \\\n--data-urlencode 'username=test' \\\n--data-urlencode 'password=12345678' \\\n--data-urlencode 'grant_type=password'\n```\n\n### 2. API Keys (Service-to-Service)\n\nใช้สำหรับระบบอื่นๆ ที่ต้องการเรียกใช้ API โดยตรงผ่าน Header `x-api-key`\n\n## 📖 เอกสารประกอบ API\n\n- **Scalar UI:** [http://localhost:3000/docs](http://localhost:3000/docs)\n\n## 📜 รายการสคริปต์ (Scripts)\n\n| คำสั่ง                  | รายละเอียด                                        |\n| :---------------------- | :------------------------------------------------ |\n| `bun run start:dev`     | รันแอปพลิเคชันในโหมด Watch                        |\n| `bun run check:full`    | รัน Quality Gate ครบชุด (Lint, Format, TSC, Test) |\n| `bun run test:cov`      | รัน Unit Test พร้อมสรุป Coverage                  |\n| `bun run prisma:studio` | เปิดหน้า UI สำหรับจัดการข้อมูลในฐานข้อมูล         |\n\n## 📐 แผนผังระบบ (Diagrams)\n\n- [🏗️ System Architecture](docs/diagrams/architect.md)\n- [🔄 Logic Flow: Idempotency](docs/diagrams/flow-function.md)\n\n---\n\n## ⚖️ สัญญาอนุญาต\n\nUNLICENSED\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanucha-tk%2Fsr-be-node-nest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanucha-tk%2Fsr-be-node-nest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanucha-tk%2Fsr-be-node-nest/lists"}