Uploaded October 2026 | Updated November 2026, 2 hours ago
In this episode of AI Coding with Dr. Chuck, I work with Cursor to refactor the administrative console in Tsugi, moving a collection of legacy PHP scripts toward a more structured controller-based architecture.
The Tsugi admin interface has grown organically over more than a decade. While functional, much of the code was written as standalone PHP pages rather than following the controller and service patterns used elsewhere in the application.
We explore how to reorganize the administration code into a hierarchy of smaller controllers, preserve existing behavior, move presentation code into templates, and extract shared utility functions into an admin service.
Topics include:
- Refactoring legacy PHP into controllers and routes
- Organizing administration features into smaller subcontrollers
- Separating controllers, templates, and services
- Preserving existing administrator authentication
- Preparing the architecture for future tenant and organization administrators
- Using Cursor AI to perform large-scale code restructuring
- Reviewing generated code and identifying remaining technical debt
This is an incremental refactoring session rather than a complete rewrite. The goal is to improve the structure of Tsugi while keeping the existing administrative console working.
Tsugi: tsugi.org
Python for Everybody: py4e.com
In January 2027, I'll be teaching Python for Everybody with AI. Visit py4e.com for more information.
#Tsugi #PHP #CursorAI #SoftwareEngineering #Refactoring #AICoding
In this episode of AI Coding with Dr. Chuck, I work with Cursor to refactor the administrative console in Tsugi, moving a collection of legacy PHP scripts toward a more structured controller-based architecture.
The Tsugi admin interface has grown organically over more than a decade. While functional, much of the code was written as standalone PHP pages rather than following the controller and service patterns used elsewhere in the application.
We explore how to reorganize the administration code into a hierarchy of smaller controllers, preserve existing behavior, move presentation code into templates, and extract shared utility functions into an admin service.
Topics include:
- Refactoring legacy PHP into controllers and routes
- Organizing administration features into smaller subcontrollers
- Separating controllers, templates, and services
- Preserving existing administrator authentication
- Preparing the architecture for future tenant and organization administrators
- Using Cursor AI to perform large-scale code restructuring
- Reviewing generated code and identifying remaining technical debt
This is an incremental refactoring session rather than a complete rewrite. The goal is to improve the structure of Tsugi while keeping the existing administrative console working.
Tsugi: tsugi.org
Python for Everybody: py4e.com
In January 2027, I'll be teaching Python for Everybody with AI. Visit py4e.com for more information.
#Tsugi #PHP #CursorAI #SoftwareEngineering #Refactoring #AICoding










