# πŸš€ MEGA PROMPT: Hybrid TypeScript/C++ Package System **Version**: 1.0 **Last Updated**: January 2026 **For**: AI Assistants working on 3-frontend package bootstrap system --- ## 🎯 PROJECT ESSENCE This is a **hybrid TypeScript/C++ bootloader system** that powers a modular package architecture. Three frontends (CLI, Qt6, Next.js) act as **entry points** that bootstrap a NestJS-based package system. The system is pragmatic: schemas are improvable, not sacred; patterns come from functional programming; and delightfulness matters. ### The Mental Model ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ User Input β”‚ β”‚ (CLI / Qt6 GUI / Next.js Web) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Bootloader β”‚ ← Frontend-specific logic β”‚ (3x) β”‚ - Routes/state management β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Package β”‚ ← Central coordinator β”‚ System β”‚ - Loads packages from /packages/ β”‚ (NestJS) β”‚ - Manages seed data & schemas β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β” β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DBAL β”‚ β”‚ C++ β”‚ β”‚ Layer β”‚ β”‚ Daemonsβ”‚ β”‚ β”‚ β”‚(Media) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Database β”‚ β”‚(PostgreSQL) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` **Key Principle**: Seed data lives in `/packages/*/seed/`, not scattered elsewhere. Schemas are single source of truth but improvable. --- ## πŸ“‹ PRIORITY READING (In Order) 1. **IMMEDIATE_FIXES.md** ⭐ - What's actually broken right now 2. **claude.md** - System overview and patterns 3. **agents.md** - Agent guidelines for this codebase 4. **README.md** - Project structure and setup 5. **ROADMAP.md** (if exists) - Vision and evolution 6. **docs/** - Architecture, testing, deployment guides 7. **schemas/** - Data models (understand but improve if needed) --- ## πŸ—οΈ ARCHITECTURE AT A GLANCE ### Three Frontends (Each a Bootloader) | Frontend | Purpose | Tech Stack | Startup Flow | |----------|---------|-----------|--------------| | **CLI** | Command-line interface | TypeScript/Node | Read config β†’ Load packages β†’ Execute | | **Qt6** | Desktop GUI application | C++/Qt6 | Parse Qt resources β†’ Load packages β†’ Render | | **Next.js** | Web application | TypeScript/React | HTTP request β†’ Load packages β†’ Render page | **Critical**: Each frontend is a **bootloader**. It doesn't contain business logicβ€”it loads and orchestrates packages. ### Package System (The Heart) ``` /packages/ β”œβ”€β”€ [package-name]/ β”‚ β”œβ”€β”€ seed/ ← REAL seed data (not /dbal/shared/seeds/) β”‚ β”‚ β”œβ”€β”€ metadata.json ← Package manifest β”‚ β”‚ β”œβ”€β”€ page-config/ ← Routes/pages β”‚ β”‚ β”œβ”€β”€ workflow/ ← Automation workflows β”‚ β”‚ β”œβ”€β”€ credential/ ← API credentials β”‚ β”‚ β”œβ”€β”€ component/ ← UI components β”‚ β”‚ └── [entity-type]/ ← Other entity types β”‚ β”œβ”€β”€ src/ ← Business logic (if TypeScript package) β”‚ β”œβ”€β”€ package.json β”‚ └── README.md ``` **Pattern**: Each package is self-contained. Seed data describes what the package does. Business logic implements it. ### DBAL Layer (Database Access) - **Phase 2** (Current): TypeScript DBAL in `/dbal/development/` - **Phase 3** (Future): C++ daemon in `/dbal/production/` - **Shared**: YAML schemas at `/dbal/shared/api/schema/entities/` (source of truth) **Rule**: Always use `getDBALClient()` from `@/dbal`, never raw Prisma. ### Schemas: Two Layers | Layer | Location | Purpose | Editable? | |-------|----------|---------|-----------| | **Entity Schemas** | `/dbal/shared/api/schema/entities/*.yaml` | Database structure (source of truth) | Yes, improve as needed | | **Validation Schemas** | `/schemas/seed-data/*.schema.json` | Seed data validation | Yes, extend for new features | | **Package Schemas** | `/schemas/package-schemas/*.schema.json` | Package system architecture | Yes, treat as blueprint | **Philosophy**: Schemas are **improvable**. If they lack features, extend them. They're not dogma. --- ## 🎨 DESIGN PHILOSOPHY (How to Think) ### 1. Functional Programming First ```typescript // βœ… GOOD: Functional, pure, composable const loadPackage = (path: string) => readJSON(path); const filterActive = (packages: Package[]) => packages.filter(p => p.active); const orchestrate = pipe(loadPackages, filterActive, initializeAll); // ❌ BAD: Imperative, class-heavy, side effects class PackageManager { private packages: Package[] = []; async load(path) { this.packages = await readJSON(path); } async filter() { this.packages = this.packages.filter(p => p.active); } } ``` ### 2. Make It Delightful - Code should be obvious. If it requires 20 comments, refactor it. - Styling matters. Use Tailwind (web), Qt stylesheets (desktop), ANSI colors (CLI). - Error messages should hint at solutions, not just fail. - Performance should feel snappy. ### 3. Schemas Are Improvable ```json // If schema lacks what you need: // 1. Document the gap // 2. Extend the schema // 3. Update examples // 4. Move on // Example: Script schema is JSON AST, but n8n-style is simpler for visual GUIs { "trigger": "http.post", "input": { "body": "{ name, email }" }, "steps": [ { "action": "validate.email", "target": "$input.email" }, { "action": "db.create", "table": "users", "data": "$input" } ], "output": { "userId": "$steps[1].id" } } // This coexists with JSON AST for complex logic. Both are valid. ``` ### 4. No Magic, No Lua - **No Lua**: JSON is sufficient for visual scripting (n8n, Scratch patterns). - **No magic imports**: Be explicit. Use dependency injection. - **No hidden state**: Logs should explain what's happening. ### 5. GUIs Over Raw Input ```typescript // ❌ RAW: User types CSS directly