How ridhsuki/book-api-laravel-flutter works
Project Type and Purpose
• This is a full-stack demo combining:
• A Laravel 11 RESTful API backend (“restapi-laravel” folder)
• A cross-platform Flutter client (“flutter_restapi” folder)
• Purpose: Perform CRUD operations on book data via HTTP/JSON.
File Structure
• Top level:
• flutter_restapi/ — Flutter client
• restapi-laravel/ — Laravel backend
• Flutter client uses the typical Flutter layout:
• lib/pages — UI pages (e.g., HomePage)
• lib/models — data classes (BookModel)
• lib/services — HTTP calls (BookService)
• lib/providers — state management (BookProvider)
• Laravel backend follows MVC:
• routes/api.php — API route definitions
• app/Http/Controllers/Api/BookController.php — request handling
• app/Models/Book.php, User.php — Eloquent models
• database/migrations / seeders — DB schema & dummy data
• public/index.php — API entry point
README for Additional Insights
• Confirms REST endpoints at /api/book
• Flutter configured to point at http://localhost:8000/api
• No authentication by default; simple CRUD demo
Main Components and Their Relationships
a. Frontend (Flutter App)
• UI Screens (HomePage)
• State Layer (BookProvider using Provider package)
• Service Layer (BookService making HTTP GET/POST/PUT/DELETE)
• Data Model (BookModel)
• Platform targets: Android, iOS, Web, Desktop
b. API Gateway (Laravel)
• Routes → BookController
• Middleware (e.g., JSON parsing)
c. Business Layer (Laravel)
• Controllers (BookController handles CRUD logic)
• Models (Eloquent ORM - Book.php)
d. Data Layer
• Relational Database (MySQL, SQLite, etc.)
• Migrations & Seeders for schema and sample data
e. External Services (optional extension)
• Could add caching (Redis), authentication (Sanctum), queue (Redis/Beanstalkd)
Architectural Patterns & Design Principles
• Frontend: MVVM-like separation (UI → Provider → Service → Model)
• Backend: MVC (Routes → Controller → Model → DB)
• API: RESTful principles (stateless, resource‐oriented)
• Dependency injection in services/providers
• Single source of truth for data via Provider