How aziz-boujaada/pnematique_bousta_api works
Purpose and Consumers
Pneumatique Bousta is a Laravel 12 REST backend for a Flutter mobile client. It centralizes tire/article catalog data, stock by depot, dashboard statistics, user access, and administrative user operations. HTTP entry points are the Laravel front controller at public/index.php and API route definitions in routes/api.php.
HTTP API and Access Boundary
API controllers receive requests and return JSON, with authentication centered on Laravel Sanctum configuration in config/sanctum.php. Public authentication flows are handled by app/Http/Controllers/Api/AuthController.php; protected inventory, depot, and reporting endpoints are exposed through controllers under app/Http/Controllers/Api/. Administrative access is a separate authorization boundary implemented by app/Http/Middleware/AdminMiddleware.php.
Identity, Registration, and Recovery
User accounts are represented by app/Models/User.php, with registration/login input validation isolated in app/Http/Requests/RegisterRequest.php and app/Http/Requests/LoginRequest.php. Password recovery uses OTP records and service logic in app/Models/ResetPasswordOtp.php, app/Services/OTPService.php, and app/Http/Controllers/Api/ResetPasswordController.php. Email delivery is an external infrastructure dependency, configured through config/mail.php and rendered from resources/views/emails/.
Inventory Read Model
Articles, stock records, and depots form the core inventory domain: app/Models/Article.php, app/Models/Stock.php, and app/Models/Depot.php. Article list/search/filter operations flow from app/Http/Controllers/Api/ArticleController.php into app/Services/ArticleService.php. The service layer is the principal boundary for source-aware or multi-database inventory retrieval; clients may identify an article by reference plus source database.
Article Detail and Stock Aggregation
Detailed article retrieval is separated from listing in app/Services/ArticleDetailsService.php and returns article information plus stock distribution across depots. This stage joins/aggregates article, stock, and depot domain data before response formatting. Its API boundary is app/Http/Controllers/Api/ArticleController.php, while app/DTOs/ArticleDTO.php provides a stable client-facing article shape.
Depots and Dashboard Metrics
Depot discovery is a dedicated read path through app/Http/Controllers/Api/DepotController.php and app/Services/DepotService.php. Dashboard-oriented aggregates are isolated in app/Http/Controllers/Api/StatsController.php and app/Services/StatsService.php, keeping reporting calculations distinct from article browsing and detail queries.
Persistence and Runtime Infrastructure
Laravel bootstraps through bootstrap/app.php; dependency and provider wiring begins in app/Providers/AppServiceProvider.php. Database connectivity is deployment-configured in config/database.php and may target SQL Server, MySQL, PostgreSQL, or SQLite, including multiple inventory sources. Application-owned schema covers users, tokens, jobs/cache, and password OTPs under database/migrations/; asynchronous work is supported by config/queue.php. Sanctum personal access tokens are persisted via database/migrations/2026_07_06_152124_create_personal_access_tokens_table.php.
Response Contract Layer
Controllers delegate business work to services and use DTOs to prevent direct database-model exposure. app/DTOs/ArticleDTO.php and app/DTOs/UserDTO.php define consistent payload boundaries for the mobile client, including source-aware article identity and authenticated-user data.
Main entry points: api.php API routes · Article.php Article, stock, and depot · ArticleController.php Article API · ArticleService.php Article catalog service
Components 22
HTTP API
- Laravel front controller
public/index.php - API routes
routes/api.php - Article API · List, search, filter, and detail endpoints.
app/Http/Controllers/Api/ArticleController.php - Depot API
app/Http/Controllers/Api/DepotController.php - Stats API
app/Http/Controllers/Api/StatsController.php
Application Services
- Article catalog service · Source-aware inventory list and search retrieval.
app/Services/ArticleService.php - Article detail aggregation · Combines article data with stock distribution by depot.
app/Services/ArticleDetailsService.php - Depot service
app/Services/DepotService.php - Dashboard metrics service
app/Services/StatsService.php - Article, stock, and depot · Core catalog and per-depot stock read model.
app/Models/Article.php - Article response DTO · Stable source-aware article payload.
app/DTOs/ArticleDTO.php
Identity & Recovery
- Authentication API
app/Http/Controllers/Api/AuthController.php - Password recovery API
app/Http/Controllers/Api/ResetPasswordController.php - Sanctum and admin access · Sanctum protects API access; middleware gates administration.
config/sanctum.php - Registration and login validation
app/Http/Requests/RegisterRequest.php - User account
app/Models/User.php - OTP recovery service
app/Services/OTPService.php - Password OTP
app/Models/ResetPasswordOtp.php
Runtime & Infrastructure
- Laravel bootstrap and providers
bootstrap/app.php - Multi-source databases · Configured for SQL Server, MySQL, PostgreSQL, or SQLite inventory sources.
config/database.php - Email delivery · Recovery emails use configured mail transport and templates.
config/mail.php
Other components
- Flutter mobile client
Connections 28
- Flutter mobile client → Laravel front controller: JSON requests
- Laravel front controller → API routes: dispatches
- API routes → Sanctum and admin access: protected routes
- API routes → Article API: article endpoints
- API routes → Depot API: depot endpoints
- API routes → Stats API: dashboard endpoints
- API routes → Authentication API: public auth
- API routes → Password recovery API: recovery endpoints
- Sanctum and admin access → User account: authenticates
- Authentication API → Registration and login validation: validates
- Authentication API → User account: creates and signs in
- Password recovery API → OTP recovery service: uses
- OTP recovery service → Password OTP: stores and verifies
- OTP recovery service → Email delivery: sends OTP email
- Article API → Article catalog service: list and search
- Article API → Article detail aggregation: detail lookup
- Article catalog service → Article, stock, and depot: retrieves
- Article detail aggregation → Article, stock, and depot: aggregates
- Depot API → Depot service: discovers
- Depot service → Article, stock, and depot: reads depots
- Stats API → Dashboard metrics service: requests metrics
- Dashboard metrics service → Article, stock, and depot: aggregates
- Article catalog service → Article response DTO: maps payload
- Article detail aggregation → Article response DTO: maps payload
- Article, stock, and depot → Multi-source databases: queries
- User account → Multi-source databases: persists
- Password OTP → Multi-source databases: persists
- Laravel bootstrap and providers → API routes: boots application