A robust Laravel web application dedicated to performing high-accuracy Optical Character Recognition (OCR) using local Large Language Models (LLMs).
This project leverages modern web architecture to process images and extract textual data with the high precision characteristic of Vision Language Models (VLMs). Designed with a focus on performance and reliability, the application offloads the heavy lifting of AI inferences to background queues, ensuring a fast, non-blocking user experience on the frontend.
By communicating with a local AI server (such as LM Studio running glm-ocr), the application guarantees data privacy, avoiding third-party cloud API costs and providing a fully self-hosted solution for text extraction, document parsing, and sanitization.
- Asynchronous Processing: Long-running AI inference tasks are dispatched to isolated background Job queues, preventing HTTP request timeouts.
- Real-Time UX (Polling): The UI seamlessly polls the backend for processing updates without requiring page reloads, transitioning states from 'pending' to 'completed'.
- Clean Architecture: Built over solid engineering principles, featuring
Actions(invokables) for single-responsibility logic routing, decoupling business rules from controllers. - Local AI Integration: Designed specifically to interact with Local LLMs via REST APIs, fully capturing, sanitizing, and filtering zero-width spaces or artifacts from AI responses.
- Robust Automated Testing: A comprehensive test suite using
Pest PHPcovering HTTP request faking, queue state transitions, JSON structural validation, and fallback mechanisms.
- Backend: PHP 8.4+, Laravel 13
- Database / Queue: SQLite (relational records) & Database Queue Driver
- AI Backend / Integration: LM Studio API (Local VLM processing)
- Testing: Pest PHP (Feature & Integration tests)
- Frontend: Vanilla JS & Blade Templates
To run this application locally, you will need PHP 8.4+, Composer, and LM Studio server running a compatible Vision Language Model locally on port 1234.
Clone the repository and install dependencies:
composer installPrepare your environment file:
cp .env.example .env
php artisan key:generate# Create SQLite Database (If using sqlite)
touch database/database.sqlite
# Run migrations
php artisan migrate
# Link local storage for image uploads
php artisan storage:linkYou will need two terminal windows to run the application fully (due to the async architecture).
Terminal 1 - Web Server:
php artisan serveTerminal 2 - Queue Worker:
php artisan queue:workEnsure LM Studio is running in the background and the Local Inference Server is started on http://127.0.0.1:1234. The model recommended for OCR tasks is glm-ocr or similar vision-capable models.
The codebase relies on Pest PHP for highly expressive and documented tests ensuring the application behaves accurately without needing to spin up a real AI server each time.
# Run the entire test suite
./vendor/bin/pest