How jahidul2018/laravel-nextjs-breeze-api works
Main Components
A. Frontend Layer (Next.js):
• Authentication Pages (Login, Register)
• Protected Routes
• API Integration Layer
B. Backend Layer (Laravel):
• API Controllers (Auth Controllers)
• Middleware Layer
• Service Providers
• Models
• Database Layer
[Client Browser]
• ↕
[Next.js Frontend (Port 3000)]
• ↕
• [Sanctum]
• ↕
[Laravel Backend (Port 8000)]
• ↕
[Database (MySQL)]
Component Details
Frontend (Next.js):
• Sub-components:
• Authentication Pages
• API Client
• State Management
• Protected Routes
API Layer:
• CORS middleware
• API endpoints:
• /api/auth/*
• /api/user
• Other protected routes
Backend (Laravel):
• HTTP Kernel (Middleware Pipeline)
• Auth Controllers
• Models (User)
• Service Providers
• Database Layer
Important Flows to Highlight
Authentication Flow:
Client → Login Request → Sanctum → Laravel Auth → Database
↑ ↓
Token Response ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←
Protected Route Flow:
Client → Protected Request + Token → Sanctum Verification → Resource
Additional Elements
• Configuration files locations:
• .env files (both frontend and backend)
• config/*.php files
• middleware configurations
• Storage components:
• Session storage
• Cache storage
• File storage