How armandoch85/restaurante works
Project Type & Purpose
• This is a full-stack Laravel web application serving as a Restaurant POS & Electronic Invoicing system.
• Key features include:
• Point-of-Sale UI (Livewire components under app/Livewire and resources/views/pos)
• Table-map management (Livewire / Filament pages under app/Filament and resources/views)
• Filament-powered admin panel for CRUD on orders, products, invoices, reservations, etc.
• Electronic billing integration with SUNAT (app/Services/SunatService, multiple Console commands for SUNAT operations)
• Background tasks (Console commands, scheduled jobs, events/listeners)
File Structure & Architectural Patterns
• Top-level directories reflect a classic Laravel MVC + layered architecture:
• app/Http/Controllers → HTTP entry points (MVC controllers for web & API)
• app/Livewire → reactive components for POS, table maps, profit projections
• app/Filament → admin panel Resources, Pages & Widgets
• app/Console/Commands → batch jobs & CLI operations (e.g., Sunat tests, data fixes)
• app/Events & app/Listeners → event-driven flows (e.g., UpdateCashRegisterTotals)
• app/Services → domain services (ReservationService, SunatService)
• app/Models → Eloquent ORM models for every business entity
• database/migrations & seeders → schema evolution and initial data
• Architectural patterns:
• MVC for HTTP requests
• Service Layer for domain logic
• Event-Listener for decoupled post-action processing
• Command Pattern for scheduled/CLI tasks
• Livewire for SPA-like interactivity without a JS framework
• Client Tier
• Browser / POS Terminal (loads public/index.php; runs Vue/Tailwind assets via Vite)
• Real-time UI via Livewire and Filament JS
• Web Server Tier
• Nginx/Apache → public/index.php → Laravel Kernel
• HTTP Controllers (app/Http/Controllers)
• Livewire Handlers (app/Livewire)
• Filament Admin Panel (app/Filament)
• Application Core
• Models (app/Models) interacting with the Database
• Services (app/Services) encapsulating business rules (e.g., SunatService, ReservationService)
• Events & Listeners for asynchronous domain reactions
• Background Processing
• Scheduler/Cron invoking artisan schedule:run → Console Commands
• Queue Worker (config/queue.php, using Redis or database) processing jobs dispatched by controllers or events
• Data & Storage
• Relational Database (MySQL/PostgreSQL) hosting all tables (users, orders, invoices, tables, products, etc.)
• File Storage (local or S3) for uploads and generated PDFs (invoice, comanda)
• Cache / Session backend (Redis or file)
• External Services
• SUNAT Electronic Invoicing API (app/Services/SunatService)
• SMTP / Mailer for notifications (config/mail.php)
• Optional WebSocket / Broadcasting (Echo, Pusher) for real-time updates
Relationships & Interactions
• Client → HTTP controllers → Service Layer → Eloquent → Database
• Controllers / Services dispatch Events → Listeners handle side effects (e.g., notifications, cash-register updates)
• Controllers & Events dispatch Jobs → queued into Redis / database → processed by Worker → call external APIs (SUNAT)
• Scheduler triggers Console Commands (e.g., CheckSunatConfig, GenerateTestInvoice) → reuse same Services/Events
• WebSocket broadcaster pushes real-time changes to browser (table status, new orders)
Architectural Patterns & Design Principles
• Single Responsibility: Controllers delegate business logic to Services
• Separation of Concerns:
• Presentation (Blade, Livewire, Filament)
• Domain Logic (Services, Models)
• Infrastructure (Database, Queue, External APIs)
• Event-Driven: decouple side-effects (Listeners for totals recalculation, notifications)
• Command Scheduler: periodic maintenance and SUNAT sync