A modern, responsive ticket management application built with PHP, Twig templating engine, and Tailwind CSS. This application provides a complete solution for managing tickets with authentication, dashboard analytics, and full CRUD operations.
- Landing Page with wavy SVG background and decorative elements
- Authentication System with login/signup and session management
- Dashboard with ticket statistics and quick navigation
- Complete CRUD Operations for ticket management
- Responsive Design optimized for mobile, tablet, and desktop
- Responsive Sidebar with mobile hamburger menu
- Form Validation with real-time error handling
- Toast Notifications for user feedback
- Protected Routes with session-based authentication
- β Max-width 1440px centered layout
- β Wavy background hero section
- β Decorative circle elements
- β Card-style boxes with shadows and rounded corners
- β Responsive mobile/tablet/desktop layouts
- β Complete authentication with localStorage session management
- β Full ticket CRUD with validation
- β Status-based color coding (green/amber/gray)
- β Accessibility compliance with semantic HTML
- β Error handling for all scenarios
- PHP 8.1+ - Server-side language
- Twig 3.21 - Modern templating engine
- Composer - PHP dependency manager
- Tailwind CSS 4.1.16 - Utility-first CSS framework
- Tailwind CLI - Build and watch CSS changes
- Custom CSS - Additional animations and utilities
- Vanilla JavaScript - Client-side interactivity
- localStorage API - Data persistence and session management
- PHP Built-in Server - Development server with custom router
- Custom Router - Routes static assets and PHP endpoints
- PHP 8.1 or higher
- Composer (PHP package manager)
- Node.js 16+ and npm (for Tailwind CSS)
-
Clone or download the project
cd /path/to/stage2-twig -
Install PHP dependencies
composer install
-
Install Node.js dependencies
npm install
-
Build Tailwind CSS
npm run build:css
-
Start the development server
php -S localhost:8000 router.php
-
Open your browser
- Navigate to
http://localhost:8000 - The application will be ready to use
- Navigate to
For active development with automatic CSS rebuilding:
Terminal 1 - PHP Server:
php -S localhost:8000 router.phpTerminal 2 - Tailwind Watch:
npm run watch:cssstage2-twig/
βββ src/
β βββ index.php # Main application entry point
β βββ css/
β βββ input.css # Tailwind CSS source file
βββ templates/ # Twig template files
β βββ base.twig # Base layout template
β βββ landing.twig # Landing/marketing page
β βββ login.twig # User login page
β βββ register.twig # User registration page
β βββ dashboard.twig # Main dashboard
β βββ tickets.twig # Ticket management interface
β βββ modals/ # Modal components
β βββ create-ticket.twig
β βββ edit-ticket.twig
βββ public/ # Public assets
β βββ styles.css # Compiled Tailwind CSS
β βββ app.js # Main JavaScript file
βββ cache/ # Twig compiled templates (auto-generated)
βββ vendor/ # Composer dependencies
βββ node_modules/ # NPM dependencies
βββ router.php # Custom PHP router for dev server
βββ composer.json # PHP dependencies
βββ package.json # Node.js dependencies
βββ tailwind.config.js # Tailwind configuration
- Main HTML structure with head and body
- Tailwind CSS and JavaScript includes
- Toast notification container
- Block system for extending templates
- landing.twig: Marketing page with hero, features, and CTA sections
- login.twig: Login form with validation
- register.twig: Registration form with validation
- dashboard.twig: Dashboard with stats cards and quick actions
- tickets.twig: Ticket management with CRUD operations
- Sidebar: Responsive navigation (desktop + mobile variants)
- Modals: Create and edit ticket forms
- Forms: Inline validation with error messages
Templates extend base.twig and use these blocks:
{% block title %}- Page title{% block head %}- Additional head content{% block body %}- Main body content (overrides default structure){% block content %}- Page-specific content (within base structure){% block scripts %}- Page-specific JavaScript
All application state is managed client-side using JavaScript and localStorage:
Authentication Context:
- User session and authentication state
- Stored in
ticketapp_session,ticketapp_user,ticketapp_users - Methods: login, signup, logout, session validation
Ticket Context:
- All ticket data and CRUD operations
- Stored in
ticketapp_tickets - Methods: create, read, update, delete, filter, search
All data is stored in localStorage with the following keys:
ticketapp_session: Current user session tokenticketapp_user: Current user informationticketapp_users: Database of all registered usersticketapp_tickets: Array of all tickets
- PHP/Twig renders initial HTML structure
- Data is injected from localStorage on page load
- All interactions are handled client-side with JavaScript
- Form validation for email, password, name, and confirmation
- Duplicate email prevention
- Password match validation
- Automatic login after successful registration
- Email and password validation
- Session token generation and storage
- Redirect to dashboard on success
- Error messages for invalid credentials
- Protected routes check for valid session token
- Automatic logout and redirect for invalid sessions
- Session persistence across browser refreshes
- Logout clears session and redirects to landing page
For testing purposes, you can use these credentials or create new accounts:
Or create a new account:
- Use any valid email format
- Password must be at least 6 characters
- Passwords must match
- Full name is required
- Stacked layout with hamburger menu
- Full-width cards and forms
- Touch-friendly button sizes
- Slide-out mobile sidebar with overlay
- Two-column grid layouts
- Optimized spacing and typography
- Responsive sidebar behavior
- Three-column layouts where appropriate
- Fixed sidebar navigation (desktop pages)
- Max-width 1440px container
- Hover states and interactions
- Proper heading hierarchy (h1, h2, h3)
- Semantic elements (
<main>,<section>,<nav>,<header>,<footer>) - Form labels and associations
- ARIA attributes where needed
- Tab order and focus management
- Visible focus indicators
- Modal trap focus
- Escape key to close modals
- WCAG-compliant color contrast ratios
- Status colors with sufficient contrast:
- Open tickets: Green (#16a34a)
- In Progress: Amber (#d97706)
- Closed: Gray (#6b7280)
- ARIA labels and descriptions
- Alternative text for decorative elements
- Meaningful link text
- Form error announcements
- Title: Required, minimum 1 character, max 100 characters
- Description: Optional, max 500 characters
- Status: Required, must be one of:
open,in_progress,closed - Priority: Optional, must be one of:
low,medium,high
- Email: Valid email format required
- Password: Minimum 6 characters
- Confirm Password: Must match password field
- Name: Required for registration, minimum 2 characters
- Real-time validation with inline error messages
- Toast notifications for system-level feedback
- Graceful fallbacks for failed operations
- User-friendly error messages
- Uses localStorage instead of a real database
- Data is limited to single browser/device
- No data synchronization across devices
- No server-side data storage
- Session tokens are simple strings, not JWT
- No password reset functionality
- No email verification process
- Passwords stored in plain text (localStorage only - not production-ready)
- No pagination for large ticket lists
- All data loaded into memory at once
- No server-side rendering of dynamic data
- Modern browsers only (ES2015+ features)
- No Internet Explorer support
- Requires JavaScript to be enabled
- localStorage must be available
- Backend Integration: Real API with database (MySQL, PostgreSQL)
- JWT Authentication: Secure token-based auth
- Password Hashing: bcrypt or similar for security
- Email Verification: Send verification emails on signup
- Password Reset: Secure password recovery flow
- Pagination: Handle large datasets efficiently
- File Attachments: Upload files to tickets
- Real-time Updates: WebSocket integration
- Dark Mode: Theme toggle support
- Export Data: CSV/PDF export functionality
- Advanced Filters: Complex filtering and search
- User Roles: Admin, manager, user permissions
This Twig implementation can be easily migrated to:
- Full-stack PHP: Add database layer (PDO, Eloquent)
- Laravel: Integrate with Laravel framework
- Symfony: Use Symfony components
- Other frameworks: Similar structure to React/Vue versions
npm run build:css # Build Tailwind CSS once
npm run watch:css # Watch and rebuild CSS on changesThe tailwind.config.js scans these files for classes:
./templates/**/*.twig- All Twig templates./src/**/*.php- PHP source files
Custom CSS in src/css/input.css uses Tailwind v4 syntax:
@import "tailwindcss";This project is part of the HNG Frontend Stage 2 requirements.
This is a learning project for the HNG internship program. Follow the established patterns for:
- Twig template structure and blocks
- JavaScript module organization
- Tailwind CSS utility classes
- localStorage key naming conventions
Built with β€οΈ for the HNG Internship Program
For more information about HNG Internship opportunities, visit:
- Landing Page with wavy SVG background and decorative elements
- Authentication System with login/signup and session management
- Dashboard with ticket statistics and quick navigation
- Complete CRUD Operations for ticket management
- Responsive Design optimized for mobile, tablet, and desktop
- Responsive Sidebar with mobile hamburger menu
- Form Validation with real-time error handling
- Toast Notifications for user feedback
- Protected Routes with session-based authentication
- β Max-width 1440px centered layout
- β Wavy background hero section
- β Decorative circle elements
- β Card-style boxes with shadows and rounded corners
- β Responsive mobile/tablet/desktop layouts
- β Complete authentication with localStorage session management
- β Full ticket CRUD with validation
- β Status-based color coding (green/amber/gray)
- β Accessibility compliance with semantic HTML
- β Error handling for all scenarios
- React 19.2.0 - Main UI framework
- TypeScript 5.9.3 - Type safety and developer experience
- Vite 7.1.12 - Build tool and development server
- Tailwind CSS 4.1.16 - Utility-first CSS framework
- shadcn/ui Components - Pre-built accessible UI components
- Lucide React 0.546.0 - Icon library
- Class Variance Authority - Component variant management
- React Router DOM 7.9.4 - Client-side routing and navigation
- React Hook Form 7.65.0 - Form state management
- Zod 4.1.12 - Schema validation
- @hookform/resolvers - Integration between React Hook Form and Zod
- React Context API - Global state for authentication and tickets
- localStorage - Data persistence
- Sonner 2.0.7 - Toast notifications
- Next Themes 0.4.6 - Theme management support
- ESLint - Code linting and quality
- TypeScript ESLint - TypeScript-specific linting rules
- Node.js (version 16 or higher)
- npm or pnpm package manager
-
Clone or download the project
cd /path/to/stage2-react -
Install dependencies
npm install # or pnpm install -
Start the development server
npm run dev # or pnpm dev -
Open your browser
- Navigate to
http://localhost:5173 - The application will automatically reload when you make changes
- Navigate to
npm run build
# or
pnpm buildnpm run preview
# or
pnpm previewsrc/
βββ components/ # Reusable UI components
β βββ forms/ # Form components (CreateTicketForm, EditTicketForm)
β βββ layout/ # Layout components (AppLayout, Sidebar, Footer)
β βββ ui/ # shadcn/ui components and custom UI elements
βββ context/ # React Context providers
β βββ AuthContext.tsx # Authentication state management
β βββ TicketContext.tsx # Ticket data management
β βββ AppProviders.tsx # Combined context providers
βββ pages/ # Page components
β βββ LandingPage.tsx # Marketing/landing page
β βββ LoginPage.tsx # User login
β βββ SignupPage.tsx # User registration
β βββ Dashboard.tsx # Main dashboard
β βββ TicketManagement.tsx # Ticket CRUD interface
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ lib/ # Shared libraries and configurations
- AppLayout: Wrapper component that includes sidebar navigation
- Sidebar: Responsive navigation with desktop/mobile variants
- Footer: Consistent footer across all pages
- CreateTicketForm: Modal form for creating new tickets
- EditTicketForm: Modal form for updating existing tickets
- Validation: Real-time validation with error messages
- Button: Various button variants and sizes
- Card: Container component for content sections
- Input: Form input fields with validation states
- Sheet: Mobile slide-out navigation
- Badge: Status indicators for tickets
- Toast: Notification system via Sonner
- WaveBackground: SVG wave pattern for hero section
- DecorativeCircle: Floating decorative elements
- ProtectedRoute: Route guard for authenticated pages
- User State: Current logged-in user information
- Session Management: localStorage-based session tokens
- Methods:
login(),signup(),logout() - Data: Stored in
ticketapp_session,ticketapp_user,ticketapp_users
- Ticket State: Array of all tickets
- CRUD Operations:
addTicket(),updateTicket(),deleteTicket() - Statistics:
getTicketStats()for dashboard metrics - Data: Persisted in
ticketapp_ticketslocalStorage key
All data is stored in localStorage with the following keys:
ticketapp_session: Current user session tokenticketapp_user: Current user informationticketapp_users: Database of all registered usersticketapp_tickets: Array of all tickets
- Form validation for email, password, and name
- Duplicate email prevention
- Automatic login after successful registration
- Email and password validation
- Session token generation and storage
- Redirect to dashboard on success
- Protected routes check for valid session token
- Automatic logout and redirect for invalid sessions
- Session persistence across browser refreshes
For testing purposes, you can use these credentials or create new accounts:
Pre-seeded Test User:
- Email:
admin@ticketly.com - Password:
password123 - Name:
Admin User
Or create a new account:
- Use any valid email format
- Password must be at least 6 characters
- Full name is required
- Stacked layout with hamburger menu
- Full-width cards and forms
- Touch-friendly button sizes
- Collapsible sidebar with slide-out sheet
- Two-column grid layouts
- Optimized spacing and typography
- Responsive sidebar behavior
- Three-column layouts where appropriate
- Fixed sidebar navigation
- Max-width 1440px container
- Hover states and interactions
- Proper heading hierarchy (h1, h2, h3)
- Semantic elements (
<main>,<section>,<nav>) - Form labels and associations
- Tab order and focus management
- Visible focus indicators
- Skip links where appropriate
- WCAG-compliant color contrast ratios
- Status colors with sufficient contrast:
- Open tickets: Green (#16a34a)
- In Progress: Amber (#d97706)
- Closed: Gray (#6b7280)
- ARIA labels and descriptions
- Alternative text for decorative elements
- Meaningful link text
- Title: Required, 1-100 characters
- Description: Optional, max 500 characters
- Status: Required, must be one of:
open,in_progress,closed - Priority: Optional, must be one of:
low,medium,high
- Email: Valid email format required
- Password: Minimum 6 characters
- Name: Required for registration
- Real-time validation with inline error messages
- Toast notifications for system-level errors
- Graceful fallbacks for failed operations
- Uses localStorage instead of a real database
- Data is limited to single browser/device
- No data synchronization across devices
- Session tokens are simple strings, not JWT
- No password reset functionality
- No email verification process
- No pagination for large ticket lists
- All data loaded into memory at once
- No image optimization for decorative elements
- Modern browsers only (ES2022+ features)
- No Internet Explorer support
- Requires JavaScript to be enabled
- Real backend API integration
- JWT-based authentication
- Data export functionality
- Drag-and-drop ticket management
- Real-time notifications
- Dark mode support
- Pagination for large datasets
- Advanced filtering and search
This application is designed to be easily portable to:
- Vue.js: Component structure maps well to Vue components
- Twig/PHP: Server-side rendering with similar layouts
- Other frameworks: Clean separation of concerns
This project is part of the HNG Frontend Stage 2 requirements.
This is a learning project for the HNG internship program. Follow the established patterns for:
- Component structure
- State management
- Styling conventions
- TypeScript usage
Built with β€οΈ for the HNG Internship Program