79e173938b44d12f2cc56e984a6e6507206fc211
Some checks failed
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 1m31s
Deploy / Build API Image (push) Failing after 25s
E2E Tests / Playwright E2E (push) Failing after 23s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Deploy / Build Web Image (push) Failing after 17s
Deploy / Build AI Services Image (push) Failing after 13s
Security Scanning / Trivy Scan — Web Image (push) Failing after 58s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 51s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m55s
Security Scanning / Trivy Filesystem Scan (push) Failing after 45s
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
Security Scanning / Security Gate (push) Failing after 3s
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 8s
CI / E2E Tests (push) Has been skipped
Closes the last gap from the tec-2725 branch: the valuation form's v2
extended-features section and POST endpoint can now submit real
predictions through to the Python ensemble model.
Backend
- New DTO apps/api/src/modules/analytics/presentation/dto/predict-valuation.dto.ts
with all v1 fields + 8 v2 fields (useV2 toggle, distanceToHospital/Park/
Mall in km, floodZoneRisk enum NONE|LOW|MEDIUM|HIGH, hasElevator/
Parking/Pool booleans).
- New CQRS handler apps/api/src/modules/analytics/application/queries/
predict-valuation/ that routes to AVM_SERVICE.estimateValue() with the
full request body.
- Extend AVMParams (domain) with the same v2 fields + inline v1 fields
(district, city, bedrooms, bathrooms, floors, frontage, roadWidth,
hasLegalPaper, projectId, imageUrl, description, deepAnalysis).
- HttpAVMService.estimateViaAi now branches on `useV2`: v2 calls the new
aiClient.predictV2() → POST /avm/v2/predict on the Python service,
mapping floodZoneRisk enum → 0..1 float and computing
building_age_years from yearBuilt. v1 path gets all the inline
descriptors wired through so non-propertyId calls no longer lose
context.
- AiServiceClient gets AiPredictV2Request / AiPredictV2Response types
mirroring libs/ai-services/app/models/avm_v2.py::AVMv2PredictRequest
(which already accepts all 7 numeric/boolean v2 fields — no Python
change needed).
- Register PredictValuationHandler in AnalyticsModule.
- New route POST /analytics/valuation on AnalyticsController:
JwtAuthGuard + QuotaGuard + EndpointRateLimitGuard (10/min),
@RequireQuota('analytics_queries'), full Swagger doc. Total endpoint
count 179 → 180.
Frontend
- Extend ValuationRequest with useV2, 3 distance-km fields,
floodZoneRisk, hasElevator/Parking/Pool + export FloodZoneRisk type
and FLOOD_RISK_OPTIONS.
- valuationApi.predict() body mapping now includes v2 fields and renames
'areaM2' → 'area' to match the backend DTO contract.
- valuationFormSchema gains matching optional Zod fields + exports
FLOOD_RISK_OPTIONS for the form.
- valuation-form.tsx gets:
* Image upload hardening: MIME+size validation (JPG/PNG ≤5MB) before
preview, role="progressbar" + aria-labels on the progress bar,
role="alert" + data-testid="image-upload-error" on errors. Matches
the upload-progress part of the task/tec-2725 commit 4ee0129 that
was previously parked as blocked.
* New Sparkles-branded "Mô hình v2 (Ensemble)" toggle alongside the
existing Bot-branded "Phân tích chuyên sâu" toggle.
* Collapsible "Đặc trưng mở rộng (AVM v2)" section with distance
inputs, flood-risk select, and three amenity checkboxes.
* handleFormSubmit passes all v2 fields through to onSubmit.
Python service unchanged — AVMv2PredictRequest already has every field
we send (distance_to_hospital_km, flood_zone_risk as float,
has_elevator/parking/pool, etc.).
Typecheck clean for the valuation surface. Pre-existing errors in
metadata.spec.ts and transfer-wizard-client.tsx are unrelated and left
for a follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…
…
…
…
…
…
…
…
…
…
…
…
…
GoodGo Platform AI
Nền tảng bất động sản thông minh của Việt Nam — tìm kiếm nhà đất, định giá bằng AI và quản lý giao dịch toàn trình.
Công Nghệ Sử Dụng
| Tầng | Công nghệ |
|---|---|
| Backend | NestJS 11, TypeScript, Prisma ORM, CQRS |
| Frontend | Next.js 15, React 18, Tailwind CSS, Zustand |
| Cơ sở dữ liệu | PostgreSQL 16 + PostGIS 3.4 |
| Tìm kiếm | Typesense 27 |
| Cache/Queue | Redis 7 |
| AI/ML | FastAPI, XGBoost, Claude API, Underthesea |
| MCP | Model Context Protocol servers (tìm kiếm nhà đất, định giá, phân tích) |
| Lưu trữ | MinIO (tương thích S3) |
| Giám sát | Prometheus, Grafana, Loki + Promtail |
| Thanh toán | VNPay, MoMo, ZaloPay |
Tổng Quan Kiến Trúc
┌─────────────┐ ┌──────────────┐ ┌──────────────────┐
│ Next.js 15 │────▶│ NestJS API │────▶│ PostgreSQL + │
│ (Web App) │ │ (REST) │ │ PostGIS │
└─────────────┘ └──────┬───────┘ └──────────────────┘
│
┌────────────┼────────────┐
│ │ │
┌─────▼──┐ ┌──────▼───┐ ┌────▼─────┐
│ Redis │ │Typesense │ │ MinIO │
│ Cache │ │ Search │ │ Storage │
└────────┘ └──────────┘ └──────────┘
│
┌─────▼──────────────────────────┐
│ MCP Servers │
│ ├─ Property Search │
│ ├─ Market Analytics │
│ └─ Valuation │
└─────────────┬─────────────────┘
│
┌───────▼────────┐
│ AI Services │
│ (FastAPI) │
│ ├─ AVM │
│ └─ Moderation │
└────────────────┘
Cấu Trúc Monorepo
goodgo-platform-ai/
├── apps/
│ ├── api/ # NestJS backend (port 3001)
│ └── web/ # Next.js frontend (port 3000)
├── libs/
│ ├── ai-services/ # Python FastAPI — AVM + content moderation
│ └── mcp-servers/ # MCP server implementations
├── prisma/ # Database schema & migrations
├── e2e/ # Playwright E2E tests (API + Web)
├── monitoring/ # Prometheus, Grafana, Loki & Promtail configs
├── scripts/ # Backup, restore & utility scripts
└── docs/ # Developer documentation
Khởi Động Nhanh
Yêu Cầu Tiên Quyết
- Docker Engine 24+ & Docker Compose v2
- Node.js 22 LTS
- pnpm 10.27+ (
corepack enable && corepack prepare pnpm@latest --activate)
Cài Đặt
# 1. Clone the repository
git clone <repo-url> && cd goodgo-platform-ai
# 2. Copy environment file
cp .env.example .env
# 3. Start infrastructure services
docker compose up -d
# 4. Verify services are healthy
docker compose ps
# 5. Install dependencies
pnpm install
# 6. Generate Prisma client
pnpm db:generate
# 7. Run database migrations
pnpm db:migrate:dev
# 8. Seed the database (optional)
pnpm db:seed
# 9. Start all apps in dev mode
pnpm dev
API sẽ khả dụng tại http://localhost:3001/api/v1 và ứng dụng web tại http://localhost:3000.
Swagger UI: Mở
http://localhost:3001/api/v1/docsđể xem tài liệu API tương tác.
Các Dịch Vụ Hạ Tầng
| Dịch vụ | Cổng | Bảng điều khiển |
|---|---|---|
| PostgreSQL + PostGIS | 5432 | — |
| Redis | 6379 | — |
| Typesense | 8108 | http://localhost:8108/health |
| MinIO | 9000 / 9001 | http://localhost:9001 (console) |
| AI Services (FastAPI) | 8000 | http://localhost:8000/health |
| Loki (tổng hợp log) | 3100 | http://localhost:3100/ready |
| Prometheus | 9090 | http://localhost:9090 |
| Grafana | 3002 | http://localhost:3002 |
Phát Triển
Các Lệnh Thông Dụng
pnpm dev # Start all apps (API + Web)
pnpm build # Build all packages
pnpm lint # Run ESLint
pnpm typecheck # TypeScript type checking
pnpm format # Format with Prettier
pnpm test # Run unit/integration tests
Cơ Sở Dữ Liệu
pnpm db:generate # Regenerate Prisma client
pnpm db:migrate:dev # Create and apply migrations
pnpm db:migrate:deploy # Apply migrations (CI/production)
pnpm db:seed # Seed database
pnpm db:studio # Open Prisma Studio (visual editor)
pnpm db:reset # Reset database (destructive)
Kiểm Thử E2E
pnpm test:e2e # Run all E2E tests
pnpm test:e2e:api # API tests only
pnpm test:e2e:web # Web UI tests only
pnpm test:e2e:report # Open HTML test report
Các Module API
Tất cả route API đều có tiền tố /api/v1/. Mỗi module tuân theo Domain-Driven Design với các tầng presentation/, application/, domain/ và infrastructure/.
| Module | Mô tả |
|---|---|
| auth | Đăng ký, đăng nhập, xoay vòng JWT + refresh token, OAuth (Google/Zalo), KYC, xuất/xoá dữ liệu người dùng |
| listings | CRUD tin đăng nhà đất, quy trình trạng thái, quản lý tệp phương tiện |
| search | Tìm kiếm toàn văn bản Typesense kết hợp bộ lọc địa lý, lưu tìm kiếm |
| payments | Tích hợp VNPay, MoMo, ZaloPay kèm xác thực callback |
| subscriptions | Quản lý gói dịch vụ, theo dõi mức sử dụng, kiểm soát hạn mức |
| notifications | Lịch sử thông báo qua email và trong ứng dụng cùng tuỳ chọn cá nhân |
| admin | Kiểm duyệt tin đăng, quản lý người dùng, nhật ký kiểm tra |
| analytics | Báo cáo thị trường, chỉ số giá, tích hợp AVM |
| agents | Hồ sơ và xác minh môi giới bất động sản |
| inquiries | Quản lý yêu cầu tư vấn nhà đất |
| leads | Theo dõi và chuyển đổi khách hàng tiềm năng |
| reviews | Đánh giá và xếp hạng bất động sản |
| health | Kiểm tra liveness và readiness |
| mcp | Cầu nối MCP server (tìm kiếm nhà đất, định giá, phân tích) |
| metrics | Thu thập metrics Prometheus và web vitals |
| shared | Mối quan tâm chung: guards, pipes, filters, dịch vụ Prisma/Redis |
Tài Liệu
| Tài liệu | Mô tả |
|---|---|
| Môi trường phát triển | Cài đặt Docker và các dịch vụ cục bộ |
| Kiến trúc | Thiết kế hệ thống, luồng dữ liệu, cấu trúc module |
| API Endpoints | Tài liệu tham khảo REST API endpoint |
| Mã lỗi API | Định dạng phản hồi lỗi và toàn bộ mã lỗi |
| Triển khai | Hướng dẫn triển khai môi trường sản xuất |
| Sao lưu & Khôi phục | Quy trình sao lưu và khôi phục sau sự cố |
| Đóng góp | Quy ước xử lý lỗi và các mẫu lập trình |
Giấy Phép
Độc quyền — Bảo lưu mọi quyền.
Description
Languages
TypeScript
95.4%
Python
2.7%
Shell
0.9%
JavaScript
0.8%
Dockerfile
0.1%