How asistente-informatica-enec/sigb works
Project type and purpose
• This is a full‐stack web application built on Laravel (PHP) with a Filament admin panel and Blade/Vue‐style frontend views.
• Purpose: Manage academic library resources (catalogs, loans, returns, history, reports) and perform an asynchronous cross‐repository search (Project Gutenberg, PMC, PubMed) with on‐the‐fly translation via LibreTranslate.
File‐structure analysis
• Top‐level folders
• app/ ← core application (Console commands, HTTP controllers, models, services, events, jobs, Filament resources/widgets)
• config/, bootstrap/, routes/ ← framework/configuration
• database/ ← migrations, factories, seeders
• public/ ← web‐accessible assets (CSS/JS for Filament admin & custom search UI)
• resources/ ← Blade views (search pages, Filament pages/widgets, PDFs), frontend assets (JS, CSS)
• storage/ ← logs, cache, uploaded/generated files
• scripts at root (start‐services.sh, start‐search‐worker.sh) + supervisor‐queue‐worker.conf → deployment/worker orchestration
• Architectural patterns
• MVC in app/Http (Controllers → Models → Views in resources/views)
• Service layer in app/Services for external‐API handling and translation
• Command/Job/Queue pattern (app/Console commands launch background jobs, app/Jobs process API searches)
• Event‐driven updates (app/Events/SearchResultsUpdated, broadcasting via Echo)
• Filament resource pattern (app/Filament/Resources, Widgets, Pages) for admin UI
Key README insights
• Emphasis on multilingual meta‐search using three external APIs and LibreTranslate
• Dual UIs: public search interface + Filament admin panel
• Reports in PDF generated under resources/views/pdf and output to storage
a. Main components
• Client browsers
– Public Search UI (Blade views + JS)
– Filament Admin UI (JS/CSS loaded from public/)
• Laravel backend
– HTTP layer: routes/web.php & routes/api.php → Controllers
– Service layer: ExternalApiService, TranslationService
– Data layer: Eloquent Models → MySQL/PostgreSQL
• Queue subsystem
– job dispatcher (SearchExternalApisJob)
– queue backend (Redis/DB as per config/queue.php)
– queue worker (supervisor‐managed, start‐search‐worker.sh)
• Event/Broadcasting
– Events (SearchResultsUpdated)
– WebSocket channel (Echo.js) → real‐time updates in UI
• External systems
– Project Gutenberg API
– PMC API
– PubMed API
– LibreTranslate API
• Storage & artifacts
– File storage for PDFs (Loan/Report outputs)
– Logs & cache
b. Relationships and data flow
1. User triggers search from public UI → HTTP POST to PublicSearchController
2. Controller enqueues SearchExternalApisJob → stored in queue driver
3. Queue worker fetches job → ExternalApiService calls each external API
4. Raw results → TranslationService (via LibreTranslate) → normalized results
5. Event SearchResultsUpdated fired → broadcast to client via WebSocket
6. Browser listens (Echo.js) → renders results asynchronously
7. Admin UI (Filament) interacts with Controllers → CRUD on Books, Authors, Loans → DB
8. Reports: user/admin triggers PDF generation → Controller/Service renders Blade PDF view → stored or streamed
c. Architectural patterns & principles
• MVC separation between UI (Blade/Filament), business logic (Controllers/Services), persistence (Models/DB)
• Event‐driven async updates for search results
• queued background processing for long‐running API calls
• dependency inversion: controllers depend on service‐layer interfaces
• resource‐centric admin UI via Filament
d. Key technologies
• Laravel (PHP 8.x), Eloquent ORM
• Filament (Laravel admin panel)
• Blade templating, Alpine.js/Echo.js for real‐time
• Queues: Redis or database driver, supervisor
• External HTTP APIs + Guzzle (likely)
• LibreTranslate for machine translation
• MySQL/PostgreSQL
• PDF generation (e.g., Dompdf or Snappy)