Commit Graph

26 Commits

Author SHA1 Message Date
Ho Ngoc Hai
9bb4c42f84 feat(web): listings page — ticker-style DataTable với toggle card view
Tạo mới trang /listings dạng bảng ticker-style theo spec TEC-3034.

- DataTable compact (row 36px, sticky header, alternating rows)
- Cột: #, Mã (GG-xxx), Quận, Loại, Giá, Δ30d, DT m², KL/Views
- Sortable theo Giá, Δ30d, DT m², KL/Views
- Filter inline: Loại giao dịch, Loại BĐS, Quận, Khoảng giá
- Toggle view: Table (default) ↔ Card grid (legacy component cũ)
- Pagination restyle compact, giữ nguyên API params
- Click row → navigate to detail page
- Dùng DataTable + PriceDelta từ @/components/design-system

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-21 01:31:22 +07:00
Ho Ngoc Hai
310ff7bb3e ci(deploy): wire Playwright smoke suite into deploy pipeline
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 4s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 20s
Deploy / Build API Image (push) Failing after 13s
Deploy / Build Web Image (push) Failing after 12s
Deploy / Build AI Services Image (push) Failing after 13s
E2E Tests / Playwright E2E (push) Failing after 9s
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 — API Image (push) Failing after 2m18s
Security Scanning / Trivy Scan — Web Image (push) Failing after 59s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 1m2s
Security Scanning / Trivy Filesystem Scan (push) Failing after 57s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 10m52s
Security Scanning / Security Gate (push) Has been cancelled
Staging and production smoke-test jobs now run both the existing bash
smoke-test.sh (fast endpoint checks) and the new Playwright @smoke projects
(smoke-api + smoke-web) against live deployed URLs. Failure blocks the
rollback trigger just as before.

Required secrets: STAGING_API_URL, PRODUCTION_API_URL (added alongside the
existing STAGING_URL / PRODUCTION_URL).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-21 00:53:33 +07:00
Ho Ngoc Hai
26b6b37cee feat(qa): add smoke test suite + post-deploy workflow
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 12s
Deploy / Build AI Services Image (push) Failing after 10s
Security Scanning / Trivy Scan — API Image (push) Failing after 1m25s
Security Scanning / Trivy Scan — Web Image (push) Failing after 46s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 43s
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 1s
Deploy / Rollback Staging (push) Has been skipped
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 32s
Deploy / Build API Image (push) Failing after 26s
Deploy / Build Web Image (push) Failing after 10s
E2E Tests / Playwright E2E (push) Failing after 21s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 5s
Security Scanning / Trivy Filesystem Scan (push) Failing after 42s
Deploy / Rollback Production (push) Has been skipped
- e2e/api/smoke.spec.ts — 9 @smoke API tests covering health, auth roundtrip,
  token refresh, listings, search, payments, subscriptions, and inquiries
- e2e/web/smoke.spec.ts — 7 @smoke Web tests covering homepage, login/register
  pages, listings, search, listing detail 404 handling, and console-error check
- playwright.config.ts — smoke-api and smoke-web projects (grep: /@smoke/)
  allowing targeted post-deploy execution without the full suite
- .github/workflows/smoke.yml — workflow_dispatch + workflow_call trigger for
  running only the @smoke subset against staging or production URLs

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-21 00:47:40 +07:00
Ho Ngoc Hai
e78d706b42 chore: update infrastructure configs, audit docs, and env template
- Update Docker Compose configs for Redis, Typesense, and MinIO services
- Update GitHub Actions deploy workflow with improved caching and steps
- Extend .env.example with Stringee, Zalo OA, and FCM config keys
- Update audit documentation with latest findings and recommendations
- Update CHANGELOG and README with recent feature additions

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-16 05:17:38 +07:00
Ho Ngoc Hai
20b79acf08 fix(deploy): tag rollback images before pull, prune after smoke test
Previously, `docker image prune` ran immediately after deploying new
containers, potentially deleting the old images needed for rollback
if smoke tests subsequently failed. Now the deploy pipeline:

1. Tags current images as :rollback before pulling new versions
2. Only runs `docker image prune` after smoke tests pass
3. Uses explicit :rollback tags for rollback instead of relying on
   Docker layer cache (which is fragile)

Applied to:
- scripts/deploy-production.sh (manual deploy script)
- .github/workflows/deploy.yml (staging + production CI jobs)
- docs/deployment.md (updated rollback documentation)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-15 11:17:32 +07:00
Ho Ngoc Hai
92e708f17f fix(ci): target master branch in security.yml and codeql.yml
Both workflow files referenced 'main' branch for push/PR triggers, but
the repo default branch is 'master'. This caused security scanning and
CodeQL analysis to never trigger on pushes to the default branch.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-15 09:39:11 +07:00
Ho Ngoc Hai
b84dfd5cad fix: Docker build errors — Prisma generate order, .dockerignore multi-service
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 11s
CI / E2E Tests (push) Has been skipped
Deploy / Build API Image (push) Failing after 23s
Deploy / Build Web Image (push) Failing after 12s
Deploy / Build AI Services Image (push) Failing after 10s
E2E Tests / Playwright E2E (push) Failing after 12s
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
- Dockerfile: move prisma generate BEFORE nest build (fixes TS2305 PropertyType)
- .dockerignore: remove apps/web + libs/ai-services exclusions (needed by Kaniko)
- CI: add pnpm db:generate step before lint/typecheck/build

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-13 15:31:08 +07:00
Ho Ngoc Hai
e5f7acf7da feat: production infra — nginx configs, deploy script, security hardening
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 58s
Deploy / Build Web Image (push) Failing after 14s
Deploy / Rollback Production (push) Has been skipped
CI / E2E Tests (push) Has been skipped
Deploy / Build API Image (push) Failing after 3m8s
Deploy / Build AI Services Image (push) Failing after 10s
E2E Tests / Playwright E2E (push) Failing after 1m21s
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
- Add Nginx reverse-proxy configs for api.goodgo.vn and platform.goodgo.vn
  with SSL, gzip, rate limiting, security headers, and WebSocket support
- Add Cloudflare DNS setup script for A/AAAA/CNAME records
- Add server-setup.sh for Ubuntu provisioning (Docker, fail2ban, UFW,
  swap, unattended-upgrades)
- Add deploy-production.sh for manual production deployments
- Add env.production.example with all required environment variables
- Bind container ports to 127.0.0.1 in docker-compose.prod.yml
  (security: prevent direct access bypassing Nginx)
- Fix deploy workflow: add -T flag to exec, sync Nginx configs,
  copy pgbouncer and backup configs to server

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-13 14:11:25 +07:00
Ho Ngoc Hai
db0fe8b9b7 fix(e2e): unblock E2E test environment — CSP, CORS, and env var fixes
Root causes of web E2E failures:
1. CSP connect-src only included API origin for NODE_ENV=development,
   blocking test mode (NODE_ENV=test) from fetching API data
2. CORS_ORIGINS missing the test web port (3010), so API rejected
   cross-origin requests from the web app
3. NEXT_PUBLIC_API_URL not set in .env.test or playwright config,
   causing web app to default to port 3001 instead of test port 3011
4. Playwright webServer config didn't inherit parent env vars,
   so API server lacked Redis/Typesense/MinIO connection info

Fixes:
- next.config.js: CSP connect-src allows API origins for all non-prod envs
- next.config.js: image remotePatterns allow localhost in test mode
- .env.test: add NEXT_PUBLIC_API_URL and CORS_ORIGINS
- playwright.config.ts: spread process.env into webServer env configs
- e2e.yml: add NEXT_PUBLIC_API_URL, API_PORT, WEB_PORT to GH Actions env
- homepage.spec.ts: update stale assertions to match current UI

Result: 147/202 tests passing (111 API + 36 web), up from 37/91.
Remaining 55 web failures are stale UI assertions needing frontend update.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-13 01:55:04 +07:00
Ho Ngoc Hai
25420720e7 fix(api,ci): remove type-only imports for DI and isolate CI ports from dev
- Remove `type` keyword from NestJS injectable class imports across all
  modules to fix runtime DI resolution (330+ handler/listener files)
- Offset CI docker-compose ports (5433/6380/8109/9002) to avoid
  conflicts with running dev containers
- Update .env.test, playwright.config.ts, and e2e workflow to use
  isolated CI ports with configurable overrides
- Fix prisma/seed.ts to use deterministic IDs for Prisma 7 upsert
  compatibility (phoneHash replaced phone as unique index)
- Add dedicated Docker bridge network for CI service containers

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-13 01:40:14 +07:00
Ho Ngoc Hai
33c2e5ac1d feat(load-tests): add K6 coverage for search, admin, and MCP endpoints
Add three new K6 load test scripts to cover previously untested API surfaces:

- search-advanced.js: Combined geo + text + filter queries, paginated deep
  search, and sort variations against /search and /search/geo (300 peak VUs)
- admin.js: Moderation queue CRUD, bulk moderation, dashboard stats, audit
  logs, and user management endpoints (50 peak VUs)
- mcp.js: MCP server discovery, SSE connection, property-search tool calls,
  valuation/batch-valuation, and feature extraction (120 peak VUs)

Also updates README with new suite documentation, per-suite custom thresholds,
and adds the new suites to the CI workflow_dispatch selector.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-11 20:14:52 +07:00
Ho Ngoc Hai
64c6074735 feat(devops): add staging auto-deploy pipeline on develop branch
- Trigger deploy workflow on push to `develop` branch (in addition to `master`)
- Add `staging-latest` Docker image tag for develop branch builds
- Add `rollback-staging` job: auto-reverts to previous images on smoke test failure
- Add Slack success notification for staging deploys (previously only failure was notified)
- Record pre-deploy image digests for rollback capability
- Update deployment docs with CI/CD pipeline details, rollback procedures, and required secrets

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-11 01:18:37 +07:00
Ho Ngoc Hai
8cdfe17205 feat(ops): add automated backup restore verification
Adds pg-verify-backup.sh that restores the latest backup to an isolated
test database and verifies integrity (table existence, row counts, key
checksums, PostGIS extension, indexes, enum types). Reports pass/fail
with optional JSON output.

- Cron schedule: daily at 04:00 UTC (2h after backup)
- On-demand: docker compose run --rm pg-verify-backup
- CI: weekly GitHub Actions workflow with artifact upload

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 23:19:43 +07:00
Ho Ngoc Hai
9b786c1c95 deps: enhance Dependabot config for monorepo coverage and security
- Add npm monitoring for apps/api, apps/web, and libs/mcp-servers
  directories alongside root workspace
- Reduce open-pull-requests-limit from 10 to 5 per ecosystem
- Add dependency groups for Next.js and React packages
- Remove stale pip and docker entries for non-existent libs/ai-services
- Add documentation header explaining security update strategy
- Security updates rely on GitHub's built-in Dependabot Security
  Updates feature (daily automatic PRs for advisories)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 21:13:09 +07:00
Ho Ngoc Hai
017d85247e fix(security): harden security headers across API and Web apps
- API: set X-Frame-Options to DENY via frameguard, add Permissions-Policy header, widen CSP connect-src for Swagger CDN
- Web: add HSTS header (1yr, includeSubDomains, preload), add payment=(self) to Permissions-Policy, make localhost:3001 in CSP connect-src dev-only

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 20:10:22 +07:00
Ho Ngoc Hai
2a8799ac5b fix(ci): correct workflow branch targets from main to master
All three GitHub Actions workflows (CI, E2E, Deploy) referenced
branches: [main] but the repository default branch is master.
This meant CI never triggered on pushes or PRs to master.

- ci.yml: push/PR triggers → master
- e2e.yml: push/PR triggers → master
- deploy.yml: push trigger + latest tag condition → master

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 19:20:49 +07:00
Ho Ngoc Hai
e6d38c796f feat(ci): add post-deploy smoke test pipeline stage
- Add scripts/smoke-test.sh — hits health, readiness, and critical API
  endpoints (listings, search, subscriptions) post-deploy
- Add smoke-test-staging job that runs after staging deploy with Slack
  notification on failure
- Add smoke-test-production job that runs after production deploy with
  success notification
- Add rollback-production job triggered on smoke test failure — reverts
  to previous container images and notifies via Slack

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:09:09 +07:00
Ho Ngoc Hai
a8e1a438b9 feat(load-tests): add K6 load testing suite for critical API paths
K6 scripts for 4 critical paths:
- Auth (100 VU): login, register, profile
- Listings (500 VU): search with filters, detail view
- Search (200 VU): full-text + geo search
- Payments (50 VU): create payment, list transactions

SLA thresholds: p50<200ms, p95<500ms, p99<1s, error<1%.
CI: manual workflow_dispatch with suite selector.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 08:41:15 +07:00
Ho Ngoc Hai
4d91c04b88 docs: add comprehensive K6 load testing guide with API structure
- Document all API endpoints (auth, listings, payments, search)
- Include DTOs and request/response body shapes
- Document authentication methods and rate limits
- Provide database and environment configuration
- Include existing test setup (Playwright, Vitest)
- Detail CI/CD pipeline structure
- Recommend K6 endpoints and test patterns
- Provide file location references for quick lookup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 01:34:15 +07:00
Ho Ngoc Hai
c00ac88f26 fix(deploy): allow variable expansion in deploy scripts and add web health route
Fix heredoc quoting in deploy workflow to allow IMAGE_TAG and
REGISTRY_URL variable expansion. Add Next.js API health check route.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 23:07:45 +07:00
Ho Ngoc Hai
6552e6a661 fix(ci): improve E2E workflow with Prisma generate, browser cache, and trace artifacts
- Add missing `pnpm db:generate` step before migrations (Prisma client was not generated)
- Add Playwright browser caching to speed up CI runs
- Upload trace artifacts on failure for easier debugging
- Remove redundant `pnpm build` step (Playwright webServer uses dev commands)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 23:06:32 +07:00
Ho Ngoc Hai
03231271ca fix(security): remove MinIO hardcoded credentials & add presigned URL support
- Remove hardcoded minioadmin/minioadmin_secret fallback from docker-compose.yml,
  require MINIO_ACCESS_KEY/MINIO_SECRET_KEY env vars (fail-fast with :? syntax)
- Align docker-compose.yml env var names with .env.example (MINIO_ACCESS_KEY/SECRET_KEY)
- Update CI e2e workflow to use GitHub vars with non-default fallbacks
- Update .env.test to use non-default test credentials
- Add @aws-sdk/s3-request-presigner and getPresignedUploadUrl() method to
  MinioMediaStorageService for properly signed client-side uploads
- Remove hardcoded credentials from dev-environment docs

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 22:44:50 +07:00
Ho Ngoc Hai
271ad76e6f fix: resolve E2E test failures and API runtime issues for Docker dev environment
- Fix DI issues: circular MCP module dependency, EventBus type import,
  SearchModule provider, CacheService metric counters placement
- Fix Express 5 readonly req.query in SanitizeInputMiddleware
- Fix Typesense client lazy initialization (getter instead of constructor)
- Fix MinIO bucket init error handling (non-fatal on 403)
- Fix missing class-validator decorators on bigint DTO fields (priceVND, amountVND)
- Fix subscription plan 404 (was returning 500 for invalid tier)
- Disable CSRF and raise rate limits in test environment
- Update E2E tests to match actual API response shapes
- Update CI workflow with Redis, Typesense, MinIO services and env vars

All 101 API E2E tests now pass against Docker dev environment.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 05:44:00 +07:00
Ho Ngoc Hai
7c9f682046 feat(deploy): add production Dockerfiles and CI/CD pipeline
- Multi-stage Dockerfile for apps/api (NestJS) and apps/web (Next.js standalone)
- Production docker-compose.prod.yml with all services, health checks, and security
- Real deploy.yml pipeline: build → push to GHCR → deploy staging/production
- .dockerignore for optimized build context
- Enable Next.js standalone output mode

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 04:03:27 +07:00
Ho Ngoc Hai
19dd59e4eb ci: add GitHub Actions CI/CD pipelines
- Add ci.yml with lint, typecheck, test, build steps + PostgreSQL service
- Add deploy.yml scaffold with Docker build placeholders

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 02:04:24 +07:00
Ho Ngoc Hai
9301f44119 feat(e2e): add Playwright E2E testing infrastructure and critical path tests
Set up Playwright with dual-project config (API + Web), auth test fixtures,
16 E2E tests covering registration, login, profile, token refresh, and
homepage rendering. Added GitHub Actions CI workflow for automated E2E runs.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 01:41:07 +07:00