resources/js/.
Component architecture
Directory structure
Application setup
app.jsx
The main entry point that configures Inertia.js: Location:resources/js/app.jsx
- Automatically wraps all pages with
Layoutcomponent - Uses Vite’s
import.meta.globfor dynamic page imports - Configures progress bar color
- Sets page titles with “My diary” suffix
Layout components
Layout
The main application layout wrapper. Location:resources/js/Layout/Layout.jsx
- Conditionally renders
NavbarorSidebarbased on current page - Provides consistent background styling
- Includes developer tools in local environment
- Wraps all page content
Page components
Home.jsx
Landing page for unauthenticated users. Location:resources/js/Pages/Home/Home.jsx
Features:
- Marketing/welcome content
- Application description
- Entry point for new visitors
Main.jsx
Authenticated user dashboard. Location:resources/js/Pages/Home/Main.jsx
Features:
- Displays user’s diary entries
- Entry creation form
- Timeline view
Login.jsx & SingIn.jsx
Authentication pages. Location:resources/js/Pages/AuthPages/
Features:
- Form validation
- Inertia form handling
- Error display
- Redirect after authentication
Friends.jsx
Friend management interface. Location:resources/js/Pages/Friends/Friends.jsx
Features:
- Search users
- Send friend requests
- Accept/reject requests
- View friends list
Navigation components
Navbar
Top navigation bar for public pages. Location:resources/js/components/NavBar/Navbar.jsx
Sidebar
Side navigation for authenticated users. Location:resources/js/components/SideBar/Sidebar.jsx
- Icon-based navigation
- Conditional admin section
- User profile section
- Logout functionality
Content components
Entry
Diary entry card component. Location:resources/js/components/Entry/Entry.jsx
entry- Entry object with creator, body, images, and visibility
- Displays entry content and metadata
- Shows creator profile picture
- Conditional edit/delete buttons (owner only)
- Visibility indicator icon
- Formatted timestamps
- Attached image display
- Integration with update and delete modals
Form components
Input
Multi-purpose form input component. Location:resources/js/components/Input/Input.jsx
- Text input
- Textarea
- Select dropdown
- Checkbox
- Floating label animation
- Error state styling
- Auto-focus on label click
- Flexible width
- Required field validation
Button
Reusable button component with loading state. Location:resources/js/components/Button/Button.jsx
text- Button labelclassName- CSS class (default: ‘btn-normal’)loading- Show loader instead of textonclick- Click handlertype- Button type (submit, button)
btn-normal- Primary buttonbtn-disable- Secondary/cancel button
Modal components
ModalDelete
Confirmation modal for delete operations. Location:resources/js/components/Modals/ModalDelete.jsx
entity- Object being deleted (for ID)openModal- Boolean to show/hidetitle- Modal titlediv- HTML content to displayURL- Delete endpoint
ModalUpdateEntry
Modal for editing diary entries. Location:resources/js/components/Modals/ModalUpdateEntry.jsx
Features:
- Form pre-filled with entry data
- Inertia form handling
- Validation errors
- Image upload support
Utility components
Loader
Loading spinner component. Location:resources/js/components/Loader/Loader.jsx
Usage:
DropFile
Drag-and-drop file upload component. Location:resources/js/components/DropFile/DropFile.jsx
Features:
- Drag and drop interface
- File type validation
- Image preview
- Click to browse
Alert components
Success and error notification components. Locations:resources/js/components/alerts/AlertSuccess/AlertSuccess.jsxresources/js/components/alerts/AlertError/AlertError.jsx
Using Inertia.js hooks
usePage()
Access page props and metadata:useForm()
Manage form state and submission:Link
Client-side navigation:Styling approach
MyDiary uses a combination of:- Tailwind CSS 4.0 - Utility classes
- Component CSS files - Scoped styles in component directories
- CSS custom properties - Theme colors (via
colorConfiguration)
Props conventions
- camelCase for prop names
- Descriptive names (e.g.,
openModalnotopen) - Default values for optional props
- Type-specific prefixes (e.g.,
onchange,onclick)
Component best practices
- Keep components focused - Each component has a single responsibility
- Use Inertia helpers - Leverage
useForm,usePage, andLink - Destructure props - For cleaner code and documentation
- Co-locate styles - Keep CSS files with components
- Handle loading states - Use
processingfromuseForm - Show errors - Display validation errors from Inertia
Next steps
- Review the database schema
- Understand the architecture
- Set up your development environment