How keroles19/wthq-users-products works
Project Type and Purpose
• This is a monolithic full-stack web application built with Laravel.
• Purpose: Provide a products catalog with role-based access (admin vs. user types), RESTful API endpoints, and a simple Blade/Vite-based frontend.
Top-Level Architecture Components
a. Client Layer
• Web Browser (Blade + Vite assets)
• API Consumer (Postman or any HTTP client)
b. Edge Routing & HTTP
• Nginx (reverse proxy, serves static assets, forwards PHP requests)
• Docker network (docker-compose orchestrates nginx, php-fpm/app, mysql)
c. Application Layer (Laravel)
• HTTP Kernel → Middleware (authentication, CSRF, validation)
• Routes (routes/web.php for UI; routes/api.php for JSON API)
• Controllers (AuthController, ProductController, UserController)
• Request Validation (FormRequest classes under app/Http/Requests)
• Service Layer (RepositoryServiceProvider binds interfaces to implementations)
• Repositories (implements contracts for Authentication, Product, User)
• Models & Observers (Eloquent models, ProductObserver)
• Resources (API Resource wrappers for Users and Products)
d. Data Layer
• MySQL (running in docker/mysql)
• Migrations, Factories, Seeders
• Storage (public/uploads for images, managed by Filesystem config)
Interactions & Data Flow
1) Client issues HTTP request (browser or API client).
2) Nginx routes to Laravel’s public/index.php.
3) HTTP Kernel applies global and route middleware.
4) Router dispatches to Controller method.
5) Controller delegates to Repository (via interface) for business operations.
6) Repository uses Eloquent model to query/update MySQL.
7) Observer may react to model events (e.g., emailing on product create).
8) Controller returns Blade view or JSON (wrapped in Resource).
9) Response travels back through middleware → client.
Architectural Patterns & Design Principles
• MVC (Model-View-Controller)
• Repository Pattern (app/Contract + app/Repositories)
• Dependency Injection (via Service Providers)
• RESTful API design for /api/* routes
• Validation-as-first-class (FormRequest classes)
• Containerized deployment (Docker & docker-compose)