Grouped 100+ docs into categories: - architecture/ - System design, DBAL, component architecture - analysis/ - Status reports, assessments, migration analysis - guides/ - Quick references, how-tos, integration guides - implementation/ - Implementation details, migration guides - packages/ - Package-specific docs (forum, notifications, etc) - phases/ - Phase completion summaries and deliverables - testing/ - E2E tests, Playwright, test architecture - workflow/ - Workflow engine documentation Root level retains: README, ROADMAP, AGENTS, CONTRACT, CLAUDE, PROMPT Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
10 KiB
Tech Debt Tracker
For AI Assistants: This file explicitly defines what needs to be done for each tech debt item. Read the "Bot Instructions" section for each task to understand exactly what's required.
Current Status: Phase 2 - 90% Complete. 3 critical items blocking Phase 3.
📋 Phase 2 Tech Debt (Priority Order)
TD-1: DBAL Refactoring - Move Database Logic from Frontend to DBAL
Status: 🔴 CRITICAL - Blocks Phase 3 start
Problem: Database logic is scattered:
- Prisma schema at
/prisma/schema.prisma(should be in DBAL) - Adapter factory at
/frontends/nextjs/src/lib/dbal-client/adapter/get-adapter.ts(duplicate code) - Prisma context at
/frontends/nextjs/src/lib/config/prisma.ts(should be in DBAL) - Seeding split between
/seed/,/frontends/nextjs/src/lib/seed/, and code (should be in DBAL) - Frontend uses raw adapter instead of entity operations
Impact: DBAL can't be versioned/deployed independently, code duplication, poor separation of concerns
Reference Documents:
/DBAL_REFACTOR_PLAN.md- Architectural overview/TD_1_REFACTORING_GUIDE.md- ⭐ Step-by-step execution guide with exact refactoring patterns/TD_1_BLOCKER.md- Workspace dependency setup (RESOLVED - see status)/DBAL_BUILD_ISSUES.md- Pre-existing DBAL build errors blocking progress
Bot Instructions:
Phase 1 (DBAL Foundation) - Already Done ✅
- ✅ Prisma schema moved to
/dbal/development/prisma/schema.prisma - ✅ DBAL owns all Prisma initialization
- ✅ DBAL exports
getDBALClient(),seedDatabase(),getPrismaClient()
Phase 1.5 (Workspace Setup) - COMPLETE ✅
- ✅ Added dbal/development to root package.json workspaces
- ✅ Added @metabuilder/dbal dependency to frontend
- ✅ Updated TypeScript paths for @/dbal resolution
- ⚠️ NEW BLOCKER: DBAL has pre-existing build errors
- Missing
types.generated.tsfile - CodeGen script failing
- TypeScript type strictness errors
- See
/DBAL_BUILD_ISSUES.mdfor details and fix options
- Missing
Phase 2 (Frontend Cleanup) - BLOCKED by DBAL build
- WAITING: DBAL TypeScript compilation must succeed first
- Once DBAL builds to dist/, then proceed:
- Read
/TD_1_REFACTORING_GUIDE.md- Exact refactoring patterns for 100+ files - Follow refactoring approach of choice (A: Automated, B: Manual, C: Git-based)
- Refactor 14 Prisma imports → use
dbfrom/lib/db-client.ts - Refactor 110+ getAdapter() calls → use
db.entity.list()pattern - Delete old modules:
/lib/dbal-client/,/lib/database-dbal/,/lib/config/prisma.ts - Verify with checklist in
/TD_1_REFACTORING_GUIDE.md
- Read
Phase 3 (Build System) - Simple configuration updates
- Update DBAL package.json (if needed)
- Update TypeScript paths (if needed)
- Update root package.json (if needed)
Expected Outcome:
- ✅ Prisma schema moved to
/dbal/development/prisma/schema.prisma - ✅ DBAL owns all Prisma initialization
- ✅ DBAL exports
getDBALClient(),seedDatabase(),getPrismaClient() - ✅ Frontend has single
/frontends/nextjs/src/lib/db-client.tsintegration point - ✅ All frontend code uses
db.users.list()pattern, notadapter.list('User') - ✅ Tests pass with new structure
- ✅ Old code deleted (
dbal-client/,database-dbal/,config/prisma.ts)
TD-2: Rate Limiting for API Endpoints
Status: 🟡 HIGH - Needed for production
Problem: No rate limiting on /api/* endpoints. Bots can enumerate users, brute force, or DoS.
Impact: Security vulnerability. Production deployment blocked until implemented.
Bot Instructions:
- Research rate limiting options for Next.js (e.g.,
next-rate-limit,redis-based,in-memory) - Evaluate against requirements:
- Per-IP limiting (not per-user, since public endpoints)
- Configurable limits by endpoint
- Works in development (SQLite) and production (Redis)
- Graceful failure if Redis unavailable
- Implement in
/api/middleware.tsor route handler - Add tests in
e2e/rate-limiting.spec.ts - Document in
/docs/API_RATE_LIMITING.md - Update
/ROADMAP.mdto mark as complete
Expected Outcome:
- ✅
GET /api/userslimited to 100 req/min per IP - ✅
POST /api/users/loginlimited to 5 req/min per IP - ✅ Exceeding limit returns 429 status
- ✅ Tests verify both pass and rate-limited scenarios
TD-3: OpenAPI/Swagger API Documentation
Status: 🟡 HIGH - Needed for frontend/API clarity
Problem: No API specification. Frontend developers must read code to understand endpoints.
Impact: Slow development, inconsistency, hard to maintain.
Bot Instructions:
-
Choose OpenAPI generator:
- Option A:
@ts-rest/open-api(lightweight, TypeScript-first) - Option B:
swagger-jsdoc(JSDoc-based, intrusive) - Option C: Manual YAML at
/openapi.yamlRecommendation: Option A for tight TypeScript integration
- Option A:
-
Generate OpenAPI 3.0 spec from route handlers:
- Document all GET, POST, PUT, DELETE endpoints in
/api/* - Include request/response schemas
- Document authentication requirements
- Mark deprecated endpoints
- Document all GET, POST, PUT, DELETE endpoints in
-
Serve Swagger UI at
/api/docs -
Verify spec in
/openapi.yaml(at root, version-controlled) -
Add tests to verify:
- All routes documented
- Schemas match actual request/response types
- No breaking changes without major version bump
-
Update AGENTS.md "API Documentation" section with usage
Expected Outcome:
- ✅
/api/docsshows interactive Swagger UI - ✅
/openapi.yamlexists with complete spec - ✅ All endpoints documented with examples
- ✅ Request/response types auto-generated from TypeScript
- ✅ Frontend can generate client SDK from spec
TD-4: Error Handling Documentation
Status: 🟡 MEDIUM - Improves developer experience
Problem: No centralized docs on error handling patterns. Developers guess.
Impact: Inconsistent error responses, hard to debug, poor API contracts.
Bot Instructions:
-
Create
/docs/ERROR_HANDLING.md:- Document error response format (should be consistent)
- List all possible HTTP status codes used
- Explain retry logic for each error type
- Show examples of client-side handling
-
Audit all
/api/*endpoints:- Ensure consistent error response format
- Use correct HTTP status codes (400, 401, 403, 404, 409, 500, etc.)
- All errors should have
code,message,detailsfields (if applicable)
-
Add error handling test suite (
e2e/error-handling.spec.ts):- Test 404 on missing resource
- Test 401 on unauthorized access
- Test 400 on invalid input
- Test 500 on server error
-
Document in AGENTS.md under "Error Handling" section
Expected Outcome:
- ✅
/docs/ERROR_HANDLING.mdexists with patterns - ✅ All errors follow consistent JSON format
- ✅ Tests verify error scenarios
- ✅ Developers know how to handle errors in frontend
📊 Phase 3+ Tech Debt (Future)
These are planned but blocked until Phase 2 completes:
TD-5: Rich Form Editors with Nested Object/Array Support
- Implement dynamic form builder
- Support nested objects, arrays, conditional fields
- Use JSON Schema for validation
- Add e2e tests
TD-6: Bulk Operations (Multi-Select, Bulk Delete, Export)
- Add bulk delete endpoint
/api/[entity]/bulk-delete - Add bulk export endpoint
/api/[entity]/export - Implement multi-select UI in generic table renderer
- Add tests for bulk operations
TD-7: Advanced Filtering UI with Visual Builder
- Create visual filter builder component
- Support multiple conditions (AND/OR)
- Persist filters in URL/localStorage
- Add tests
TD-8: Relationship/Foreign Key Dropdown Selectors
- Auto-generate dropdowns for foreign keys
- Support search/autocomplete for large datasets
- Lazy-load options on demand
- Add tests
TD-9: God Panel (System Admin Dashboard)
- Create
/adminpage (requires God role) - Dashboard showing system stats
- User management UI
- Tenant management UI
- Job monitoring
- Error tracking
TD-10: Workflow Automation UI
- Visual workflow builder
- Trigger selection (API, schedule, manual)
- Action selection (email, webhook, database)
- Condition logic
- Tests
TD-11: Advanced Authentication (SSO, SAML, OAuth)
- Implement OAuth2 flow
- Add SAML support
- Add SSO configuration
- Tests
TD-12: C++ DBAL Daemon (Production Security Mode)
- See
/dbal/production/docs/PHASE3_DAEMON.md - Requires Phase 2 complete
TD-13: Multi-Source Package System (NPM, Git, HTTP)
- Load packages from NPM registry
- Load packages from Git repositories
- Load packages from HTTP endpoints
- Verify package signatures
- Tests
✅ Completed Tech Debt (Phase 0 & 1)
- ✅ Core architecture (Next.js, Prisma, DBAL, Multi-tenant)
- ✅ Authentication & authorization
- ✅ CRUD operations
- ✅ Package system (52 packages)
- ✅ Generic component renderer
- ✅ Infrastructure (Docker, PostgreSQL, Redis, Nginx)
- ✅ Test suite (464 tests)
- ✅ AGENTS.md expanded to cover whole project
- ✅ CLAUDE.md synced with AGENTS.md
- ✅ ROADMAP.md restructured for clarity
🎯 How Bots Should Use This File
Start here when assigned tech debt work:
- Find the task ID (TD-1, TD-2, etc.)
- Read the "Bot Instructions" section
- Follow each step exactly as written
- Check off each step as completed
- Verify against any listed "Expected Outcome"
- Commit with message:
chore: Complete TD-X [task name]
For sequential work:
- Phase 2 tasks (TD-1, TD-2, TD-3, TD-4) must complete in order
- Phase 3+ tasks (TD-5+) are independent but require Phase 2 complete
Questions?
- If instructions are ambiguous, ask user before starting
- If you get stuck, check
/CLAUDE.mdfor architectural context - If you need implementation details, check the reference documents
📝 Adding New Tech Debt
When adding new tech debt items:
- Use next available ID (TD-14, TD-15, etc.)
- Include: Status, Problem, Impact, Bot Instructions
- Link to reference documents where applicable
- Add to "Phase X Tech Debt" section with correct priority
- Update this file in git with clear commit message