A comprehensive system for managing, versioning, and serving system prompts for LLM applications.
Prompt Builder is a dual-stack application that provides:
- Laravel Admin Interface - Full-featured web UI for editing and managing prompts
- Slim/RoadRunner API - High-performance public API for serving prompts to external services
- Version Control: Track different versions of prompts with draft/active/archived status
- Sectioned Organization: Organize prompt content into logical sections (identity, safety, style, etc.)
- Granular Editing: Edit individual lines within prompts
- Drag-and-Drop Reordering: Easily reorder prompt lines and sections
- Section Filtering: Work on specific sections at a time
- Enable/Disable: Toggle individual lines or entire sections without deletion
- Full-Text Rendering: Generate complete prompts for API consumption
- Statistics: Track prompt length, line counts, and usage metrics
- Cloning: Duplicate versions for iterative development
- Preview Mode: View rendered prompts before activation
┌─────────────────────────────────────────────────────────────┐
│ Prompt Builder System │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Laravel Admin │ │ Slim/RoadRunner │ │
│ │ Interface │ │ API │ │
│ │ │ │ │ │
│ │ - Version Mgmt │ │ - Get Active │ │
│ │ - Line Editor │ │ - Get by Version │ │
│ │ - Section Mgmt │ │ - List Versions │ │
│ │ - Preview │ │ - Statistics │ │
│ └────────┬─────────┘ └────────┬─────────┘ │
│ │ │ │
│ └──────────────┬───────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ PostgreSQL │ │
│ │ Database │ │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
- prompt_version - Stores versions of prompts
- prompt_section - Defines organizational sections
- prompt_line - Individual lines of prompt content
See database/schema.sql for complete DDL.
PromptBuilder/
├── app/
│ ├── Models/ # Eloquent models
│ │ ├── PromptVersion.php
│ │ ├── PromptSection.php
│ │ └── PromptLine.php
│ ├── Services/ # Business logic layer
│ │ └── PromptService.php
│ └── Http/
│ └── Controllers/ # Laravel controllers
│ ├── PromptVersionController.php
│ ├── PromptLineController.php
│ ├── PromptSectionController.php
│ └── PromptApiController.php
├── routes/
│ ├── web.php # Laravel web routes
│ └── api.php # Laravel API routes
├── resources/
│ └── views/
│ └── prompts/ # Blade templates
│ ├── layout.blade.php
│ ├── index.blade.php
│ ├── edit.blade.php
│ ├── show.blade.php
│ └── create.blade.php
├── database/
│ └── migrations/ # Database migrations
├── SLIM_API_INTEGRATION.md # Slim/RoadRunner setup guide
└── README.md # This file
- PHP 8.1+
- PostgreSQL 12+
- Composer
- Node.js & NPM (for frontend assets)
- Clone the repository
git clone <repository-url>
cd PromptBuilder- Install dependencies
composer install
npm install- Configure environment
cp .env.example .env
# Edit .env with your database credentials- Run migrations
php artisan migrate- Seed sections (optional)
php artisan db:seed --class=PromptSectionSeeder- Start Laravel server
php artisan serveVisit http://localhost:8000 to access the admin interface.
See SLIM_API_INTEGRATION.md for complete setup instructions.
Quick start:
# Install Slim dependencies
composer require slim/slim slim/psr7
# Download RoadRunner
wget https://github.com/roadrunner-server/roadrunner/releases/download/v2023.3.0/roadrunner-2023.3.0-linux-amd64.tar.gz
tar -xzf roadrunner-*.tar.gz
# Run RoadRunner
./rr serveAPI available at http://localhost:8080/api/v1/
- Navigate to "Create Version"
- Enter:
- Prompt Name (e.g., "AskGVT")
- Version Label (e.g., "v2025-10-28")
- Status (draft/active/archived)
- Notes (optional)
- Click "Create Version"
- Select a version from the list
- Click "Edit"
- Use the editor to:
- Add new lines with "+" button
- Edit existing lines inline
- Drag lines to reorder
- Toggle enabled/disabled
- Move lines between sections
- Delete unwanted lines
- Click "Save All Changes"
- From the versions list, click the activation button
- Confirm - this will deactivate other versions with the same name
- The API will now serve this version as "active"
- Click the clone button on any version
- Enter a new version label
- Add notes about the changes
- Edit the cloned version
curl http://localhost:8080/api/v1/prompts/AskGVT/activeResponse:
{
"success": true,
"data": {
"prompt_name": "AskGVT",
"version_id": 1,
"version_label": "v2025-10-28",
"prompt": "Your system is AskGVT...",
"generated_at": "2025-10-28T12:00:00+00:00"
}
}curl http://localhost:8080/api/v1/prompts/versions/1curl http://localhost:8080/api/v1/prompts/AskGVT/versions/v2025-10-28curl http://localhost:8080/api/v1/prompts/AskGVT/versionscurl http://localhost:8080/api/v1/prompts/versions/1/statsSee SLIM_API_INTEGRATION.md for complete API documentation.
Represents a version of a prompt.
Key Methods:
renderPrompt()- Generate full text outputrenderPromptWithSections()- Generate output with section headerscloneVersion()- Duplicate a versionenabledLines()- Get only enabled lineslinesBySection()- Get lines grouped by section
Represents an organizational section.
Key Methods:
linesForVersion()- Get lines for a specific versionreorder()- Reorder sectionsgetNextOrderIndex()- Get next available position
Represents an individual line of content.
Key Methods:
moveToSection()- Move line to different sectionreorder()- Reorder lines within a sectionduplicateToVersion()- Copy line to another version
Centralized business logic for all prompt operations.
Key Methods:
- Version management:
getVersions(),createVersion(),updateVersion(),deleteVersion() - Line management:
getLines(),createLine(),updateLine(),deleteLine(),reorderLines() - Section management:
getSections(),createSection(),updateSection(),deleteSection() - Rendering:
renderPrompt(),renderActivePrompt() - Statistics:
getVersionStats()
- PromptVersionController - Manages versions (CRUD, clone, activate)
- PromptLineController - Manages individual lines (CRUD, reorder, move)
- PromptSectionController - Manages sections (CRUD, reorder)
- PromptApiController - Public API for external services
GET /prompts - List all versions
GET /prompts/create - Create new version form
POST /prompts - Store new version
GET /prompts/{id} - View version
GET /prompts/{id}/edit - Edit version
PUT /prompts/{id} - Update version
DELETE /prompts/{id} - Delete version
POST /prompts/{id}/clone - Clone version
POST /prompts/{id}/activate - Activate version
GET /prompts/{id}/render - Render full prompt
GET /prompts/{id}/stats - Get statistics
GET /lines - Get lines (filtered)
POST /lines - Create line
PUT /lines/{id} - Update line
DELETE /lines/{id} - Delete line
POST /lines/reorder - Reorder lines
POST /lines/{id}/move - Move line to section
GET /sections - List sections
POST /sections - Create section
PUT /sections/{id} - Update section
DELETE /sections/{id} - Delete section
POST /sections/reorder - Reorder sections
GET /api/v1/health - Health check
GET /api/v1/prompts/{name}/active - Get active prompt
GET /api/v1/prompts/versions/{id} - Get by version ID
GET /api/v1/prompts/{name}/versions/{label} - Get by version label
GET /api/v1/prompts/{name}/versions - List versions
GET /api/v1/prompts/versions/{id}/stats - Get statistics
- Bootstrap 5 - UI framework
- jQuery - DOM manipulation and AJAX
- SortableJS - Drag-and-drop functionality
- Bootstrap Icons - Icon library
Recommended indexes for performance:
CREATE INDEX idx_prompt_version_name_status ON prompt_version(prompt_name, status);
CREATE INDEX idx_prompt_version_name_label ON prompt_version(prompt_name, version_label);
CREATE INDEX idx_prompt_line_version_section ON prompt_line(version_id, section_id);
CREATE INDEX idx_prompt_line_order ON prompt_line(order_index);
CREATE INDEX idx_prompt_section_order ON prompt_section(order_index);- Use semantic versioning or date-based labels
- Keep drafts for work-in-progress changes
- Only one active version per prompt name
- Archive old versions instead of deleting
- Clone before major changes to preserve history
- Use sections to organize related content
- Keep lines focused - one concept per line
- Use meaningful section keys (lowercase, underscore-separated)
- Order sections logically (identity → rules → examples)
- Disable, don't delete when testing changes
- Cache rendered prompts in your application
- Use version IDs for deterministic retrieval
- Monitor stats endpoint for prompt growth
- Handle 404s gracefully for missing versions
- Use
include_sectionsfor debugging only
php artisan test# Test health check
curl http://localhost:8080/api/v1/health
# Test active prompt retrieval
curl http://localhost:8080/api/v1/prompts/AskGVT/active
# Test version listing
curl http://localhost:8080/api/v1/prompts/AskGVT/versions- Use connection pooling
- Add indexes on frequently queried columns
- Consider read replicas for API
- Implement response caching (Redis, Memcached)
- Use RoadRunner for concurrent request handling
- Monitor worker pool size
- Minimize DOM operations
- Lazy-load sections with many lines
- Debounce auto-save operations
Add authentication middleware:
- Laravel: Use built-in auth or Sanctum
- Slim: Implement API key middleware
- Restrict write operations to admin users
- Rate limit public API endpoints
- Validate all inputs
- Use prepared statements (implemented)
- Sanitize user input
- Enable HTTPS in production
- Regular security audits
# Check PostgreSQL is running
sudo systemctl status postgresql
# Test connection
psql -h localhost -U postgres -d prompt_builder# Clear cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
# Check logs
tail -f storage/logs/laravel.log# Check RoadRunner status
./rr reset
# View logs
tail -f .rr.log- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
[Your License Here]
For issues and questions:
- GitHub Issues: [repository-url]/issues
- Documentation: See SLIM_API_INTEGRATION.md
- Email: [your-email]
- Initial release
- Laravel admin interface
- Slim/RoadRunner API
- Version management
- Section organization
- Line editing with drag-and-drop
- Statistics and reporting