How nomura-kainos/japanese-ddd-sample works
Project Type and Purpose
• This project is a Laravel-based application that uses Docker to set up its development environment. It is designed to run a full-stack Laravel application with a well‐structured, domain-driven approach using packages for features such as cart management, product handling, order processing, etc.
a. Docker Infrastructure:
– Containers/Services: PHP (the Laravel runtime environment), MySQL (database server), and nginx (web server).
– Configuration files: docker-compose.yml, docker folder (with Dockerfiles and configurations for db, nginx, and php).
b. Laravel Application (src folder):
– Core Application Layers:
• App – contains the Laravel “app” code (controllers, middleware, providers, etc.).
• Config, Database (migrations and seeds), Resources (views, assets, translations) and Public folder.
c. Domain/Module Packages (inside src/packages):
– Separate modules implementing domain logic via a domain-driven design. For example:
• Cart
• Product
• Product Category
• Order
• Featured (特集)
• Authentication (認証)
– Each package typically splits into layers:
• Application (ユースケース)
• Infrastructure (エロクアント, レスポンスデータ, リポジトリ)
• Domain (モデル and interfaces)
• Presentation (コントローラ, ビューモデル, フォームリクエスト)
Relationships and Interactions
• The Docker containers work together to host and run the Laravel application. The nginx container acts as the entry point (frontend web server) that passes requests to the PHP container, which in turn interacts with the MySQL container for persistent storage.
• Inside the Laravel app, HTTP requests pass through middleware and controllers (located under src/app/Http and in each package’s presentation layer). These controllers invoke use cases (アプリ/ユースケース in each domain package) that interact with domain models and repository interfaces.
• The infrastructure layer in each package implements data persistence (using Eloquent models under エロクアント, repository classes, and query services) and external services such as email and file uploads.
• The common “packages/共通” cover shared functionalities (such as ID generation, transaction management, domain events, and login user handling).
Architectural Patterns and Design Principles
• Domain-Driven Design: The separation into packages based on bounded contexts (Cart, Product, etc.) with clear divisions into application, domain, infrastructure, and presentation layers.
• MVC: The classic separation of controllers (HTTP layer), models (domain and Eloquent), and views (Blade templates under resources/views).
• Docker Microservices (development environment): Leveraging Docker Compose to orchestrate multiple services running in separate containers.
• Dependency Injection and Service Providers: Laravel providers (in src/app/Providers) are used to register services and bind interfaces to their implementations (such as repository interfaces).
• Component has a clear and descriptive label.
– Client → nginx → PHP container → Laravel controllers → Domain Use Cases → Database (MySQL) via repository interfaces.