Technology stack
Backend
- Laravel 12.0 - PHP framework for web applications
- PHP 8.2+ - Server-side programming language
- MySQL - Relational database management system
- Inertia.js Laravel Adapter - Server-side adapter for Inertia.js
Frontend
- React 19.0 - JavaScript library for building user interfaces
- Inertia.js React Adapter - Client-side adapter for Inertia.js
- Tailwind CSS 4.0 - Utility-first CSS framework
- Vite 6.0 - Frontend build tool and dev server
- Hugeicons React - Icon library for UI elements
Development tools
- Laravel Pail - Real-time log viewer
- Laravel Pint - PHP code style formatter
- Laravel Sail - Docker development environment
- Concurrently - Run multiple npm commands concurrently
- Axios - HTTP client for API requests
Architecture overview
Monolithic SPA architecture
MyDiary uses a monolithic Single Page Application (SPA) architecture powered by Inertia.js:What is Inertia.js?
Inertia.js allows you to build SPAs without building an API. It works by:- Laravel controllers return Inertia responses instead of views
- Inertia sends JSON data to the frontend
- React components render the data without page reloads
- Form submissions and navigation use Inertia’s client-side routing
Directory structure
Backend structure
Frontend structure
Core concepts
Server-side rendering flow
- User navigates to a route (e.g.,
/Home) - Laravel router matches the route in
routes/web.php - Controller method handles the request
- Controller returns Inertia response with data
- Inertia sends page component and props to React
- React renders the component with the provided data
Client-side navigation
Form handling
Route helper (Ziggy)
Ziggy provides JavaScript access to Laravel named routes:Authentication flow
- User submits login form via
Login.jsx - Inertia posts to
UserController@login - Laravel authenticates user and creates session
- User is redirected to authenticated area
- Middleware protects authenticated routes
Authentication middleware
Routes inroutes/web.php use Laravel’s auth middleware:
Data flow example
Here’s how creating a diary entry works:- User fills form in React component
- Component uses
useForm()hook from Inertia - Form posts to
/Entryroute EntryController@createhandles the request- Controller validates and saves to database
- Controller returns Inertia response
- React component updates without page reload
Asset compilation
Vite compiles frontend assets defined invite.config.js:
Development mode
Production build
Queue system
MyDiary uses Laravel’s queue system with database driver:- Queue connection:
database(configured in.env) - Jobs table:
jobs - Failed jobs table:
failed_jobs
Session management
- Driver:
database(configured in.env) - Sessions table:
sessions - Lifetime: 120 minutes
- Tracks: user_id, IP address, user agent
File storage
Uploaded files (profile pictures, entry images) are stored in:- Storage path:
storage/app/public/ - Public symlink:
public/storage/ - Access via:
/storage/path/to/file.jpg
API structure
MyDiary currently doesn’t expose a separate REST API. All interactions use Inertia.js protocol, which provides:- Automatic CSRF protection
- Session-based authentication
- JSON responses for AJAX requests
- Traditional form submissions fallback
Performance considerations
- Eager loading: Use Eloquent eager loading to prevent N+1 queries
- Caching: Database cache driver configured
- Asset optimization: Vite bundles and minifies assets
- Database indexing: Foreign keys and commonly queried fields
Security features
- CSRF protection: Built into Laravel forms and Inertia
- Password hashing: Bcrypt with configurable rounds
- SQL injection prevention: Eloquent ORM parameterized queries
- XSS protection: React escapes output by default
- Session security: HTTP-only cookies, secure connections
Next steps
- Explore the database schema
- Learn about frontend components
- Review developer setup guide