LTUC AI Assistant

LTUC AI Assistant

An intelligent learning companion for LTUC students, powered by OpenAI's advanced language models and built with Laravel.

Laravel 11.31 PHP 8.3 OpenAI GPT

Overview

The LTUC AI Assistant is a sophisticated web application designed specifically for Luminus Technical University College students. It provides an intelligent, conversational interface that helps students with academic questions, learning support, and educational guidance.

Intelligent Responses

Powered by OpenAI's advanced language models for accurate and helpful responses.

Student-Focused

Tailored specifically for LTUC students with academic context and support.

24/7 Availability

Always available to help with learning questions and academic support.

Why Laravel over Python?

While we acknowledge that Python is the dominant language in AI and machine learning ecosystems, we chose Laravel/PHP for this educational platform for several compelling reasons:

Superior Authentication & User Management

  • Built-in Laravel Breeze: Complete authentication system out of the box
  • Robust Session Management: Secure user sessions and CSRF protection
  • Role-Based Access Control: Easy implementation of user roles and permissions
  • Password Security: Built-in hashing, password reset, and email verification

Rapid Web Development

  • MVC Architecture: Clean, organized code structure for large applications
  • Eloquent ORM: Intuitive database interactions with relationships
  • Blade Templating: Powerful templating engine for dynamic UIs
  • Artisan CLI: Hundreds of built-in commands for development efficiency

Enterprise Web Features

  • Advanced Routing: RESTful routing with middleware and route caching
  • Database Migrations: Version control for database schema changes
  • Queue System: Background job processing for file handling
  • Caching: Redis/Memcached integration for performance

Production-Ready Infrastructure

  • Mature Ecosystem: 10+ years of enterprise-grade packages
  • Horizontal Scaling: Easy deployment across multiple servers
  • Error Handling: Comprehensive logging and debugging tools
  • Security: Built-in protection against OWASP top 10 vulnerabilities

Comprehensive AI Features

🤖 Core AI Capabilities

Advanced Conversational AI

  • • Powered by OpenAI GPT-4o for natural, intelligent responses
  • • Context-aware conversations with memory
  • • Educational focus tuned for academic scenarios
  • • Up to 16,000 tokens per response for detailed explanations

Personalized Learning Experience

  • • Personal chat history saved for registered users
  • • Multiple chat sessions with individual titles
  • • Contextual responses based on previous conversations
  • • Progress tracking and learning patterns

📁 Advanced File Processing (Up to 10MB)

Document Analysis

  • PDFs: Text extraction + embedded images
  • Word Documents: .docx, .doc with images
  • Spreadsheets: .xlsx, .xls, .csv data analysis
  • PowerPoint: .pptx, .ppt presentations
  • Text Files: .txt, .rtf, .md, .rst

Programming & Code Analysis

  • All Languages: Python, JavaScript, PHP, Java, C++, etc.
  • Web Files: HTML, CSS, SQL, JSON, XML
  • Config Files: YAML, TOML, ENV, Docker
  • Notebooks: Jupyter (.ipynb) cell-by-cell analysis
  • Build Files: Makefile, package.json, composer.json

Image & Visual Analysis

  • GPT-4o Vision: Advanced image understanding
  • OCR: Text extraction from images
  • Formats: PNG, JPG, GIF, BMP, WEBP, SVG
  • Analysis: Diagrams, charts, handwritten notes
  • Educational: Math problems, homework images

🎓 Academic & Educational Support

Math & Problem Solving

  • Math Equations: LaTeX formatting support
  • Calculus: Derivatives, integrals, limits
  • Algebra: Equations, matrices, polynomials
  • Statistics: Data analysis and interpretation
  • Homework Help: Step-by-step solutions

Learning Assistance

  • Concept Explanation: Complex topics simplified
  • Code Review: Bug detection and improvements
  • Research Help: Information synthesis
  • Writing Support: Essays, reports, documentation
  • Study Plans: Personalized learning paths

⚙️ Technical Features

Persistent Chat History

All conversations saved with full context retention and searchable history

Drag & Drop File Upload

Support for multiple files up to 10MB each with instant processing

Syntax Highlighting

Beautiful code display with copy functionality and language detection

Rich Text Formatting

Markdown support with tables, lists, and formatted content

Mobile Responsive

Perfect experience on all devices with touch-optimized interface

Secure Authentication

Laravel Breeze with CSRF protection and secure sessions

Rate Limiting

Built-in API throttling for optimal performance and fair usage

Demo Mode

Public demo access for testing without registration required

🎨 User Experience

LTUC Branding

Beautiful pink-purple gradients matching university colors

Dark Code Blocks

Professional ChatGPT-like code appearance

Interactive Elements

Hover effects and smooth animations

Copy to Clipboard

Easy code and text copying functionality

Technology Stack

Backend

Laravel 11.31 - PHP Framework
PHP 8.3-CLI - Server Runtime
MySQL/SQLite - Database

Frontend

TailwindCSS 3.1 - Styling
Alpine.js 3.4 - Interactivity
Vite 6.0 - Build Tool

AI & Processing

OpenAI PHP Client 0.15
PHPOffice Suite
CommonMark

Installation

Prerequisites

  • PHP 8.3 or higher
  • Composer
  • Node.js 20.x
  • MySQL or SQLite
  • OpenAI API Key

Setup Steps

# Clone the repository
git clone https://github.com/osamaalkhazali/LTUCBot.git
cd LTUCBot

# Install PHP dependencies
composer install

# Install Node.js dependencies
npm install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Run migrations
php artisan migrate

# Build assets
npm run build

# Start the development server
php artisan serve

Docker Deployment

The application uses a multi-stage Docker build process optimized for production deployment. The Dockerfile creates a lightweight, secure container with all necessary dependencies.

Docker Build Process

Stage 1: Node.js Build

  • • Node.js 20 Alpine base
  • • Install npm dependencies
  • • Build frontend assets with Vite
  • • Optimize for production

Stage 2: PHP Runtime

  • • PHP 8.3-CLI Alpine base
  • • Install required PHP extensions
  • • Copy application code
  • • Configure for production

Quick Start with Docker

# Build and run with Docker
docker build -t ltuc-ai-assistant .
docker run -p 8000:8000 ltuc-ai-assistant

# Or use Docker Compose
docker-compose up -d

Configuration

Environment Variables

Create your .env file with the following configurations:

# Application
APP_NAME="LTUC AI Assistant"
APP_ENV=production
APP_KEY=base64:your-generated-key
APP_DEBUG=false
APP_URL=https://ltucbot.up.railway.app

# Database (Clever Cloud MySQL)
DB_CONNECTION=mysql
DB_HOST=your-clever-cloud-host
DB_PORT=3306
DB_DATABASE=your-database-name
DB_USERNAME=your-username
DB_PASSWORD=your-password

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_ORGANIZATION=your_org_id_optional

# File Upload Limits
UPLOAD_MAX_FILESIZE=10M
POST_MAX_SIZE=10M

OpenAI API Setup

  1. Get API Key: Visit OpenAI Platform
  2. Create New Key: Generate a new secret key
  3. Add to Environment: Set OPENAI_API_KEY in your .env file
  4. Set Usage Limits: Configure billing and usage limits in OpenAI dashboard

Usage Guide

Access the Application

Demo Mode

Try without registration

Full Features

Register for chat history

Sample Text Questions

"Explain object-oriented programming"
"Help me understand calculus derivatives"
"Laravel development best practices"

File-based Interactions

"Analyze this code" + upload .php file
"Extract key points" + upload PDF
"What does this show?" + upload image

File Processing

Supported File Types

Category Extensions Processing Method
Documents .pdf, .docx, .doc, .txt, .rtf Text extraction + AI analysis
Spreadsheets .xlsx, .xls, .csv Data parsing + structure analysis
Images .png, .jpg, .jpeg, .gif, .bmp, .webp GPT-4o Vision API
Code .php, .js, .py, .java, .cpp, .html, .css Syntax-aware processing
Data .json, .xml, .yaml, .sql Structure-aware parsing
Archives .zip Content extraction + analysis

Processing Features

  • Automatic Type Detection - Smart MIME type analysis
  • Content Extraction - Text, code, and data extraction
  • Image Analysis - OCR and visual content understanding
  • Error Handling - Graceful fallbacks for unsupported files

Size Limits

  • Images: 10MB maximum for GPT-4o Vision
  • Documents: Configurable file size restrictions
  • Archives: Content extraction with size validation
  • Code Files: No specific size limit for text analysis

Live Deployments

Railway (Primary)

ltucbot.up.railway.app
  • • Production environment
  • • Automatic deployments
  • • High availability

Render (Backup)

ltucbot.onrender.com
  • • Backup deployment
  • • Docker-based hosting
  • • Redundancy and failover

Clever Cloud DB

MySQL Database
  • • Managed MySQL hosting
  • • Automatic backups
  • • Shared across deployments

API Integration

OpenAI Configuration

The application uses OpenAI's latest models for optimal performance:

Chat Completions

'model' => 'gpt-4o',
'max_tokens' => 16000,
'temperature' => 0.7

Vision API (Images)

'model' => 'gpt-4o-mini',
'detail' => 'high'

Response Formatting

All AI responses include multiple formats for optimal user experience:

Raw Text: Original AI response
HTML: Parsed markdown with syntax highlighting
Code Blocks: Formatted with copy functionality
File Analysis: Structured content extraction results

Development

Development Environment Setup

# Install development dependencies
composer install --dev
npm install --dev

# Set up testing database
php artisan migrate --env=testing

# Run development server with debugging
php artisan serve --env=local

Code Standards

  • PSR-12: PHP coding standard compliance
  • Laravel Conventions: Follow Laravel best practices
  • Documentation: Comment complex functions
  • Testing: Write tests for new features

Testing

Test Suite

The application includes comprehensive testing with PHPUnit:

Feature Tests

  • • Authentication flow testing
  • • Chat functionality testing
  • • File upload testing
  • • API endpoint testing

Unit Tests

  • • File processing logic
  • • Model relationships
  • • Helper functions
  • • Validation rules
# Run all tests
php artisan test

# Run specific test suite
php artisan test --testsuite=Feature
php artisan test --testsuite=Unit

Contributing

Development Workflow

1

Fork the Repository

Create your own fork of the project

2

Create Feature Branch

git checkout -b feature/amazing-feature
3

Make Changes

Follow PSR-12 coding standards

4

Run Tests

Ensure all tests pass

5

Submit Pull Request

With detailed description of changes

License & Acknowledgments

License

This project is open-sourced software licensed under the MIT license.

Acknowledgments

OpenAI for providing the GPT-4o API
Laravel Community for the amazing framework
Railway & Render for reliable hosting
LTUC for supporting educational technology
LTUC AI Assistant

Built with ❤️ for Education

© 2025 LTUC AI Assistant | Powered by Laravel & OpenAI