chore: update project documentation, audit reports, and initialize IDE configuration files
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
# GoodGo Platform — Infrastructure Quick Reference
|
||||
# GoodGo Platform — Tài Liệu Tham Khảo Nhanh về Cơ Sở Hạ Tầng
|
||||
|
||||
## 🚀 Quick Start
|
||||
## 🚀 Khởi Động Nhanh
|
||||
|
||||
```bash
|
||||
# Development
|
||||
# Phát triển
|
||||
docker compose up -d --wait
|
||||
|
||||
# Production
|
||||
# Sản xuất
|
||||
docker compose -f docker-compose.prod.yml up -d --wait
|
||||
|
||||
# CI/E2E
|
||||
docker compose -f docker-compose.ci.yml up -d --wait
|
||||
```
|
||||
|
||||
## 📊 Service Map (Dev)
|
||||
## 📊 Bản Đồ Dịch Vụ (Dev)
|
||||
|
||||
| Service | Port | Health | Status |
|
||||
| Dịch Vụ | Cổng | Kiểm Tra Sức Khỏe | Trạng Thái |
|
||||
|---------|------|--------|--------|
|
||||
| **API (NestJS)** | 3001 | GET /health | 🟢 |
|
||||
| **Web (Next.js)** | 3000 | GET / | 🟢 |
|
||||
@@ -27,21 +27,21 @@ docker compose -f docker-compose.ci.yml up -d --wait
|
||||
| **Prometheus** | 9090 | GET /-/healthy | 🟢 |
|
||||
| **Grafana** | 3002 | GET /api/health | 🟢 |
|
||||
| **Loki** | 3100 | GET /ready | 🟢 |
|
||||
| **Promtail** | 9080 | (passive) | 🟢 |
|
||||
| **Promtail** | 9080 | (thụ động) | 🟢 |
|
||||
|
||||
## 📊 Service Map (Prod)
|
||||
## 📊 Bản Đồ Dịch Vụ (Prod)
|
||||
|
||||
Same as dev, plus **PgBouncer** (6432) for connection pooling.
|
||||
Giống như dev, cộng thêm **PgBouncer** (6432) để gộp kết nối.
|
||||
|
||||
## 🗄️ Database
|
||||
## 🗄️ Cơ Sở Dữ Liệu
|
||||
|
||||
- **Type:** PostgreSQL 16 + PostGIS
|
||||
- **Schema:** 22 Prisma models
|
||||
- **Backup:** Daily 02:00 UTC, 7-day retention
|
||||
- **Connection Pooling (Prod):** PgBouncer (transaction mode, 20 connections)
|
||||
- **Verification:** Weekly automated restore test
|
||||
- **Loại:** PostgreSQL 16 + PostGIS
|
||||
- **Schema:** 22 mô hình Prisma
|
||||
- **Sao lưu:** Hằng ngày lúc 02:00 UTC, lưu giữ 7 ngày
|
||||
- **Gộp Kết Nối (Prod):** PgBouncer (chế độ giao dịch, 20 kết nối)
|
||||
- **Xác minh:** Kiểm tra khôi phục tự động hàng tuần
|
||||
|
||||
**Key Tables:**
|
||||
**Các Bảng Chính:**
|
||||
- User, RefreshToken, OAuthAccount, Agent
|
||||
- Property, PropertyMedia, Listing
|
||||
- SavedSearch, Transaction, Inquiry, Lead
|
||||
@@ -49,71 +49,71 @@ Same as dev, plus **PgBouncer** (6432) for connection pooling.
|
||||
- Plan, Subscription, UsageRecord
|
||||
- Valuation, MarketIndex, NotificationLog, AdminAuditLog, Review
|
||||
|
||||
## 💾 Cache & Search
|
||||
## 💾 Bộ Nhớ Đệm & Tìm Kiếm
|
||||
|
||||
- **Redis:** 512MB (prod), 256MB (dev), AOF persistence, LRU eviction
|
||||
- **Typesense:** Full-text search on listings, geo-indexing support
|
||||
- **Redis:** 512MB (prod), 256MB (dev), lưu trữ AOF, loại bỏ LRU
|
||||
- **Typesense:** Tìm kiếm toàn văn bản trên các danh sách, hỗ trợ lập chỉ mục địa lý
|
||||
|
||||
## 📈 Monitoring
|
||||
## 📈 Giám Sát
|
||||
|
||||
- **Prometheus:** 30-day retention (prod), 15-day (dev)
|
||||
- **Grafana:** Pre-provisioned dashboards (7 total)
|
||||
- **Loki:** 15-day log retention, Pino JSON parsing
|
||||
- **Alerts:** p99 latency > 1s (warn), > 3s (critical), 5xx > 1%
|
||||
- **Prometheus:** Lưu giữ 30 ngày (prod), 15 ngày (dev)
|
||||
- **Grafana:** Bảng điều khiển được cấu hình sẵn (7 bảng)
|
||||
- **Loki:** Lưu giữ nhật ký 15 ngày, phân tích cú pháp JSON Pino
|
||||
- **Cảnh báo:** Độ trễ p99 > 1s (cảnh báo), > 3s (nghiêm trọng), 5xx > 1%
|
||||
|
||||
## 💳 Payment Integration
|
||||
## 💳 Tích Hợp Thanh Toán
|
||||
|
||||
| Gateway | Provider | Status Tracking | Callback Verification |
|
||||
| Cổng Thanh Toán | Nhà Cung Cấp | Theo Dõi Trạng Thái | Xác Minh Callback |
|
||||
|---------|----------|-----------------|----------------------|
|
||||
| VNPay | VNPAY | ✅ | HMAC SHA-256 |
|
||||
| MoMo | MOMO | ✅ | HMAC |
|
||||
| ZaloPay | ZALOPAY | ✅ | Key 1/2 |
|
||||
| Bank Transfer | BANK_TRANSFER | Manual | N/A |
|
||||
| Bank Transfer | BANK_TRANSFER | Thủ công | N/A |
|
||||
|
||||
**Callback Handler:**
|
||||
- Idempotent (updateIfStatus pattern)
|
||||
- Atomic state transitions (PENDING → COMPLETED/FAILED)
|
||||
- Domain event publishing (triggers downstream actions)
|
||||
**Trình Xử Lý Callback:**
|
||||
- Idempotent (mẫu updateIfStatus)
|
||||
- Chuyển trạng thái nguyên tử (PENDING → COMPLETED/FAILED)
|
||||
- Xuất bản sự kiện miền (kích hoạt các hành động tiếp theo)
|
||||
|
||||
## 🏥 Health Checks
|
||||
## 🏥 Kiểm Tra Sức Khỏe
|
||||
|
||||
```bash
|
||||
GET /health # Liveness (always 200)
|
||||
GET /health/ready # Readiness (checks DB + Redis)
|
||||
GET /health/db # Database only
|
||||
GET /health/redis # Redis only
|
||||
GET /health # Liveness (luôn 200)
|
||||
GET /health/ready # Readiness (kiểm tra DB + Redis)
|
||||
GET /health/db # Chỉ cơ sở dữ liệu
|
||||
GET /health/redis # Chỉ Redis
|
||||
```
|
||||
|
||||
## 🔐 Environment Variables (Critical)
|
||||
## 🔐 Biến Môi Trường (Quan Trọng)
|
||||
|
||||
```env
|
||||
# Database
|
||||
# Cơ sở dữ liệu
|
||||
DB_USER=goodgo
|
||||
DB_PASSWORD=<required>
|
||||
DATABASE_URL_DIRECT=postgresql://... # For migrations
|
||||
|
||||
# Redis (Prod requires password)
|
||||
# Redis (Prod yêu cầu mật khẩu)
|
||||
REDIS_PASSWORD=<required-in-prod>
|
||||
|
||||
# Typesense API Key
|
||||
TYPESENSE_API_KEY=<required>
|
||||
|
||||
# JWT Secrets (REQUIRED, min 32 chars)
|
||||
# JWT Secrets (BẮT BUỘC, tối thiểu 32 ký tự)
|
||||
JWT_SECRET=<openssl rand -base64 48>
|
||||
JWT_REFRESH_SECRET=<openssl rand -base64 48>
|
||||
|
||||
# KYC Encryption (Prod only)
|
||||
# KYC Encryption (Chỉ Prod)
|
||||
KYC_ENCRYPTION_KEY=<openssl rand -hex 32> # 64 hex chars
|
||||
|
||||
# Payment Gateways (optional if disabled)
|
||||
# Cổng Thanh Toán (tùy chọn nếu bị tắt)
|
||||
VNPAY_TMN_CODE=
|
||||
MOMO_PARTNER_CODE=
|
||||
ZALOPAY_APP_ID=
|
||||
```
|
||||
|
||||
## 📦 Deployment
|
||||
## 📦 Triển Khai
|
||||
|
||||
**Containers:**
|
||||
**Container:**
|
||||
- `goodgo-api:${IMAGE_TAG}` — NestJS API
|
||||
- `goodgo-web:${IMAGE_TAG}` — Next.js Frontend
|
||||
- `goodgo-ai-services:${IMAGE_TAG}` — Python FastAPI
|
||||
@@ -121,95 +121,95 @@ ZALOPAY_APP_ID=
|
||||
**Registry:** `ghcr.io/goodgo/`
|
||||
|
||||
**CI/CD:** GitHub Actions
|
||||
- **ci.yml** — Test, build, lint on push
|
||||
- **deploy.yml** — Build images, deploy to staging (auto) or prod (manual)
|
||||
- **backup-verify.yml** — Weekly restore verification
|
||||
- **e2e.yml** — End-to-end test suite
|
||||
- **ci.yml** — Kiểm tra, build, lint khi push
|
||||
- **deploy.yml** — Build image, triển khai lên staging (tự động) hoặc prod (thủ công)
|
||||
- **backup-verify.yml** — Xác minh khôi phục hàng tuần
|
||||
- **e2e.yml** — Bộ kiểm thử đầu cuối
|
||||
|
||||
## 🆘 Troubleshooting
|
||||
## 🆘 Khắc Phục Sự Cố
|
||||
|
||||
**API not healthy?**
|
||||
**API không hoạt động bình thường?**
|
||||
```bash
|
||||
docker compose exec api curl http://localhost:3001/health/ready
|
||||
docker compose logs api --tail=50
|
||||
```
|
||||
|
||||
**Database connection pooling full?**
|
||||
**Gộp kết nối cơ sở dữ liệu đầy?**
|
||||
```bash
|
||||
docker compose exec pgbouncer psql -h 127.0.0.1 -p 6432 -U pgbouncer_stats -c "SHOW stats"
|
||||
```
|
||||
|
||||
**Redis down?**
|
||||
**Redis ngừng hoạt động?**
|
||||
```bash
|
||||
docker compose exec redis redis-cli ping
|
||||
# App continues working (DB fallback), but slower
|
||||
# Ứng dụng vẫn tiếp tục chạy (dự phòng DB), nhưng chậm hơn
|
||||
```
|
||||
|
||||
**Typesense not indexing?**
|
||||
**Typesense không lập chỉ mục?**
|
||||
```bash
|
||||
curl http://localhost:8108/collections/listings -H "X-TYPESENSE-API-KEY: ${KEY}"
|
||||
# Reindex: docker compose exec api npx ts-node scripts/reindex-listings.ts
|
||||
# Lập chỉ mục lại: docker compose exec api npx ts-node scripts/reindex-listings.ts
|
||||
```
|
||||
|
||||
**Payment callback failing?**
|
||||
**Callback thanh toán thất bại?**
|
||||
```bash
|
||||
docker compose logs api | grep -i callback
|
||||
# Check VNPAY_HASH_SECRET / MOMO_SECRET_KEY / ZALOPAY_KEY1
|
||||
# Kiểm tra VNPAY_HASH_SECRET / MOMO_SECRET_KEY / ZALOPAY_KEY1
|
||||
```
|
||||
|
||||
**Backup stuck?**
|
||||
**Sao lưu bị kẹt?**
|
||||
```bash
|
||||
docker compose exec pg-backup bash -c "tail -f /var/log/pg-backup.log"
|
||||
docker compose exec postgres psql -U goodgo -d goodgo -c "SELECT * FROM pg_stat_activity WHERE wait_event_type IS NOT NULL;"
|
||||
```
|
||||
|
||||
## 📝 Key Files
|
||||
## 📝 Các Tệp Quan Trọng
|
||||
|
||||
| Path | Purpose |
|
||||
| Đường Dẫn | Mục Đích |
|
||||
|------|---------|
|
||||
| `docker-compose.yml` | Dev (no resource limits, all services) |
|
||||
| `docker-compose.prod.yml` | Prod (PgBouncer, limits, secrets) |
|
||||
| `docker-compose.ci.yml` | Test (tmpfs, minimal services) |
|
||||
| `INFRASTRUCTURE_RUNBOOK.md` | Full documentation (this file's companion) |
|
||||
| `prisma/schema.prisma` | Complete data model |
|
||||
| `infra/pgbouncer/pgbouncer.ini` | Connection pooling config |
|
||||
| `monitoring/prometheus/alert-rules.yml` | Alert definitions |
|
||||
| `scripts/backup/pg-backup.sh` | Daily backup automation |
|
||||
| `scripts/backup/pg-verify-backup.sh` | Restore verification |
|
||||
| `.github/workflows/*.yml` | CI/CD pipelines |
|
||||
| `docker-compose.yml` | Dev (không giới hạn tài nguyên, tất cả dịch vụ) |
|
||||
| `docker-compose.prod.yml` | Prod (PgBouncer, giới hạn, bí mật) |
|
||||
| `docker-compose.ci.yml` | Kiểm thử (tmpfs, dịch vụ tối thiểu) |
|
||||
| `INFRASTRUCTURE_RUNBOOK.md` | Tài liệu đầy đủ (tệp đồng hành) |
|
||||
| `prisma/schema.prisma` | Mô hình dữ liệu hoàn chỉnh |
|
||||
| `infra/pgbouncer/pgbouncer.ini` | Cấu hình gộp kết nối |
|
||||
| `monitoring/prometheus/alert-rules.yml` | Định nghĩa cảnh báo |
|
||||
| `scripts/backup/pg-backup.sh` | Tự động hóa sao lưu hàng ngày |
|
||||
| `scripts/backup/pg-verify-backup.sh` | Xác minh khôi phục |
|
||||
| `.github/workflows/*.yml` | Pipeline CI/CD |
|
||||
|
||||
## 🔗 Links
|
||||
## 🔗 Liên Kết
|
||||
|
||||
- **Grafana:** http://localhost:3002 (admin/admin)
|
||||
- **Prometheus:** http://localhost:9090
|
||||
- **MinIO Console:** http://localhost:9001
|
||||
- **API Docs:** http://localhost:3001/api (if Swagger enabled)
|
||||
- **API Docs:** http://localhost:3001/api (nếu Swagger được bật)
|
||||
- **Frontend:** http://localhost:3000
|
||||
|
||||
## 📞 Common Commands
|
||||
## 📞 Lệnh Thường Dùng
|
||||
|
||||
```bash
|
||||
# View all services
|
||||
# Xem tất cả dịch vụ
|
||||
docker compose ps
|
||||
|
||||
# Tail logs
|
||||
# Theo dõi nhật ký
|
||||
docker compose logs -f api web postgres redis
|
||||
|
||||
# Execute command in container
|
||||
# Thực thi lệnh trong container
|
||||
docker compose exec api npx prisma db push
|
||||
docker compose exec postgres psql -U goodgo -d goodgo
|
||||
|
||||
# Restart single service
|
||||
# Khởi động lại một dịch vụ
|
||||
docker compose restart api
|
||||
|
||||
# Full cleanup (dev only!)
|
||||
# Dọn dẹp hoàn toàn (chỉ dev!)
|
||||
docker compose down -v && docker compose up -d --wait
|
||||
|
||||
# Database backup & restore
|
||||
# Sao lưu & khôi phục cơ sở dữ liệu
|
||||
docker compose exec postgres pg_dump -U goodgo -d goodgo | gzip > backup.sql.gz
|
||||
docker compose exec postgres pg_restore -U goodgo -d goodgo backup.sql.gz
|
||||
|
||||
# Check health endpoints
|
||||
# Kiểm tra endpoint sức khỏe
|
||||
curl http://localhost:3001/health/ready | jq
|
||||
curl http://localhost:3001/health/db | jq
|
||||
curl http://localhost:3001/health/redis | jq
|
||||
@@ -217,6 +217,6 @@ curl http://localhost:3001/health/redis | jq
|
||||
|
||||
---
|
||||
|
||||
**For detailed information, see `INFRASTRUCTURE_RUNBOOK.md`**
|
||||
**Để biết thêm thông tin chi tiết, xem `INFRASTRUCTURE_RUNBOOK.md`**
|
||||
|
||||
Last updated: April 11, 2026
|
||||
Cập nhật lần cuối: ngày 11 tháng 4 năm 2026
|
||||
|
||||
Reference in New Issue
Block a user