Seed Infrastructure
The make seed-full command populates the entire Ngwenya platform with realistic, production-representative test data using a 22-archetype approach. Every user archetype represents a specific permission/tier/role combination to maximize coverage of platform capabilities.
NOTE
This infrastructure lives in scripts/db/verticals/ in the ngwenya-federation repository. The full seed runs in ~5 seconds on an M-series Mac.
Quick Start
# Prerequisites: infrastructure containers must be running
make infra-up
# Full platform seed โ all 22 archetypes, orgs, verticals, social, commerce, enterprise
make seed-full
# Individual phases (can run independently)
make seed-users # Auth users โ Postgres (21 users + guest token)
make seed-profiles # User profiles โ nodes MongoDB
make seed-verticals # Orgs + all 11 malets
make seed-blogs # Blog posts for all malets
# Clean everything and start fresh
make seed-clean && make seed-full
Environment Variables
| Variable | Default | Description |
|---|---|---|
GATEWAY_URL |
http://localhost:30000/graphql |
Hive Gateway endpoint |
MONGODB_URI |
mongodb://localhost:27017/ngwenya |
MongoDB connection string |
DATABASE_URL |
postgres://postgres:password@localhost:5432/ngwenya_auth |
Auth Postgres connection |
CONTAINER_CMD |
podman |
Container CLI (podman or docker) |
TOKEN |
Dev session token | Auth header for GQL mutations |
Seed Architecture
Two-Plane Approach
The seed system mirrors the platform's architectural split:
| Plane | Method | Used For |
|---|---|---|
| Auth Plane | psql via container exec |
Users, platform admins, guest tokens (Postgres) |
| Control Plane | GraphQL mutations via Gateway | Malets, Products, Services โ entities with business-logic validators |
| Feature Plane | Direct MongoDB inserts via Mongoose | Profiles, follows, wishlists, reviews, enterprise config |
Phase Execution Order
Phase 1: Auth users (Postgres) โ 21 users + 1 guest token + platform admins
Phase 2: User profiles (nodes/MongoDB) โ 20 profiles (2 deliberately missing)
Phase 3: Organizations & Teams โ 2 orgs (PRO + ENTERPRISE), teams, memberships
Phase 4: Verticals (seed-all.ts) โ 11 malets, products, services, experiences
Phase 5: Blog Posts โ ~22 posts across all malets
Phase 6: Social graph โ 40+ follows, 7 wishlists, 16+ likes
Phase 7: Commerce โ 8 orders, 4 carts, 8+ reviews
Phase 8: Community โ 5 discussions, 17+ comments, 3 posts
Phase 9: Enterprise โ SAML, SCIM, custom roles, SIEM, audit events
Phase 10: Meilisearch Reindex โ Rebuild search indexes (non-fatal if unavailable)
File Structure
scripts/db/verticals/
โโโ shared/
โ โโโ config.ts # GATEWAY_URL, MONGODB_URI, POSTGRES_URI, TOKEN
โ โโโ gql-client.ts # GraphQL client with user impersonation
โ โโโ mongo.ts # Lazy Mongoose connection factory
โ โโโ ids.ts # oid(), daysAgo(), daysFromNow(), img()
โ โโโ users.ts # 22 users, 2 orgs, 11 malet definitions
โโโ seed-full.ts # Master orchestrator (all phases)
โโโ seed-users.ts # Phase 1: Auth users (Postgres)
โโโ seed-profiles.ts # Phase 2: User profiles (MongoDB)
โโโ seed-orgs.ts # Phase 3: Organizations + Teams
โโโ seed-all.ts # Phase 4: All 11 verticals
โโโ seed-social.ts # Phase 6: Follows, wishlists, likes
โโโ seed-commerce.ts # Phase 7: Orders, carts, reviews
โโโ seed-community.ts # Phase 8: Discussions, comments, posts
โโโ seed-enterprise.ts # Phase 9: SAML, SCIM, roles, SIEM
โโโ clean.ts # Drops all seed collections
โโโ seed-{vertical}.ts # One per vertical (11 total)
User Archetype Matrix
๐ถ Solo Operators (Starter Tier โ No Org)
These users own a single malet without an organization. They exercise Starter tier limits (1 malet, 3 members max).
| # | Handle | Name | Malet | What They Exercise |
|---|---|---|---|---|
| 1 | amara-styles |
Amara Ndlovu | fashion-demo |
Products with variants/size charts, lookbooks, collections |
| 2 | zuri-writes |
Zuri Okafor | author-demo |
Content subscriptions, gated blogs, free vs premium |
| 3 | lens-maestro |
Kagiso Molefe | photo-demo |
Galleries, proofing sessions, image-heavy workflows |
| 4 | lerato-wellness |
Lerato Khumalo | serenity-spa-demo |
Membership plans + subscriptions, wellness profiles |
| 5 | lindiwe-advisory |
Lindiwe Dlamini | advisory-demo |
Client engagements, vault documents, professional services |
๐ท AfriArts Collective (Pro Tier โ Teams, 4 Malets)
Exercises org-scoped billing, team-based access, vertical roles, multi-malet management.
| # | Handle | Name | Org Role | Vertical Role | What They Exercise |
|---|---|---|---|---|---|
| 6 | thabo-mgmt |
Thabo Mthembu | OWNER | โ | Full org admin, billing, invites |
| 7 | naledi-ops |
Naledi Kgosi | MEMBER | KITCHEN | KDS access, order status updates |
| 8 | sipho-trails |
Sipho Dlamini | MEMBER | GUIDE | Booking views, manifest access |
| 9 | zanele-events |
Zanele Maseko | ADMIN | โ | Org admin, team management |
| 10 | bongani-viewer |
Bongani Nkosi | VIEWER | โ | Read-only analytics |
Malets: venue-demo, gallery-demo, tour-demo, restaurant-demo
Teams: "Events & Culture" (Thabo, Zanele), "Food & Tours" (Naledi, Sipho, Bongani)
๐ฃ Circuit Board Inc. (Enterprise Tier โ SAML/SCIM)
Exercises unlimited malets, SAML SSO, SCIM, SIEM, custom RBAC, 3% commission.
| # | Handle | Name | Org Role | Vertical Role | What They Exercise |
|---|---|---|---|---|---|
| 11 | kwame-tech |
Kwame Asante | OWNER | โ | SAML config, SCIM tokens, custom roles |
| 12 | ayanda-dev |
Ayanda Moyo | MEMBER | โ | Custom RBAC role assignment |
| 13 | fatima-editor |
Fatima Hassan | MEMBER | AUTHOR_EDITOR | Blog editing permissions |
Malets: tech-store-demo, pixel-vault-demo
๐ข Platform Admins (Tower Access)
| # | Handle | Name | Platform Role | What They Exercise |
|---|---|---|---|---|
| โ | meekdenzo |
Meek Denzo | SUPER_ADMIN | Full Tower access (pre-existing) |
| 14 | tower-admin |
Nandi Zulu | ADMIN | Limited tower management |
| 15 | tower-viewer |
Themba Sithole | VIEWER | Tower read-only access |
๐ก Consumers (7 Behavioral Archetypes)
| # | Handle | Name | Behavior | What They Exercise |
|---|---|---|---|---|
| 16 | shopper-pro |
Nomsa Mbeki | Power Buyer | 5 completed orders, reviews, full cart |
| 17 | casual-browser |
Thandeka Dube | Casual Browser | Follows 5 malets, 1 pending checkout, wishlists |
| 18 | social-connector |
Palesa Mokoena | Social Connector | Follows all 11 malets + all solo owners |
| 19 | list-curator |
Mpho Tau | Wishlist Curator | 5 custom lists, items from 8+ malets |
| 20 | community-voice |
Lesedi Phiri | Community Contributor | 10+ comments, 4 detailed reviews, 0 purchases |
| 21 | quiet-lurker |
Kabelo Mokgadi | Lurker | Zero activity โ tests empty-state UI |
| 22 | (anonymous) | โ | Guest | Guest token only, 2 cart items |
Organization Summary
| Org | Tier | Malets | Members | Teams | SAML | SCIM | Custom RBAC | SIEM |
|---|---|---|---|---|---|---|---|---|
| (none โ solo) | Starter | 1 each | N/A | N/A | โ | โ | โ | โ |
| AfriArts Collective | PRO | 4 | 5 | 2 | โ | โ | โ | โ |
| Circuit Board Inc. | ENTERPRISE | 2 | 3 | 0 | โ | โ | โ | โ |
Tier Capabilities
| Tier | Max Malets | Max Members | Requires Org | Custom RBAC | SAML/SCIM | SIEM | Commission |
|---|---|---|---|---|---|---|---|
| Starter | 1 | 3 | No | No | No | No | 8% |
| Pro | 5 | 10 | Yes | Yes | No | No | 5% |
| Enterprise | โ | โ | Yes | Yes | Yes | Yes | 3% |
Activity Coverage Matrix
Social Activity
| Activity | User | Count | Details |
|---|---|---|---|
| Follow malets | shopper-pro |
4 | fashion, tech, venue, tour |
| Follow malets | casual-browser |
5 | fashion, photo, author, spa, gallery |
| Follow malets | social-connector |
11 | All malets |
| Follow malets | list-curator |
3 | fashion, tech, tour |
| Follow users | social-connector |
7 | All solo owners + org owners |
| Follow users | casual-browser |
2 | amara, zuri |
| Follow users | community-voice |
3 | amara, lens-maestro, lerato |
| Mutual follow | amara-styles โ zuri-writes |
2 | Cross-follow |
| Mutual follow | social-connector โ shopper-pro |
2 | Consumer mutual |
| Zero follows | quiet-lurker |
0 | Tests empty social state |
| Wishlists | list-curator |
5 | Birthday, Office, Wardrobe, Art, Trips |
| Wishlists | shopper-pro |
1 | "My Favorites" |
| Wishlists | casual-browser |
1 | "Gift Ideas" |
| Blog likes | casual-browser |
5 | Across malets |
| Blog likes | social-connector |
8 | Likes everything |
| Blog likes | community-voice |
3 | Selective |
Commerce Activity
| Activity | User | Count | Details |
|---|---|---|---|
| Completed orders | shopper-pro |
5 | Across fashion + tech |
| Cancelled orders | shopper-pro |
2 | Exercises refund flow |
| Pending order | casual-browser |
1 | Incomplete checkout |
| Cart items | shopper-pro |
5 | Full cart |
| Cart items | casual-browser |
1 | Single item |
| Cart items | quiet-lurker |
1 | Abandoned cart |
| Cart items | guest-shopper |
2 | Guest cart |
| Reviews | shopper-pro |
3 | 3โ , 4โ , 5โ |
| Reviews | community-voice |
4 | Long-form, no purchases |
| Reviews | casual-browser |
1 | Service review |
Community Activity
| Activity | User | Details |
|---|---|---|
| Discussion: "Size guide question" | shopper-pro |
fashion-demo, 4 comments |
| Discussion: "Shipping to Zimbabwe?" | casual-browser |
fashion-demo, 3 comments |
| Discussion: "Best beginner camera?" | community-voice |
photo-demo, 5 comments |
| Discussion: "Warranty policy?" | community-voice |
tech-store-demo, 3 comments |
| Discussion: "Menu allergen info" | community-voice |
restaurant-demo, 2 comments |
| Community post | amara-styles |
"New Spring Collection" (ANNOUNCEMENT) |
| Community post | shopper-pro |
"My new outfit" (UGC) |
| Community post | community-voice |
"Top 5 Mallnline finds" (REVIEW_ROUNDUP) |
Adding New Seed Users
- Define the user in
shared/users.ts:
export const USER_NEW_ARCHETYPE: SeedUser = {
id: 'b1a2c3d4-e5f6-7890-abcd-XXYY00000001', // deterministic UUID
handle: 'new-handle',
displayName: 'Full Name',
email: 'name@domain.test',
description: 'What this user exercises',
};
- Add to
getAllUsers()array - Add to
seed-profiles.tsbio map (or it gets a default bio) - Register in auth โ
seed-users.tsauto-inserts allgetAllUsers()members - Add activity in
seed-social.ts,seed-commerce.ts, etc. as needed
WARNING
Never modify applied migrations. Auth migrations are checksummed by SQLx. To add platform admin records, create a new migration file with a timestamp prefix. See 20260505000000_add_info_admin.sql for the pattern.
Idempotency
All scripts are safe to re-run:
- Auth users:
ON CONFLICT (id) DO NOTHINGfor Postgres inserts - Malet creation:
ensureMalet()checks for existing handle first - Product creation:
ensureProduct()checks for existing slug+maletId before creating - MongoDB inserts: wrapped in try/catch that skips
E11000duplicate key errors - Deterministic IDs: User UUIDs are hardcoded in
shared/users.ts - Meilisearch reindex: Phase 10 automatically reindexes (non-fatal if Meilisearch is unavailable)
For a completely clean state, run make seed-clean before seeding.
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
Cannot connect to Postgres container |
Infrastructure not running | Run make infra-up first |
Users tab "Bad Request Exception" |
Missing class-validator decorators on DTOs | See admin-users.types.ts fix pattern |
Users tab "No users found" |
No profiles in nodes MongoDB | Run make seed-profiles |
| Tour services fail with "Bad Request" | Duration exceeds @Max(1440) validator |
Multi-day tours use direct MongoDB insert |
forbidNonWhitelisted rejection |
@ArgsType() DTOs missing class-validator decorators |
Add @IsOptional(), @IsString(), etc. |
| Billing subscription missing | Org created without billing bootstrap | seed-orgs.ts auto-creates tier-appropriate billing sub |
Related
- Vertical Seeding Infrastructure โ Per-vertical entity details and catalog integration
- Platform Admin Provisioning โ Tower access and invite-chain provisioning
- Gateway โ GraphQL API and subgraph architecture
- Tower โ Admin dashboard and analytics
- Error Tracking โ GlitchTip integration for crash reporting
- Custom RBAC โ Role-based access control
- SIEM Event Streaming โ Security audit event streams
- Teams & Sub-Groups โ Organization structure and role-based access
- Wishlists & Collections โ Custom lists and social sharing
- Database Backup & Disaster Recovery โ Backup scheduling, restore procedures, and storage configuration