feat(api): add industrial, transfer, and reports backend modules

Add three new NestJS modules following DDD/CQRS architecture:
- Industrial: KCN (industrial park) management with PostGIS geo queries, Typesense search, and market statistics
- Transfer: Furniture/premises transfer listings with AI-powered price estimation and depreciation modeling
- Reports: Async AI report generation via BullMQ with Claude narrative service, PDF generation, and macro data integration

Includes Prisma schema models, migrations, seed scripts, and app.module wiring with BullMQ Redis config.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-16 09:11:16 +07:00
parent 7ce651fce5
commit deb04989de
123 changed files with 8260 additions and 12 deletions

View File

@@ -0,0 +1,77 @@
-- CreateEnum
CREATE TYPE "ReportType" AS ENUM ('RESIDENTIAL_MARKET', 'INDUSTRIAL_MARKET', 'DISTRICT_ANALYSIS', 'INVESTMENT_FEASIBILITY', 'INDUSTRIAL_LOCATION', 'PROPERTY_VALUATION', 'PORTFOLIO');
-- CreateEnum
CREATE TYPE "ReportStatus" AS ENUM ('GENERATING', 'READY', 'FAILED');
-- AlterTable: Add maxReports to Plan
ALTER TABLE "Plan" ADD COLUMN "maxReports" INTEGER;
-- CreateTable: Report
CREATE TABLE "Report" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"type" "ReportType" NOT NULL,
"title" TEXT NOT NULL,
"params" JSONB NOT NULL,
"content" JSONB,
"pdfUrl" TEXT,
"status" "ReportStatus" NOT NULL DEFAULT 'GENERATING',
"errorMsg" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Report_pkey" PRIMARY KEY ("id")
);
-- CreateTable: MacroeconomicData
CREATE TABLE "MacroeconomicData" (
"id" TEXT NOT NULL,
"province" TEXT NOT NULL,
"indicator" TEXT NOT NULL,
"value" DOUBLE PRECISION NOT NULL,
"unit" TEXT NOT NULL,
"period" TEXT NOT NULL,
"source" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MacroeconomicData_pkey" PRIMARY KEY ("id")
);
-- CreateTable: InfrastructureProject
CREATE TABLE "InfrastructureProject" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"province" TEXT NOT NULL,
"category" TEXT NOT NULL,
"status" TEXT NOT NULL,
"investmentVND" BIGINT,
"startDate" TIMESTAMP(3),
"completionDate" TIMESTAMP(3),
"description" TEXT,
"impactRadius" DOUBLE PRECISION,
"location" geometry(Point, 4326),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "InfrastructureProject_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Report_userId_createdAt_idx" ON "Report"("userId", "createdAt" DESC);
CREATE INDEX "Report_userId_type_idx" ON "Report"("userId", "type");
CREATE INDEX "Report_status_idx" ON "Report"("status");
-- CreateIndex
CREATE UNIQUE INDEX "MacroeconomicData_province_indicator_period_key" ON "MacroeconomicData"("province", "indicator", "period");
CREATE INDEX "MacroeconomicData_province_idx" ON "MacroeconomicData"("province");
CREATE INDEX "MacroeconomicData_indicator_period_idx" ON "MacroeconomicData"("indicator", "period");
-- CreateIndex
CREATE INDEX "InfrastructureProject_province_idx" ON "InfrastructureProject"("province");
CREATE INDEX "InfrastructureProject_category_idx" ON "InfrastructureProject"("category");
CREATE INDEX "InfrastructureProject_status_idx" ON "InfrastructureProject"("status");
CREATE INDEX "InfrastructureProject_province_category_idx" ON "InfrastructureProject"("province", "category");
-- AddForeignKey
ALTER TABLE "Report" ADD CONSTRAINT "Report_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;