This project aims to develop restful endpoints about start wars entities provided by swapi while applying principles of Domain Driven Design.
This project is written in java8 under spring-boot web framework using futures to complete tasks in a asynchronous way.
In this project you'll see the following in action:
- Domain Driven Design: Onion Architecture with Ports and Adapters
- API Rest
- Spring Boot
- Java 8 : Functional Interfaces, Lambda & Optional
- Asynchronism with Completable Futures
- Unit Test: MockMvc
Main requirements of this projects are:
- Develop user stories
- DDD framework to design the software
- SOLID principles is a must
- Data will never be stored, so avoid usage of persistence mechanisms is a must
AS A Star Wars fan
I WANT to see the information about PEOPLE and STARSHIPS being able to sort the information and search by too
SO THAT I can have fun searching about Star Wars information.
- Web application to display information from SWAPI (https://swapi.co/).
- The Web application should read and display information in a web browser, from the API endpoints:
- people
- starships
- The Web application should allow to sort the data by "name" and "created" fields, in descending and ascending order both cases.
- The mechanism for sorting should be designed following the "Open-closed" principle.
- Visualize the data using
json
format.
After run the server, please click on the following links to check if result is what expected
- Sort by name asc: http://localhost:8080/people?sort=%2Bname
- Sort by name desc: http://localhost:8080/people?sort=-name
- Sort by created asc: http://localhost:8080/people?sort=-created
- Sort by created desc: http://localhost:8080/people?sort=%2Bcreated
This web service is designed under DDD paradigm. Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and terminology for making design decisions that focus and accelerate software projects dealing with complicated domains.
The layers are a logical artifact, and are not related to the deployment of the service. They exist to help developers manage the complexity in the code.
You want to design the system so that each layer communicates only with certain other layers.
Please take a look into following image to have a global vision of how the framework addresses layer design
Responsible for representing concepts of the business, information about the business situation, and business rules. State that reflects the business situation is controlled and used here, even though the technical details of storing it are delegated to the infrastructure. This layer is the heart of business software.
Defines the jobs the software is supposed to do and directs the expressive domain objects to work out problems. The tasks this layer is responsible for are meaningful to the business or necessary for interaction with the application layers of other systems. This layer is kept thin. It does not contain business rules or knowledge, but only coordinates tasks and delegates work to collaborations of domain objects in the next layer down. It does not have state reflecting the business situation, but it can have state that reflects the progress of a task for the user or the program.
That is how the data that is initially held in domain entities (in memory) is persisted in databases or another persistent store.
In accordance with Persistence and Infrastructure Ignorance principles, the infrastructure layer must not “contaminate” the domain model layer. You must keep the domain model entity classes agnostic from the infrastructure that you use to persist data (EF or any other framework) by not taking hard dependencies on frameworks.
nouns found while domain analisys are:
- People
- Startship
which they reflect the model of the services
This section is in charge of the definition of the functionalities represented as endpoints
- /people: endpoint to get all people. It defines one mandatory param
sort
that can take the following values: {+name
,-name
,+created
,-created
}
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Clone the repository:
$ git clone https://github.com/javigs82/ddd-startwars-api.git
If this is your first time using Github, review http://help.github.com to learn the basics.
What things you need to install the software and how to install them
- JDK 1.8
- Gradle
- Maven
A step by step series of examples that tell you have to get a development env running
gradle clean build
Explain how to run the automated tests for this system
gradle test
Add additional notes about how to deploy this on a live system
java -jar build/libs/startwars-api-1.0.0-SNAPSHOT.jar
with an expected output like:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
...
...
...
2019-03-10 16:26:54.996 INFO 27752 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-03-10 16:26:55.003 INFO 27752 --- [ main] m.j.startwars.SpringApplicationBuilder : Started SpringApplicationBuilder i
- javigs82 github
This project is licensed under the MIT License - see the LICENSE.md file for details