Mockdaten-Generator-Experten-Prompt
Von Wikiprompt, der freien Prompt-Enzyklopädie
Mockdaten-Generator-Experten-Prompt Ein umfassender System-Prompt zur Generierung realistischer Mock-Daten mit Faker.js, der Workflows, Domänen, Best Practices und Qualitäts-Checklisten abdeckt.
Prompt-InhaltSpeichern
🌐
# Mock Data Generator - TODO
## Context
- **Target Database Schema**: Flexible multi-domain schema covering e-commerce, finance, healthcare, and social media
- **Data Volume**: Development (small) - 100-1000 records; Testing (medium) - 10,000+ records
- **Use Case**: Test fixtures, API mocks, and database seeds
- **Output Format**: JSON, SQL, CSV, TypeScript
## Generation Plan
### Entity & Schema Planning
- [ ] **MOCK-PLAN-1.1 [Users Entity]**:
- **Schema**: id (UUID), firstName, lastName, email (unique), phone, createdAt, updatedAt, status (active/suspended/closed)
- **Volume**: 1000 records
- **Format**: JSON, and SQL
- **Edge Cases**: Min/max name lengths, invalid emails, null optional fields, duplicate prevention
- [ ] **MOCK-PLAN-1.2 [Products Entity]**:
- **Schema**: id (SKU format PROD-XXXX), name, description, price (2dp), stockQuantity, categoryId (FK), createdAt, updatedAt
- **Volume**: 500 records
- **Format**: JSON, and SQL
- **Edge Cases**: Zero price, negative stock test, max price dec, unicode in descriptions
- [ ] **MOCK-PLAN-1.3 [Orders Entity]**:
- **Schema**: id (ORDER-XXXXX), userId (FK), orderDate, status (pending, paid, shipped, delivered, cancelled), total (computed)
- **Volume**: 2000 records
- **Format**: JSON, and SQL
- **Edge Cases**: Order before user birthday, null delivery date for pending, totals with extreme values
- [ ] **MOCK-PLAN-1.4 [OrderItems Relation]**:
- **Schema**: orderId (FK), productId (FK), quantity, priceSnapshot
- **Volume**: 5000 records (2-5 items per order)
- **Format**: JSON, and SQL
- **Edge Cases**: Quantity nullable (checkout removed), product discontinued (zero stock)
- [ ] **MOCK-PLAN-1.5 [Reviews Entity]**:
- **Schema**: id, productId (FK), userId (FK), rating (1-5), comment, createdAt
- **Volume**: 3000 records
- **Format**: JSON, and SQL
- **Edge Cases**: Rating 0 and 6 for schema-valid, empty comments, emoji and unicode
### Deep-Dive Data Modeling
- [ ] **MOCK-PLAN-1.6 [Addresses Entity]**:
- **Schema**: id, userId (FK), country, state, city, postalCode, street, isPrimary
- **Volume**: 2000 records (multiple user addresses)
- **Format**: TypeScript objects
- **Edge Cases**: Extremely long street names, invalid postal codes (special), null country (shipping)
- [ ] **MOCK-PLAN-1.7 [Product Categories Tree]**:
- **Schema**: id, parentId (nullable), level, name, slug, description
- **Volume**: 50 records (4 levels deep)
- **Format**: CSV and JSON
- **Edge Cases**: Root (parent null), circular references prevention, duplicated slugs
- [ ] **MOCK-PLAN-1.8 [API Response Models]**:
- **Schema**: Standard REST envelope with data, meta, and errors
- **Volume**: 5 examples per endpoint (success, error, validation, not found, pagination)
- **Format**: JSON
- **Edge Cases**: 204 No Content, 500 error (empty errors array), gate delayed (429), network blips
## Generation Items
### Core Data Generation Tasks
- [ ] **MOCK-ITEM-1.1 [User Dataset Builder]**:
- **Entity**: Users
- **Generator**: Faker.js `faker.internet.email`, `faker.name.firstName`, `faker.name.lastName`, custom `randomStatus()`
- **Relationships**: None (standalone), to be referenced by Addresses, Orders, Reviews
- **Validation**: Email uniqueness enforced by `faker.helpers.unique`
- [ ] **MOCK-ITEM-1.2 [Product Catalog Generator]**:
- **Entity**: Products
- **Generator**: `faker.commerce.productName`, `faker.commerce.price`, custom category assignment from `PRODUCT_CATEGORIES`
- **Relationships**: Categories (many-to-one)
- **Validation**: SKUs are unique and follow strict regex
- [ ] **MOCK-ITEM-1.3 [Order and Line Items Factory]**:
- **Entity**: Orders, Order Items
- **Generator**: `faker.date.between` for timestamps wisely, `faker.helpers.arrayElement` for status
- **Relationships**: Users (FK), Orders (FK) -> orderItems (FK productId)
- **Validation**: Generate totals consistently (sum. quantity * priceSnapshot = total)
### Edge Case Implementation Tasks
- [ ] **MOCK-ITEM-1.4 [Boundary Value Seeds]**:
- **Entity**: All entities
- **Generator**: Custom `boundaryCase()`
- **Relationships**: N/A
- **Validation**: Ensure 100% edge-case coverage by explicit records (e.g., null createdAt, max-length book description)
- [ ] **MOCK-ITEM-1.5 [Large Dataset with Index Hints]**:
- **Entity**: Orders, Products, Users (load test scenario)
- **Generator**: `streamArray()` with seeded RNG
- **Relationships**: FK cascade rules (ON DELETE = CASCADE)
- **Validation**: Using `EXPLAIN ANALYZE` before/after
- [ ] **MOCK-ITEM-1.6 [Audit Trail / Log Seeding]**:
- **Entity**: AuditLog
- **Generator**: Faker's `faker.internet.ipv4`, `faker.date.between`, JSON object for metadata
- **Relationships**: userId (optional, can be null for anonymous actions)
- **Validation**: Ensure sequence isn't broken if local timezone changes
## Proposed Code Changes
### Patch-Style Diffs For Generators
```
+---- scripts/
+ |-- generate-users.js
+ |-- generate-products.js
+ |-- generate-orders.js
+ +-- generate-reviews.js
```
1. `[file: scripts/generate-users.js]`:
```diff
+import { faker } from '@faker-js/faker';
+faker.seed(12345); // deterministic
+const users = Array.from({ length: 1200 }, () => ({
+ id: faker.string.uuid(),
+ firstName: faker.person.firstName(),
+ lastName: faker.person.lastName(),
+ email: faker.helpers.unique(faker.internet.email, [faker.person.firstName(), faker.person.lastName()]),
+ phone: faker.phone.number({ style: 'national' }),
+ status: faker.helpers.arrayElement(['active', 'suspended', 'archived'], 1),
+ createdAt: faker.date.past({ years: 5 }),,
+ updatedAt: faker.date.recent({ days: 90 }),
+}));
export default users;
```
### Command-Line Interface
- **Local**:
```bash
npm run seed:generate # outputs JSON + SQL
npm run seed:clean # reverses
```
- **CI**:
```bash
npm run test:integration # After seeding
```
### SQL Seed Template (PostgreSQL-Compliant)
```sql
INSERT INTO "public"."Users" ("id", "firstName", "lastName", "email", "createdAt", "updatedAt")
VALUES
(:id, :firstName, :lastName, :email, :createdAt, :updatedAt);
```
## Validation Task List (Must-Have in Code)
- [ ] `validateUser.js` - Regex for email, sanity check on date ranges
- [ ] Return `boolean`/`throw new Error` on failure
- [ ] `validateProduct.js` - Price ≥ 0, category exists, unique SKU
- [ ] `validateOrders.js` - Sum check using productSeed array, ensure “userId” FK spells correctly
- [ ] `validateReferences()` - Ensures all FK (orders.user -> user.id) exist in pool before mutagenesis
## Quality Assurance Task Checklist
Before finalizing the generator:
- [ ] **Q-1**: Strict schema check on all entities
- [ ] **Q-2**: FK satisfied, no orphans after cleanup
- [ ] **Q-3**: Deterministic → `seed(12345)` same data on every run
- [ ] **Q-4**: Edge cases are deliberately sprinkled (e.g., 0 reviews, post-Feb 29to)
- [ ] **Q-5**: Output is valid per target DB (`psql \"\\copy\"` or Stored Procedure)
- [ ] **Q-6**: Cleanup scripts in `teardown.sql` are provided and run w/o errors
- [ ] **Q-7**: Time to generate < 5 sec for 10K (measure various volumes)
- [ ] **Q-8**: Unique email/SKU > 99.99% success rate
## Commands to Execute
### Local Data Generation
```bash
# Will generate `/data` JSON and `/sql` inserts
npm run db:seed -- --environment dev
```
### Verify During CI
```bash
npm install # ensures Faker version pin
npx eslint generated-data/*.ts include "no-null-eslint" - for js lint
npm ci
npm run seed:all --no-daemon
```
### Cleanup Script Path
```
cleanup/
destroy-orders.sql
destroy-reviews.sql
destroy-users.sql
(~/scripts/cleanup-all.sh)
```
## Red Flag Checks
- [ ] No hardcoded “John Doe” names in any dataset
- [ ] Every table has at least 3 formatting types (2 English, 1 Unicode)
- [ ] Every column got <1% Null in an optional case (validate percentage algorithm)
- [ ] `generated - faker@9.5.0` is in dependencies list
- [ ] Cross-entity consistency: order timestamp ≥ createdAt, ≥ updatedAt
- [ ] Run `psql -f seed.sql` and confirm 0 output scripts
- [ ] Verify no ad-hoc temp tables left (clean)
---
This is the completed **mock-data-plan as TODO** output aimed at LLM/Dev. Use checkboxes and task IDs directly to track implementation in code review via IDE opened report enhance.
Melde dich an, um den vollständigen Prompt zu sehen
Weiter mit:
Mit der Anmeldung akzeptierst du unsere Nutzungsbedingungen und Datenschutz
Verwendung
Dieser Prompt ist für die Verwendung mit coding gedacht. Kopiere den Inhalt oben und füge ihn in dein bevorzugtes KI-Tool ein.
Für beste Ergebnisse passe die Platzhalter (eckige Klammern oder Großbuchstaben) an deine Anforderungen an.
Diskussion
0 Kommentare