How yusuke-takatsu/share-money-api-server works
Main Components/Boundaries
• Docker Containers:
– “.docker/local/mysql”: Represents the MySQL container used as the database.
– “.docker/local/nginx”: Represents the NGINX container acting as the reverse proxy/load balancer and serving static files.
– “.docker/local/php”: Represents the container running the Laravel application (PHP-FPM).
• Laravel Application:
The “app” directory houses all of the core Laravel application code. This includes:
– The HTTP layer (Controllers, Middleware, Routes defined in “routes/api.php”, “routes/web.php”, etc.).
– Application services, repositories (in “app/Services” and “app/Repositories”), and business logic (e.g., Builders, Enums, Exceptions).
• Database:
The “database” directory along with migration and seeder files represents the persistence layer using MySQL.
Internal Sub-Components of the Laravel App
• Routing and Request Handling:
– “routes” folder: Contains API endpoints and web routes.
– “app/Http/Controllers”: Implements the actual endpoints tying routes to business logic.
– “app/Http/Middleware”: Manages request pre-processing (authentication, CSRF, etc.).
• Business Logic & Domain Modeling:
– “app/Models”: Eloquent models (e.g., User and Profile) represent our domain entities.
– “app/Services” and “app/Repositories”: Encapsulate business logic and data access.
– “app/Builders”, “app/Enums”, and “app/Exceptions”: These reflect custom domain logic, specialized exception handling, and the pattern for modifying model instances.
• Data Transfer & Validation:
– “app/Http/Actions/DataTransferObjects”: Structures data for actions.
– “app/Http/Requests”: Manages validation logic for incoming API requests.
• Infrastructure & Configuration:
– “config” directory: Contains configuration files for the application.
– “public”: Serves as the document root accessible by end users.
– “resources”: Manages static assets and views (in this case, mainly used for a welcome page).
Relationships and Data Flow
• NGINX forwards relevant dynamic requests to the PHP container (where Laravel runs):
• Laravel Application Flow:
– Routes parse the HTTP request (as defined in the “routes” files).
– Requests are processed through middleware, reaching Controllers in “app/Http/Controllers”.
– Controllers call down into services, repositories, builders, and models to process business logic.
• Database Interaction:
• Exception Handling & Responses:
– Capture the request/response cycle including custom exceptions (from “app/Exceptions”) that eventually send responses back to the client.
Architectural Patterns and Principles
• MVC Pattern: Emphasize the separation of concerns (Controllers, Models, Views/Resources).
• Containerization: Note the clear separation between web server (NGINX), application logic (PHP/Laravel), and persistence (MySQL).
• Layered/Hexagonal Approach: Indicate common layers such as HTTP handling, business logic (services and repositories), and persistence.
• Extensibility: The usage of Service Providers (in “app/Providers”) and Repositories shows adherence to dependency injection and interface-driven design.
Relevant Technologies, Frameworks, and Tools
• Laravel Framework (with its MVC architecture, routing, middleware).
• PHP 8.2.
• Docker for containerization (using separate Dockerfiles for MySQL, NGINX, PHP).
• MySQL as the database.
• NGINX acts as the reverse proxy.
• Additional tools such as Makefile commands and GitHub Actions (in “.github/workflows”) for CI/CD.
• Testing is handled in the “tests” directory (both Feature and Unit tests).