How salamalicun/nutribox works
Project type and purpose
• This is a monolithic full-stack Single Page Application (SPA) called “Nutribox” for generating personalized diets.
• Backend: Laravel 12.3.0 (PHP 8.2) using an MVC pattern.
• Frontend: React 19.0.0 + TypeScript, styled with Tailwind CSS, routed via Inertia.js (no separate REST API).
• Database: SQLite (local file).
• External integrations: OpenFoodFacts, Deepseek (via PHP client), Pexels.
File structure
• Top‐level directories:
• nutribox/ ← application root
• public/ ← static assets and index.php
• resources/js/ ← React components, pages, layouts, hooks
• app/ ← Laravel controllers, middleware, console commands, models
• config/, routes/, database/, storage/, tests/ ← config, routing, migrations/seeders, file storage, automated tests
• .github/workflows/*.yml ← CI/CD (lint, tests, deploy)
Key architectural patterns and tech
• Monolith with Inertia.js bridging Laravel controllers ↔ React pages
• Laravel’s MVC on server:
• Models ↔ SQLite database (Eloquent ORM)
• Controllers handle HTTP/Inertia requests, orchestrate Models and return Inertia responses
• Blade template (app.blade.php) bootstraps React SPA
• React SPA: Vite bundler, React components, Inertia client, shadcn/ui + custom TS components
• CI/CD: GitHub Actions runs linting, tests, then deployment to VPS (Apache + PHP).
Main components and interactions
A. Client (Browser)
• Inertia.js adapter issues link clicks/Form submissions as XHR
• React Rendering Layer (resources/js)
B. Web Server
• Apache (or PHP-FPM behind Apache)
• Laravel Application
• HTTP Kernel → Middleware → Controllers
• Controllers interact with Models and Services
• Return Inertia responses (JSON + page props)
C. Database
• SQLite file (database/database.sqlite) accessed by Eloquent Models
D. External Services
• OpenFoodFacts API (nutritional data lookup)
• Deepseek API (AI-powered suggestions via deepseek-php-client)
• Pexels API (image sourcing)
E. Static Assets & Build
• Vite builds React app → assets in public/js, public/css
• Tailwind CSS config (tailwind.config.js)
F. CI/CD Pipeline
• GitHub Actions:
1. Lint (eslint, PHP_CodeSniffer)
2. Tests (PHPUnit, Pest, Playwright e2e)
3. Deploy (SSH/FTP to VPS)
• Component names and responsibilities (e.g., MenusController, Comida model)
• Data flows with arrowheads (e.g., “Search product → OpenFoodFacts API → JSON response”)
• Configuration files or build tools (Vite, Composer, NPM scripts) as side annotations
• CI/CD steps linking GitHub repo to production VPS