- Created TODO files for Testing, DBAL, Frontend, Packages, Database, and Lua Scripting. - Updated README with a quick reference table for all TODO files and their priorities. - Added specific tasks for improving testing coverage, implementing DBAL features, enhancing frontend components, and refining package management. - Included documentation tasks to ensure thorough coverage and clarity across all areas. - Implemented initial unit tests for the useAuth hook and improved password generation logic. - Enhanced package loader functionality to support modular package seed data retrieval. - Updated page renderer to include public role in permission checks. - Added comments for future unit tests in workflow engine and other critical areas.
26 KiB
MetaBuilder Documentation Comprehensive Findings
Date: December 25, 2025
Scope: Complete review of all project documentation
Status: Initial comprehensive analysis
Table of Contents
- Project Overview
- Architecture & Design
- Technology Stack
- Completed Features
- Database Layer (DBAL)
- Component System
- Development Workflow
- Known Issues & Refactoring Needs
- Security Implementation
- Documentation Index
Project Overview
Mission Statement
MetaBuilder is a declarative, data-driven, multi-tenant application platform where 95% of functionality is defined through JSON and Lua, not TypeScript. The platform features a 5-level architecture with advanced meta-programming capabilities, functioning as a "platform for building platforms."
Complexity Classification
Complex Application with meta-programming capabilities. Levels 4-5 procedurally generate Levels 1-3 from pure data definitions stored in a modular seed system.
Core Philosophy
- Declarative First: Everything from pages to workflows defined as data
- Modular: Clear separation of concerns with isolated, maintainable modules
- Scalable: Architecture supports massive applications without unwieldy growth
- Procedural: UI and logic generated from configuration, not hardcoded files
Architecture & Design
5-Level Architecture
The platform implements a hierarchical level system with progressive access and capabilities:
| Level | Role | Purpose | Access | Key Features |
|---|---|---|---|---|
| L1 | Public | Landing page & login | All users | Public information, login interface |
| L2 | User | Dashboard & user tools | Authenticated users | Personal dashboard, user settings |
| L3 | Admin | Admin panel | Admin role users | System administration, user mgmt |
| L4 | God | Builder & IDE | God role users | Visual page builder, full code access |
| L5 | SuperGod | Multi-tenant management | SuperGod role | Tenant creation, power transfer, cross-level preview |
Multi-Tenant System
Complete multi-tenant support implemented with:
- Tenant Isolation: Namespace-based data separation for all resources
- Blob Storage: Multi-tenant file storage with access control and quotas
- Structured Data: User/page/KV/list data scoped to tenants
- Access Control: Role-based permissions (owner, admin, member, viewer)
- Storage Quotas: Limits on blob storage, record counts, data size, list length
- Components:
TenantIdentity: User identity within a tenantTenantQuota: Resource limits and usage trackingTenantContext: Context for all operationsTenantManager: Manages tenants, quotas, usage
Atomic Design Pattern
Components organized into three categories following atomic design principles:
Atoms (~12 components)
- Basic UI elements from shadcn/ui
- Buttons, inputs, labels, badges, avatars
- Stateless or minimal state
- Location:
src/components/atoms/
Molecules (~10 components)
- Groups of 2-5 atoms functioning together
- Simple composites with single purpose
- Examples: form fields, search bars, card headers
- Location:
src/components/molecules/
Organisms (~40+ components)
- Complex components forming distinct sections
- May contain business logic
- Examples: data tables, forms, editors, IDE
- Location:
src/components/organisms/
Pages/Levels (5 components)
- Top-level page components (remain at root)
- Level1 through Level5 components
- Location:
src/components/
Technology Stack
Frontend
- React 18+ with TypeScript
- Next.js framework (migration from Vite mentioned)
- Tailwind CSS for styling
- shadcn/ui for component library
- Phosphor Icons for icon system
- Monaco Editor for code editing
Styling System
- Font Families:
- IBM Plex Sans (body text)
- Space Grotesk (headings)
- JetBrains Mono (code)
- Color Space: oklch
- Theme: Purple/accent theme with customizable CSS classes
Backend/Database
- Prisma ORM for database abstraction
- SQLite for local development (switchable to PostgreSQL/MySQL)
- PostgreSQL/MySQL for production
Scripting & Logic
- Lua 5.1+ for business logic (via Fengari)
- Sandbox execution for security
- JSON schemas for data definitions
Tools & Infrastructure
- GitHub Actions for CI/CD
- Docker for containerization
- Playwright for E2E testing
- Vitest for unit testing
- ESLint for code quality
C++ Layer
- DBAL Daemon (future production layer)
- CMake build system
- Ninja build generator
Completed Features
Phase 1: Core Platform ✅
- Multi-tenant architecture
- 5-level access hierarchy
- Basic CRUD operations
- User authentication
- Role-based access control
Phase 2: Database Abstraction Layer (DBAL) ✅
Status: COMPLETE
Delivered Components:
-
Prisma Adapter (100% complete)
- CRUD operations
- Query timeout protection
- Flexible filtering/sorting
- Pagination support
- Error handling & mapping
- Capability detection
-
ACL Security Layer (100% complete)
- Role-based permissions (user/admin/god/supergod)
- Operation-level authorization
- Row-level security filters
- Comprehensive audit logging
- Pre-configured rules for all entities
-
WebSocket Bridge (100% complete)
- RPC protocol for future C++ daemon
- Request/response tracking
- Timeout handling
- Auto-reconnection logic
- Ready for Phase 3
-
DBAL Client (100% complete)
- Mode switching (development/production)
- Adapter selection
- Type-safe APIs
- Resource management
-
Integration Layer (100% complete)
- Helper functions
- Authentication context
- Configuration defaults
- Migration utilities
Super God Level (Level 5) - PARTIAL ✅/🔄
Completed:
- ✅ Multi-tenant management
- ✅ Tenant creation/deletion
- ✅ God user management interface
- ✅ Tenant-specific configurations
Status: In Development:
- 🔄 Power transfer system (one-way supergod privilege transfer)
- 🔄 Cross-level preview (preview L1-L4 from L5)
- 🔄 Credentials display system
Package System - PARTIAL 🔄
Completed:
- ✅ Package data models
- ✅ Install/uninstall operations
- ✅ Seed data support
In Development:
- 🔄 Docker-style package browser
- 🔄 Full import/export functionality
- 🔄 Asset support (images, videos, audio, documents)
- 🔄 Pre-built packages (Forum, Guestbook, Video, Music, Games, E-Commerce)
Declarative Component System - PARTIAL 🔄
Completed:
- ✅ IRC Webchat (IRC) in declarative format
- ✅ JSON configuration support
- ✅ Lua script integration
In Development:
- 🔄 Full IRC component implementation
- 🔄 Generic component renderer
- 🔄 More components as declarative
Nerd Mode IDE - PARTIAL 🔄
Framework:
- ✅ Monaco editor integration
- ✅ File navigation
In Development:
- 🔄 Virtual file tree
- 🔄 GitHub/GitLab integration
- 🔄 Test runner
- 🔄 Debugging console
Docker-Style Package System - PLANNED 📋
6+ pre-built packages planned for implementation:
- Forum package
- Guestbook package
- Video platform package
- Music streaming package
- Games arcade package
- E-Commerce platform package
Features:
- Browse, filter, install packages
- One-click installation
- Automatic schema/page/workflow inclusion
- Enable/disable without uninstalling
- Separate package data storage
Database Layer (DBAL)
Architecture
┌─────────────────────────────────────────┐
│ MetaBuilder Application (React/TS) │
└────────────────┬────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ DBAL Client (Mode: dev/prod) │
└────────────────┬────────────────────────┘
│
┌────────────┴────────────┐
│ (development) │ (production)
▼ ▼
┌──────────────┐ ┌──────────────┐
│ ACL Adapter │ │ WebSocket │
│ (Security) │ │ Bridge (RPC) │
└────┬─────────┘ └──────┬───────┘
│ │
▼ │
┌──────────────┐ │
│ Prisma │ │
│ Adapter │ │
└────┬─────────┘ │
│ ▼
│ ┌──────────────────┐
│ │ C++ DBAL Daemon │
│ │ (Production) │
│ └────┬─────────────┘
│ │
└───────┬───────────┘
▼
┌──────────────┐
│ Prisma │
│ SQLite/Postgres
└──────────────┘
Design Principles
- Language Agnostic: API contracts defined in YAML
- Security First: C++ daemon sandboxes database access
- Development Speed: TypeScript for rapid iteration
- Zero Trust: User code never touches DB credentials
- Capability-based: Adapters declare support (transactions, joins, etc.)
- Testable: Shared test vectors ensure behavioral consistency
Repository Structure
dbal/
├── api/ # Language-agnostic contracts (YAML)
│ ├── schema/ # Entity and operation definitions
│ ├── idl/ # Proto/FlatBuffers schemas (optional)
│ └── versioning/ # Compatibility rules
├── common/ # Shared test vectors and fixtures
├── ts/ # TypeScript implementation (dev)
│ ├── src/
│ │ ├── adapters/ # Backend adapters (Prisma, SQLite)
│ │ ├── core/ # Core abstractions
│ │ ├── query/ # Query builder
│ │ └── runtime/ # Config and telemetry
│ └── tests/
├── cpp/ # C++ implementation (production)
├── backends/ # Backend-specific assets (Prisma, SQLite)
├── tools/ # Code generation and build tools
└── scripts/ # Cross-platform build scripts
Phase 2 Metrics
- Development Time: Complete and deployed
- Overhead: ~0.5-1ms per operation
- Lines of Code: ~2000 LOC TypeScript, ready for C++ port
- Test Coverage: 80%+ of critical paths
- Security Level: Production-ready ACL and audit logging
Phase 3 Roadmap (Future)
C++ daemon implementation with:
- Process isolation and sandboxing
- Credential protection
- Query validation and sanitization
- Row-level security enforcement
- Resource limits and quotas
- Docker and Kubernetes deployment options
Component System
Current Component Organization
Atoms (Basic UI)
All from shadcn/ui, re-exported via @/components/atoms:
- Button, Input, Label, Badge, Avatar, Separator
- Skeleton, Switch, Slider, Progress, Checkbox, RadioGroup
- And more generic UI primitives
Molecules (Simple Composites)
- AppHeader, AppFooter
- GodCredentialsBanner
- ProfileCard
- SecurityWarningDialog, PasswordChangeDialog
Organisms (Complex Features)
Core Builders:
- Builder, Canvas, ComponentCatalog
- ComponentConfigDialog, ComponentHierarchyEditor
- PropertyInspector
Schema & Data Management:
- SchemaEditor, DatabaseManager
- FieldRenderer, RecordForm, ModelListView
Code Editors:
- CodeEditor, JsonEditor
- LuaEditor, LuaSnippetLibrary
- NerdModeIDE
Configuration:
- CssClassBuilder, CssClassManager
- DropdownConfigManager, ThemeEditor
- SMTPConfigEditor
UI Features:
- IRCWebchat, IRCWebchatDeclarative
- WorkflowEditor, PageRoutesManager
- GodCredentialsSettings, ScreenshotAnalyzer
- GitHubActionsFetcher, AuditLogViewer
Component Size Violations
Critical Violations (Exceed 150 LOC):
| Component | Current | Target | Reduction |
|---|---|---|---|
| GitHubActionsFetcher | 887 LOC | 95 LOC | 89% ↓ |
| NerdModeIDE | 733 LOC | 110 LOC | 85% ↓ |
| LuaEditor | 686 LOC | 120 LOC | 82% ↓ |
| SchemaEditor | 520 LOC | 100 LOC | 80% ↓ |
| ComponentConfigDialog | 450 LOC | 90 LOC | 80% ↓ |
| PropertyInspector | 380 LOC | 85 LOC | 77% ↓ |
| IRCWebchat | 290 LOC | 85 LOC | 70% ↓ |
| AuditLogViewer | 210 LOC | 70 LOC | 66% ↓ |
Total Violations: 8 components, 4,146 LOC over limits
Code Organization Issues
- Components often contain multiple responsibilities
- State management scattered across multiple useState hooks
- Business logic mixed with UI rendering
- Hardcoded configurations in components
- Limited reusability across contexts
Development Workflow
Available Scripts
# Development
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
# Code Quality
npm run lint # Run ESLint
npm run lint:fix # Auto-fix linting issues
# Testing
npm run test # Run tests in watch mode
npm run test:unit # Run unit tests once
npm run test:unit:ui # UI test runner
npm run test:unit:coverage # Coverage report
npm run test:e2e # Playwright E2E tests
npm run test:e2e:ui # E2E UI runner
npm run test:e2e:headed # E2E in headed mode
npm run test:all # All tests (unit + e2e)
# Database
npm run db:generate # Generate Prisma client
npm run db:push # Apply schema to database
npm run db:migrate # Apply migrations (CI/prod)
# GitHub Actions (Local Testing)
npm run act # Run workflows locally
npm run act:lint # Test lint job
npm run act:e2e # Test e2e job
# C++ Build
npm run cpp:check # Check build dependencies
npm run cpp:full # Complete build workflow
npm run cpp:build # Build with Ninja
npm run cpp:test # Run C++ tests
npm run cpp:clean # Clean build artifacts
Testing Approach
- Unit Tests: Vitest with UI runner
- E2E Tests: Playwright with multiple browsers
- Local CI/CD: Act for testing GitHub Actions locally
- Coverage: Target 80%+ for critical paths
- Performance: Size limit enforcement
Database Migration Path
- Generate Prisma client:
npm run db:generate - Apply schema:
npm run db:push - Run migrations:
npm run db:migrate(CI/production)
Seed Data System
- Located in
/src/seed-data/and package directories - Loaded at application initialization
- Package-based organization for modularity
- Supports multi-tenant data initialization
Known Issues & Refactoring Needs
High Priority
1. Component Size Violations
- 8 components exceed 150 LOC architectural limit
- 4,146 total LOC over limits
- Action: Systematic refactoring with decomposition strategy
- Timeline: 3 weeks, ~103 hours
- Impact: Improved modularity, testability, maintainability
2. State Management Scatter
- Business logic scattered across multiple useState hooks
- Duplicated state management patterns
- Action: Extract to custom hooks and database persistence
- Pattern: One hook per major feature
3. Ephemeral State vs Persistent Data
- Component state lost on page reload
- Should be database-persisted for:
- Editor content (LuaEditor, CodeEditor, SchemaEditor)
- Workflow configurations
- GitHub Actions cache
- Action: Implement Prisma models for persistent storage
4. Hardcoded Configurations
- Colors, column definitions, UI configs in components
- Action: Move to JSON in database or seed files
- Benefit: Runtime changes without code deployment
Medium Priority
5. GitHub Actions Integration Complexity
- GitHubActionsFetcher: 887 LOC with multiple responsibilities
- Components: API fetching, polling, log aggregation, AI analysis
- Refactoring Strategy:
- Create custom hook:
useGitHubActions()(~50 LOC) - Separate components for tabs/views (~65-85 LOC each)
- Extract log aggregation to Lua script
- Move analysis cache to Prisma model
- Create custom hook:
6. IDE Implementation Incomplete
- NerdModeIDE: 733 LOC, partial implementation
- Missing: File tree, Git integration, test runner, debugging
- Strategy: Componentize into smaller focused modules
7. Lua Editor Missing Features
- LuaEditor: 686 LOC, lacks snippet system integration
- No persistent script storage
- Action: Create LuaSnippetLibrary organism, database models
Low Priority
8. Package System Incomplete
- Pre-built packages not implemented
- Import/export needs UI polish
- Asset handling incomplete
Security Implementation
Multi-Layer Security Architecture
Layer 1: ACL (Access Control Layer)
- Role-based permissions: user, admin, god, supergod
- Operation-level authorization: create, read, update, delete, list
- Row-level security: Users can only access their own data
- Configuration: Pre-configured rules for all entities
Layer 2: Audit Logging
- Event Logging: All operations logged with:
- User context and timestamp
- Operation type and entity
- Input parameters (sensitive data excluded)
- Success/failure status
- Error messages
- Compliance: Audit trail for compliance requirements
Layer 3: Credential Security
- SHA-512 Hashing: All passwords stored as salted hashes
- Never Plaintext: Credentials never logged or transmitted
- Token-based Sessions: Secure session tokens for API access
Layer 4: Input Validation
- Prisma: Parameterized queries prevent SQL injection
- Schema Validation: JSON schemas enforce data types
- Lua Sandboxing: Lua scripts execute in sandboxed environment
Layer 5: Error Handling
- Safe Failures: Comprehensive error types
- User-Friendly: Error messages don't expose internals
- Logging: Errors logged for debugging
Security Policies
Password Requirements
- Minimum length enforced
- Hash comparison protected from timing attacks
- Reset tokens with expiration
Multi-Tenant Isolation
- Automatic namespace scoping
- Permission checks on all operations
- Quota enforcement per tenant
Blob Storage Security
- Namespace-based isolation
- Virtual root directories for path sandboxing
- Size limits and file count limits
Future Protections (Phase 3 - C++ Daemon)
- Process isolation
- User code never sees database credentials
- Query validation and sanitization
- Resource limits and quotas
Documentation Index
Core Documentation
TODO: Core doc links below point to docs/reference; update to correct paths under docs/ (README, PRD, SECURITY).
| File | Purpose |
|---|---|
| INDEX.md | Navigation hub for all documentation |
| README.md | Project overview and quick start |
| PRD.md | Product requirements and features (599 lines) |
| SECURITY.md | Security policies and best practices |
Implementation Guides
| File | Purpose |
|---|---|
| implementation/ATOMIC_DESIGN.md | Component organization principles |
| implementation/MULTI_TENANT_SYSTEM.md | Multi-tenancy architecture (446 lines) |
| implementation/PRISMA_IMPLEMENTATION_COMPLETE.md | Database layer implementation |
| implementation/COMPONENT_MAP.md | Complete component classification |
| implementation/DBAL_INTEGRATION.md | DBAL integration guide |
Refactoring & Strategy
| File | Purpose |
|---|---|
| REFACTORING_STRATEGY.md | Comprehensive refactoring plan (858 lines) |
| REFACTORING_QUICK_REFERENCE.md | Quick refactoring guide (485 lines) |
| REFACTORING_CHECKLIST.md | Refactoring task checklist |
Database & DBAL
| File | Purpose |
|---|---|
| dbal/README.md | DBAL architecture and overview |
| dbal/QUICK_START.md | DBAL 5-minute quick start |
| dbal/PROJECT.md | DBAL project structure |
| dbal/IMPLEMENTATION_SUMMARY.md | Phase 2 DBAL implementation summary |
| dbal/AGENTS.md | Agent development guide for DBAL |
| dbal/PHASE2_COMPLETE.md | Phase 2 completion status |
Development Guides
| Directory | Contents |
|---|---|
| guides/ | Quick references and setup instructions |
| builds/ | C++ build and cross-platform compilation |
| deployments/ | Docker, CI/CD, Nginx integration |
| troubleshooting/ | Debugging guides and diagnostics |
| migrations/ | Data migrations and refactoring |
Archive & Reference
| Directory | Contents |
|---|---|
| archive/ | Completed phases and historical work |
| reference/ | API references and technical specs |
| database/ | Database design and schemas |
| lua/ | Lua scripting documentation |
| packages/ | Package system documentation |
Key Integration Points
1. DBAL Integration with MetaBuilder
Import pattern:
import { getDBALClient } from '@/lib/dbal-client'
const client = getDBALClient(currentUser, session)
Usage:
// CRUD operations
const user = await client.users.create({ ... })
const users = await client.users.list({ filter: {...} })
await client.users.update(id, {...})
await client.users.delete(id)
2. Component Registration System
Components registered in package catalog with:
- JSON configuration
- Lua scripts for behavior
- Property schema definitions
- UI layout definitions
3. Workflow Engine
Workflows stored as JSON with:
- Node definitions
- Edge connections
- Lua script integration
- Execution context
4. Package System
Each package contains:
- Seed data directory
- Components (JSON + Lua)
- Scripts and utilities
- Static content (assets)
- Manifest with metadata
Summary of Key Findings
Strengths ✅
- Well-Architected Foundation: 5-level hierarchy is clean and scalable
- Comprehensive Documentation: Extensive guides and implementation docs
- Modern Tech Stack: React, TypeScript, Tailwind, Prisma, Lua integration
- Security-First Design: Multi-layer ACL, audit logging, sandboxing
- DBAL Complete: Phase 2 production-ready database abstraction layer
- Multi-Tenant Ready: Full tenant isolation and quota management
- Atomic Design: Good component organization principles
Areas for Improvement 🔄
- Component Size Violations: 8 components exceed 150 LOC (4,146 LOC over limits)
- State Management: Logic scattered across multiple useState hooks
- Data Persistence: Editor content and configurations should be persistent
- Configuration Hardcoding: UI configs should be data-driven
- Feature Completeness: Package system and IDE incomplete
- Documentation Fragmentation: Many separate docs could be consolidated
Immediate Action Items 📋
- High Priority: Refactor components to meet 150 LOC limit
- High Priority: Implement persistent storage for editor content
- Medium Priority: Complete package system implementation
- Medium Priority: Finish IDE and nerd mode features
- Low Priority: Consolidate documentation
- Low Priority: Add more pre-built packages
Recommendations 💡
- Follow Refactoring Strategy: Use the documented 3-week plan for component refactoring
- Leverage DBAL: Fully utilize database abstraction for persistent storage
- Implement Hooks Pattern: Extract business logic into reusable custom hooks
- Data-Driven UI: Move hardcoded configs to JSON/Lua
- Package First: Build new features as packages for reusability
- Test Early: Use Vitest and Playwright for comprehensive coverage
Documentation Quality Assessment
Comprehensive ✅
- All major systems documented
- Multiple views (overview, quick start, deep dive)
- Examples provided
Well-Organized ✅
- Clear hierarchy with INDEX.md
- Consistent formatting
- Cross-references between docs
Actionable ✅
- Quick start guides
- Step-by-step instructions
- Code examples
Areas for Enhancement 🔄
- Some documents are very long (858 LOC refactoring strategy)
- Could benefit from visual diagrams (some ASCII provided)
- Some duplication between quick reference and full guides
Conclusion
MetaBuilder is a well-architected, extensively documented platform with solid foundations in place. The DBAL Phase 2 is production-ready, multi-tenant support is comprehensive, and the component system follows atomic design principles.
The primary focus areas should be:
- Resolving component size violations through systematic refactoring
- Implementing persistent storage for editor and configuration data
- Completing the package system for extensibility
- Finishing IDE features for the nerd mode interface
The project is well-positioned for continued development with clear roadmaps, comprehensive documentation, and a solid technical foundation.
End of Findings Report
Generated from manual review of all documentation
Total Documentation Reviewed: 40+ files, ~4,000 lines of documentation