ddd-java

repository·master·Indexed 43 days ago

https://github.com/jkazama/ddd-java

A Spring Boot sample implementation of Domain-Driven Design (DDD) based on Eric Evans's principles. It provides a reference for structuring Java applications into UI, Application, and Domain layers, with the Infrastructure layer as a cross-cutting concern.

Tokens
889
Snippets
4
Records
5
Agent score
6%

What's inside ddd-java

  1. Understand the DDD Layering Model in ddd-java

    master

    This project is a sample implementation of Domain-Driven Design (DDD) based on Evans's principles, using Spring Boot. It follows a three-layer model where the Infrastructure layer is treated as a cross-cutting concern.

    • UI Layer: Handles public interactions and receives use case requests (implemented via RESTful endpoints).
    • Application Layer: Processes use cases and manages access to external resources.
    • Domain Layer: Contains pure domain logic and does not depend on external resources.
    • Infrastructure Layer: Manages the DI container, ORM, and various libraries.
  2. Start the server using VSCode DevContainer

    master

    To run the application in a containerized environment, ensure you have Docker and the VSCode DevContainer extension installed.

    1. Navigate to the cloned ddd-java directory.
    2. Run code . to open the directory in VSCode.
    3. Select Open Container when prompted.
    4. Open the Run And Debug view in VSCode.
    5. Choose Run ddd-java.
    6. Once the console displays Started Application, the server is running on port 8080.
    7. Verify the status by running: curl http://localhost:8080/actuator/health
    curl http://localhost:8080/actuator/health
  3. Start the server using Gradle (Console)

    master

    To run the application locally from a terminal, ensure you have JDK 21 or higher installed.

    1. Navigate to the cloned ddd-java directory.
    2. Execute the following command: ./gradlew bootRun --args='--spring.profiles.active=dev'
    3. Once the console shows Started Application, the server is running on port 8080.
    4. Verify the status by running: curl http://localhost:8080/actuator/health
    ./gradlew bootRun --args='--spring.profiles.active=dev'
  4. Test Batch Use Case APIs

    master

    The system includes batch jobs for processing business days and cash flows. Execute these in the appropriate business sequence.

    # Close withdrawal requests
    curl -X POST http://localhost:8080/system/job/daily/closingCashOut
    
    # Advance the business day to the next day
    curl -X POST http://localhost:8080/system/job/daily/processDay
    
    # Realize cash flow (Reflects to the balance on the delivery date)
    curl -X POST http://localhost:8080/system/job/daily/realizeCashflow
  5. Test Customer and Internal Use Case APIs

    master

    Once the server is running on port 8080, you can interact with the RESTful endpoints to test customer and administrative functionality.

    # Request a withdrawal
    curl -X POST -H "Content-Type: application/json" -d '{"accountId"  : "sample" , "currency" : "JPY", "absAmount": 1000}' http://localhost:8080/asset/cio/withdraw
    
    # Search for outstanding withdrawal requests
    curl 'http://localhost:8080/asset/cio/unprocessedOut'
    
    # Search for deposit and withdrawal requests (Admin)
    # Replace yyyy-MM-dd with actual dates
    curl 'http://localhost:8080/admin/asset/cio?updFromDay=yyyy-MM-dd&updToDay=yyyy-MM-dd'