2026-01-01 15:40:32 -05:00
# Tinker Tickets - Project Documentation for AI Assistants
2026-01-01 19:45:49 -05:00
## Project Status (January 2026)
2026-01-23 10:39:55 -05:00
**Current Phase**: All core features implemented. System is production-ready.
2026-01-01 19:45:49 -05:00
2026-01-20 21:11:49 -05:00
**Completed Features**:
2026-01-23 10:39:55 -05:00
- Activity Timeline, Ticket Assignment, Status Transitions with Workflows
- Ticket Templates, Bulk Actions (Admin Only)
- File Attachments, Ticket Dependencies, @Mentions in Comments
- Recurring Tickets, Custom Fields, Advanced Search with Saved Filters
- Export to CSV/JSON, API Key Management
- Ticket Visibility Levels (public/internal/confidential)
- Collapsible Sidebar, Kanban Card View, Inline Ticket Preview
- Mobile Responsive Design, Ticket Linking in Comments
- Admin Pages (Templates, Workflow, Recurring, Custom Fields, User Activity, Audit Log, API Keys)
2026-01-24 16:59:29 -05:00
- Comment Edit/Delete (owner or admin can modify their comments)
- Markdown Tables Support, Auto-linking URLs in Comments
2026-01-01 19:45:49 -05:00
2026-01-01 15:40:32 -05:00
## Project Overview
2026-01-20 21:11:49 -05:00
Tinker Tickets is a feature-rich, self-hosted ticket management system built for managing data center infrastructure issues. It features SSO integration with Authelia/LLDAP, workflow management, Discord notifications, and a retro terminal-style web interface.
2026-01-01 15:40:32 -05:00
**Tech Stack:**
2026-01-01 19:45:49 -05:00
- Backend: PHP 7.4+ with MySQLi
2026-01-01 15:40:32 -05:00
- Frontend: Vanilla JavaScript, CSS3
2026-01-01 19:45:49 -05:00
- Database: MariaDB on separate LXC (10.10.10.50)
2026-01-23 22:01:20 -05:00
- Web Server: nginx with PHP-FPM on production (10.10.10.45)
2026-01-01 19:45:49 -05:00
- Authentication: Authelia SSO with LLDAP backend
2026-01-01 15:40:32 -05:00
**Production Environment:**
2026-01-23 22:01:20 -05:00
- **Primary URL**: https://t.lotusguild.org
- **Web Server**: nginx at 10.10.10.45 (`/var/www/html/tinkertickets` )
2026-01-01 19:45:49 -05:00
- **Database**: MariaDB at 10.10.10.50 (`ticketing_system` database)
- **Authentication**: Authelia provides SSO via headers
2026-01-23 22:01:20 -05:00
- **Dev Environment**: `/root/code/tinker_tickets` (not production)
2026-01-01 15:40:32 -05:00
## Architecture
2026-01-01 19:45:49 -05:00
### MVC Pattern
```
Controllers → Models → Database
↓
Views
```
2026-01-20 21:11:49 -05:00
### Project Structure
2026-01-01 15:40:32 -05:00
```
/tinker_tickets/
2026-01-01 19:45:49 -05:00
├── api/ # API endpoints
│ ├── add_comment.php # POST: Add comment
2026-01-20 21:11:49 -05:00
│ ├── assign_ticket.php # POST: Assign ticket to user
│ ├── bulk_operation.php # POST: Bulk operations - admin only
│ ├── check_duplicates.php # GET: Check for duplicate tickets
│ ├── delete_attachment.php # POST/DELETE: Delete attachment
2026-01-24 16:59:29 -05:00
│ ├── delete_comment.php # POST: Delete comment (owner/admin)
2026-01-20 21:11:49 -05:00
│ ├── export_tickets.php # GET: Export tickets to CSV/JSON
2026-01-23 10:39:55 -05:00
│ ├── generate_api_key.php # POST: Generate API key (admin)
2026-01-20 21:11:49 -05:00
│ ├── get_template.php # GET: Fetch ticket template
│ ├── get_users.php # GET: Get user list
│ ├── manage_recurring.php # CRUD: Recurring tickets (admin)
│ ├── manage_templates.php # CRUD: Templates (admin)
│ ├── manage_workflows.php # CRUD: Workflow rules (admin)
2026-01-23 10:39:55 -05:00
│ ├── revoke_api_key.php # POST: Revoke API key (admin)
2026-01-20 21:11:49 -05:00
│ ├── ticket_dependencies.php # GET/POST/DELETE: Ticket dependencies
2026-01-24 16:59:29 -05:00
│ ├── update_comment.php # POST: Update comment (owner/admin)
2026-01-20 21:11:49 -05:00
│ ├── update_ticket.php # POST: Update ticket (workflow validation)
│ └── upload_attachment.php # GET/POST: List or upload attachments
2026-01-01 19:45:49 -05:00
├── assets/
2026-01-01 15:40:32 -05:00
│ ├── css/
2026-01-20 21:11:49 -05:00
│ │ ├── dashboard.css # Dashboard + terminal styling
│ │ └── ticket.css # Ticket view styling
2026-01-01 15:40:32 -05:00
│ ├── js/
2026-01-20 21:11:49 -05:00
│ │ ├── advanced-search.js # Advanced search modal
│ │ ├── ascii-banner.js # ASCII art banner
2026-01-23 10:39:55 -05:00
│ │ ├── dashboard.js # Dashboard + bulk actions + kanban + sidebar
2026-01-20 21:11:49 -05:00
│ │ ├── keyboard-shortcuts.js # Keyboard shortcuts
2026-01-23 10:39:55 -05:00
│ │ ├── markdown.js # Markdown rendering + ticket linking
2026-01-20 21:11:49 -05:00
│ │ ├── settings.js # User preferences
2026-01-23 10:39:55 -05:00
│ │ ├── ticket.js # Ticket + comments + visibility
2026-01-20 21:11:49 -05:00
│ │ └── toast.js # Toast notifications
2026-01-01 15:40:32 -05:00
│ └── images/
│ └── favicon.png
├── config/
2026-01-01 19:45:49 -05:00
│ └── config.php # Config + .env loading
2026-01-20 21:11:49 -05:00
├── controllers/
│ ├── DashboardController.php # Dashboard with stats + filters
2026-01-23 10:39:55 -05:00
│ └── TicketController.php # Ticket CRUD + timeline + visibility
2026-01-20 21:11:49 -05:00
├── cron/
│ └── create_recurring_tickets.php # Process recurring ticket schedules
├── helpers/
│ └── ResponseHelper.php # Standardized JSON responses
├── middleware/
│ ├── AuthMiddleware.php # Authelia SSO integration
│ ├── CsrfMiddleware.php # CSRF protection
│ ├── RateLimitMiddleware.php # API rate limiting
│ └── SecurityHeadersMiddleware.php # Security headers
├── models/
2026-01-23 10:39:55 -05:00
│ ├── ApiKeyModel.php # API key generation/validation
2026-01-01 19:45:49 -05:00
│ ├── AuditLogModel.php # Audit logging + timeline
2026-01-20 21:11:49 -05:00
│ ├── BulkOperationsModel.php # Bulk operations tracking
2026-01-01 19:45:49 -05:00
│ ├── CommentModel.php # Comment data access
2026-01-20 21:11:49 -05:00
│ ├── CustomFieldModel.php # Custom field definitions/values
│ ├── DependencyModel.php # Ticket dependencies
│ ├── RecurringTicketModel.php # Recurring ticket schedules
│ ├── StatsModel.php # Dashboard statistics
│ ├── TemplateModel.php # Ticket templates
2026-01-23 10:39:55 -05:00
│ ├── TicketModel.php # Ticket CRUD + assignment + visibility
│ ├── UserModel.php # User management + groups
2026-01-20 21:11:49 -05:00
│ ├── UserPreferencesModel.php # User preferences
│ └── WorkflowModel.php # Status transition workflows
├── scripts/
2026-01-23 22:01:20 -05:00
│ ├── cleanup_orphan_uploads.php # Clean orphaned uploads
│ └── create_dependencies_table.php # Create ticket_dependencies table
2026-01-20 21:11:49 -05:00
├── uploads/ # File attachment storage
├── views/
│ ├── admin/
2026-01-23 10:39:55 -05:00
│ │ ├── ApiKeysView.php # API key management
2026-01-20 21:11:49 -05:00
│ │ ├── AuditLogView.php # Audit log browser
│ │ ├── CustomFieldsView.php # Custom field management
│ │ ├── RecurringTicketsView.php # Recurring ticket management
│ │ ├── TemplatesView.php # Template management
│ │ ├── UserActivityView.php # User activity report
│ │ └── WorkflowDesignerView.php # Workflow transition designer
2026-01-23 10:39:55 -05:00
│ ├── CreateTicketView.php # Ticket creation with visibility
│ ├── DashboardView.php # Dashboard with kanban + sidebar
│ └── TicketView.php # Ticket view with visibility editing
2026-01-20 21:11:49 -05:00
├── .env # Environment variables (GITIGNORED)
├── Claude.md # This file
├── README.md # User documentation
└── index.php # Main router
2026-01-01 15:40:32 -05:00
```
2026-01-20 21:11:49 -05:00
## Admin Pages
All admin pages are accessible via the **Admin dropdown ** in the dashboard header (for admin users only).
| Route | Description |
|-------|-------------|
| `/admin/templates` | Create and edit ticket templates |
| `/admin/workflow` | Visual workflow transition designer |
| `/admin/recurring-tickets` | Manage recurring ticket schedules |
| `/admin/custom-fields` | Define custom fields per category |
| `/admin/user-activity` | View per-user activity statistics |
| `/admin/audit-log` | Browse all audit log entries |
2026-01-23 10:39:55 -05:00
| `/admin/api-keys` | Generate and manage API keys |
2026-01-20 21:11:49 -05:00
## Database Schema
2026-01-01 15:40:32 -05:00
2026-01-01 19:45:49 -05:00
**Database**: `ticketing_system` at 10.10.10.50
**User**: `tinkertickets`
2026-01-01 15:40:32 -05:00
2026-01-01 19:45:49 -05:00
### Core Tables
2026-01-01 15:40:32 -05:00
2026-01-23 10:39:55 -05:00
- `tickets` - Core ticket data with assignment and visibility
2026-01-20 21:11:49 -05:00
- `ticket_comments` - Markdown-supported comments
- `ticket_attachments` - File attachment metadata
2026-01-23 10:39:55 -05:00
- `ticket_dependencies` - Ticket relationships
- `users` - User accounts synced from LLDAP (includes groups)
2026-01-20 21:11:49 -05:00
- `user_preferences` - User settings and preferences
- `audit_log` - Complete audit trail
- `status_transitions` - Workflow configuration
- `ticket_templates` - Reusable ticket templates
- `recurring_tickets` - Scheduled ticket definitions
- `custom_field_definitions` - Custom field schemas
- `custom_field_values` - Custom field data per ticket
- `saved_filters` - User-saved dashboard filters
- `bulk_operations` - Bulk operation tracking
2026-01-23 10:39:55 -05:00
- `api_keys` - API key storage with hashes
2026-01-20 21:11:49 -05:00
2026-01-23 10:39:55 -05:00
### Ticket Visibility Columns
- `visibility` - ENUM('public', 'internal', 'confidential')
- `visibility_groups` - VARCHAR(500) comma-separated group names
2026-01-20 21:11:49 -05:00
## Dashboard Features
2026-01-23 10:39:55 -05:00
- **View Toggle**: Switch between Table view and Kanban card view
- **Collapsible Sidebar**: Click arrow to collapse/expand filter sidebar
- **Stats Widgets**: Clickable cards for quick filtering
- **Inline Ticket Preview**: Hover over ticket IDs for 300ms to see preview popup
2026-01-20 21:11:49 -05:00
- **Sortable Columns**: Click headers to sort
- **Advanced Search**: Date ranges, priority ranges, user filters
- **Saved Filters**: Save and load custom filter combinations
2026-01-23 10:39:55 -05:00
- **Bulk Actions** (admin): Select multiple tickets for bulk operations
2026-01-20 21:11:49 -05:00
- **Export**: Export selected tickets to CSV or JSON
2026-01-01 15:40:32 -05:00
2026-01-23 10:39:55 -05:00
## Ticket Visibility Levels
2026-01-01 19:45:49 -05:00
2026-01-23 10:39:55 -05:00
- **Public**: All authenticated users can view
- **Internal**: Only users in specified groups can view
- **Confidential**: Only creator, assignee, and admins can view
2026-01-01 15:40:32 -05:00
## Important Notes for AI Assistants
2026-01-23 10:39:55 -05:00
1. **Session format ** : `$_SESSION['user']['user_id']` (not `$_SESSION['user_id']` )
2. **API auth ** : Check `$_SESSION['user']['user_id']` exists
3. **Admin check ** : `$_SESSION['user']['is_admin'] ?? false`
4. **Config path ** : `config/config.php` (not `config/db.php` )
5. **Comments table ** : `ticket_comments` (not `comments` )
6. **CSRF ** : Required for POST/DELETE requests via `X-CSRF-Token` header
7. **Cache busting ** : Use `?v=YYYYMMDD` query params on JS/CSS files
8. **Ticket linking ** : Use `#123456789` in markdown-enabled comments
9. **User groups ** : Stored in `users.groups` as comma-separated values
2026-01-23 22:01:20 -05:00
10. **API routing ** : All API endpoints must be added to `index.php` router
11. **Session in APIs ** : RateLimitMiddleware starts session; don't call session_start() again
12. **Database collation ** : Use `utf8mb4_general_ci` (not unicode_ci) for new tables
13. **Ticket ID extraction ** : Use `getTicketIdFromUrl()` helper in JS files
2026-01-01 15:40:32 -05:00
## File Reference Quick Guide
2026-01-20 21:11:49 -05:00
| File | Purpose |
|------|---------|
| `index.php` | Main router for all routes |
2026-01-23 10:39:55 -05:00
| `api/update_ticket.php` | Ticket updates with workflow + visibility |
| `models/TicketModel.php` | Ticket CRUD, visibility filtering |
| `models/ApiKeyModel.php` | API key generation and validation |
| `assets/js/dashboard.js` | Dashboard UI, kanban, sidebar, bulk actions |
| `assets/js/ticket.js` | Ticket UI, visibility editing |
| `assets/js/markdown.js` | Markdown parsing + ticket linking |
| `assets/css/dashboard.css` | Terminal styling, kanban, sidebar |
2026-01-01 19:45:49 -05:00
2026-01-23 10:39:55 -05:00
## Repository
2026-01-01 19:45:49 -05:00
- **Gitea**: https://code.lotusguild.org/LotusGuild/tinker_tickets
- **Production**: http://t.lotusguild.org