AI-Powered Enterprise PHP Code Generation System
Django platform that learns Royal ERP PHP conventions from uploaded codebases and generates deployment-ready modules with validation and ZIP packaging.
Overview
Royal ERP AI Code Generator indexes legacy PHP ERP codebases, retrieves convention-matched context, parses natural-language requirements, and orchestrates generators for forms, JS handlers, SQL, menus, and installers — then validates and packages the module.
Problem
Hand-writing Royal ERP modules that match house conventions (helpers, vouchers, grids, permissions) is slow and error-prone across a large legacy PHP codebase.
Business challenge
Generate production-ready ERP modules grounded in 1,400+ real company files without modernizing away from legacy ERP patterns.
Solution
Secure ZIP upload → PHP knowledge extraction + vector index → NL requirements → GenerationOrchestrator → ERP validators + optional php -l → downloadable package with feedback capture.
Architecture
Upload → PHP parser / knowledge extract → embed & retrieve similar modules → requirements parse → generators (PHP, functionsJS, SQL, menus, docs) → ERPValidator + static checks → ZIP package.
Implementation
Django 5 + DRF services for analyzer, indexer (VoyageAI or offline embeddings), Anthropic-optional generation with deterministic fallbacks, SSE progress, REST APIs, and Django admin/developer UI.
Challenges
Preserving legacy ERP style while using modern Python orchestration; keeping generation usable offline without API keys.
How we solved them
Deterministic fallbacks for embeddings and generation; Royal-specific validators; optional Anthropic/Voyage when configured.
Security
Path-traversal and symlink protection on ZIP upload, skip rules, authenticated developer access, and validation gates before packaging.
Results
Production code-generation workflow that cuts manual ERP module effort and matches existing conventions at high similarity.
Key modules
- Upload & extractor
- PHP analyzer / knowledge extractor
- Vector indexer & search
- GenerationOrchestrator
- ERPValidator & packaging
Features
- Secure ERP ZIP upload with inventory and module discovery
- Convention-aware PHP parsing and knowledge index
- NL requirements → orchestrated multi-file generation
- PHP forms, functionsJS, SQL schema, menus, installer, docs
- Royal ERP validators + optional PHP lint
- SSE progress, feedback loop, and ZIP download
My responsibilities
- Built end-to-end generation pipeline and orchestrator
- Implemented ERP-specific parsers and validators
- Added indexing, retrieval, and packaging flows
Outcomes
- Grounded on 1,400+ company ERP files
- 70–90% similarity with real codebase conventions
- 60%+ reduction in manual module development effort
Related projects
Intelligent ERP Chatbot — Multi-Agent System
Production multi-tenant ERP chatbot answering natural-language business questions against live MySQL with SQL tools, forecasting, Plotly dashboards, and client isolation.
Codebase-Aware Prompt Engine (n8n + MySQL)
n8n + MySQL prompt engine that seeds ERP codebase excerpts and generates codebase-aware multi-task batch prompts with TMS mapping.
