feat: sase.tr v2 full application implementation
Complete rewrite of sase.tr VIN lookup platform with modern stack: Backend (NestJS 10 + Drizzle ORM + PostgreSQL + Redis + BullMQ): - 34 DB models (core + PL24 + EMEX schemas) - Auth via Better Auth (email/password + social) - Brands, Plans, Subscriptions, Payments (iyzico + EFT) - VIN decode orchestration (Corgi + PL24 + EMEX + NHTSA) - Interactive schema viewer backend (MinIO storage) - EMEX scraping integration (Puppeteer + BullMQ workers) - Translation module (EN→TR automotive dictionary) - Admin dashboard API (stats, user mgmt, payment approval) - Rate limiting, Helmet security, file upload validation Frontend (Next.js 15 + Tailwind v4 + shadcn/ui + TanStack Query + Zustand): - 20 routes: auth, dashboard, VIN search, schema viewer, admin - Interactive schema viewer with zoom/pan/hotspot highlighting - Subscription management with brand selector - Payment flow (iyzico 3D Secure + EFT with receipt upload) - i18n support (TR/EN) - Error boundaries, loading skeletons, 404 page Infrastructure: - 85 tests (52 backend + 33 frontend, Vitest) - CI/CD (GitHub Actions: lint, typecheck, test, build, deploy) - Zero-downtime deploy script (PM2) - Env validation script Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
202
apps/api/src/database/schema/pl24.ts
Normal file
202
apps/api/src/database/schema/pl24.ts
Normal file
@@ -0,0 +1,202 @@
|
||||
import {
|
||||
pgTable,
|
||||
uuid,
|
||||
varchar,
|
||||
text,
|
||||
boolean,
|
||||
integer,
|
||||
timestamp,
|
||||
jsonb,
|
||||
index,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
// ─── PL24 Catalog ───────────────────────────────────
|
||||
export const pl24Catalogs = pgTable(
|
||||
"pl24_catalogs",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
catalogId: varchar("catalog_id", { length: 100 }).notNull(),
|
||||
brandName: varchar("brand_name", { length: 100 }).notNull(),
|
||||
description: text("description"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [uniqueIndex("pl24_catalogs_catalog_id_idx").on(table.catalogId)],
|
||||
);
|
||||
|
||||
// ─── PL24 Vehicle ───────────────────────────────────
|
||||
export const pl24Vehicles = pgTable(
|
||||
"pl24_vehicles",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
catalogId: uuid("catalog_id").references(() => pl24Catalogs.id, { onDelete: "cascade" }),
|
||||
vehicleId: varchar("vehicle_id", { length: 100 }).notNull(),
|
||||
name: varchar("name", { length: 500 }),
|
||||
modelCode: varchar("model_code", { length: 100 }),
|
||||
engine: varchar("engine", { length: 255 }),
|
||||
transmission: varchar("transmission", { length: 100 }),
|
||||
bodyType: varchar("body_type", { length: 100 }),
|
||||
market: varchar("market", { length: 100 }),
|
||||
yearFrom: integer("year_from"),
|
||||
yearTo: integer("year_to"),
|
||||
rawData: jsonb("raw_data"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("pl24_vehicles_vehicle_id_idx").on(table.vehicleId),
|
||||
index("pl24_vehicles_catalog_id_idx").on(table.catalogId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Vehicle VIN ───────────────────────────────
|
||||
export const pl24VehicleVins = pgTable(
|
||||
"pl24_vehicle_vins",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24VehicleId: uuid("pl24_vehicle_id").references(() => pl24Vehicles.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
vin: varchar("vin", { length: 17 }).notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_vehicle_vins_vin_idx").on(table.vin),
|
||||
index("pl24_vehicle_vins_vehicle_id_idx").on(table.pl24VehicleId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Part Group ────────────────────────────────
|
||||
export const pl24PartGroups = pgTable(
|
||||
"pl24_part_groups",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24VehicleId: uuid("pl24_vehicle_id").references(() => pl24Vehicles.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
groupId: varchar("group_id", { length: 100 }).notNull(),
|
||||
name: varchar("name", { length: 500 }).notNull(),
|
||||
parentGroupId: varchar("parent_group_id", { length: 100 }),
|
||||
sortOrder: integer("sort_order"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_part_groups_vehicle_id_idx").on(table.pl24VehicleId),
|
||||
index("pl24_part_groups_group_id_idx").on(table.groupId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Part ──────────────────────────────────────
|
||||
export const pl24Parts = pgTable(
|
||||
"pl24_parts",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24VehicleId: uuid("pl24_vehicle_id").references(() => pl24Vehicles.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
groupId: uuid("group_id").references(() => pl24PartGroups.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
partId: varchar("part_id", { length: 100 }),
|
||||
name: varchar("name", { length: 500 }).notNull(),
|
||||
description: text("description"),
|
||||
quantity: integer("quantity"),
|
||||
position: varchar("position", { length: 100 }),
|
||||
hotspotIndex: integer("hotspot_index"),
|
||||
rawData: jsonb("raw_data"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_parts_vehicle_id_idx").on(table.pl24VehicleId),
|
||||
index("pl24_parts_group_id_idx").on(table.groupId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Part Number ───────────────────────────────
|
||||
export const pl24PartNumbers = pgTable(
|
||||
"pl24_part_numbers",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24PartId: uuid("pl24_part_id").references(() => pl24Parts.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
oemCode: varchar("oem_code", { length: 100 }).notNull(),
|
||||
isMain: boolean("is_main").default(true).notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_part_numbers_part_id_idx").on(table.pl24PartId),
|
||||
index("pl24_part_numbers_oem_code_idx").on(table.oemCode),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Vehicle Group ─────────────────────────────
|
||||
export const pl24VehicleGroups = pgTable(
|
||||
"pl24_vehicle_groups",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
catalogId: uuid("catalog_id").references(() => pl24Catalogs.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
groupId: varchar("group_id", { length: 100 }).notNull(),
|
||||
name: varchar("name", { length: 500 }).notNull(),
|
||||
parentGroupId: varchar("parent_group_id", { length: 100 }),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_vehicle_groups_catalog_id_idx").on(table.catalogId),
|
||||
index("pl24_vehicle_groups_group_id_idx").on(table.groupId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Vehicle Part ──────────────────────────────
|
||||
export const pl24VehicleParts = pgTable(
|
||||
"pl24_vehicle_parts",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24VehicleId: uuid("pl24_vehicle_id").references(() => pl24Vehicles.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
pl24PartId: uuid("pl24_part_id").references(() => pl24Parts.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
fitmentInfo: text("fitment_info"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index("pl24_vehicle_parts_vehicle_id_idx").on(table.pl24VehicleId),
|
||||
index("pl24_vehicle_parts_part_id_idx").on(table.pl24PartId),
|
||||
],
|
||||
);
|
||||
|
||||
// ─── PL24 Schema Pic ────────────────────────────────
|
||||
export const pl24SchemaPics = pgTable(
|
||||
"pl24_schema_pics",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
groupId: uuid("group_id").references(() => pl24PartGroups.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
imageUrl: text("image_url").notNull(),
|
||||
originalUrl: text("original_url"),
|
||||
hotspots: jsonb("hotspots").default("[]").notNull(),
|
||||
width: integer("width"),
|
||||
height: integer("height"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [index("pl24_schema_pics_group_id_idx").on(table.groupId)],
|
||||
);
|
||||
|
||||
// ─── PL24 Part Image ────────────────────────────────
|
||||
export const pl24PartImages = pgTable(
|
||||
"pl24_part_images",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
pl24PartId: uuid("pl24_part_id").references(() => pl24Parts.id, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
imageUrl: text("image_url").notNull(),
|
||||
originalUrl: text("original_url"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
},
|
||||
(table) => [index("pl24_part_images_part_id_idx").on(table.pl24PartId)],
|
||||
);
|
||||
Reference in New Issue
Block a user