# Database Seeding Architecture This system uses a modular, two-tier seeding architecture. It ensures that UI/Load testing has plenty of random data, while Automated Integration Tests (API tests) have predictable, hardcoded constraints. The seed pipeline completely clears the database constraints (`TRUNCATE CASCADE`) on every run in `dev`/`staging` environments to prevent drift and mathematical average corruption. ## Tier 1: Fixed Test Data (For API & Integration Tests) This data is completely deterministic. The UUIDs, Usernames, Passwords, and relationships never change. **Global Test Password:** `password123` ### The 4 Fixed Users: 1. **`user_1`** (`user_1@test.io`) * UUID: `11111111-1111-4111-8111-111111111111` * Role in Seed: Rates the target track a `10`. 2. **`user_2`** (`user_2@test.io`) * UUID: `22222222-2222-4222-8222-222222222222` * Role in Seed: The "Producer". Owns the Root Project and the Test Tracks. 3. **`user_3`** (`user_3@test.io`) * UUID: `33333333-3333-4333-8333-333333333333` * Role in Seed: The "Artist". Replies to comments. 4. **`user_4`** (`user_4@test.io`) * UUID: `44444444-4444-4444-8444-444444444444` * Role in Seed: The "Reviewer". Rates the track an `8` and leaves a root-level comment. ### The Fixed Entities: * **Genre**: `"Testing Audio"` (UUID: `aaaaaaaa-aaaa...`) * **Project**: `"Fixed Test Project"` (Owned by `user_2`) * **Track Lineage**: `"Fixed Test Single"` * `Version 1` (UUID: `66666666-6666...`) -> `Version 2` (UUID: `77777777-7777...`) * Owned by `user_2`. * **Social Threading** (Attached to Track V2): * `user_4` writes a root comment (UUID: `88888888...`) * `user_3` writes a nested reply (UUID: `99999999...`) * Pre-calculated Rating Math: Exactly `9.0` out of `2` votes. --- ## Tier 2: Dynamic Random Data (For UI & Load Testing) This data is randomly distributed across the database. It is explicitly instructed to **ignore** `user_1` to `user_4` and the `"Fixed Test Single"` tracks, guaranteeing your test entities are never polluted with randomized junk. * **Production Genres**: Maps 16 Core Production Genres (Pop, Hip Hop, Rock, Electronic, R&B, Latino, Afrobeats, Reggae, K-Pop, Jazz, Blues, Country, Folk, Ambient, Lo-fi, Chill) and over 60+ nested sub-genres dynamically linking to UI hex colors. * **Users**: 45 generated profiles (e.g., `JamesSmith_0`, `TaylorDavis_14`). Password is `password123`. Users are automatically assigned 1-3 favorite genres. * **Projects**: 30 random workspace projects simulating DAW state. * **Tracks**: 40 random linear track trees. Automatically distributed public vs private. * **Social**: 80 random threaded comments. Simulates organic interaction by dynamically deciding to post root comments or nested replies to existing threads. * **Ratings Math**: Dynamic in-memory calculations (Score / Count) to ensure GORM properly saves the exact Track `AverageRating` without breaking composite index constraints (No user rates the same track twice).Math**: Dynamic in-memory calculations (Score / Count) to ensure GORM properly saves the exact Track `AverageRating` without breaking composite index constraints (No user rates the same track twice).