> For the complete documentation index, see [llms.txt](https://admincode.gitbook.io/admincode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://admincode.gitbook.io/admincode/basics/newpage/step-4-creating-the-dto.md).

# Step 4: Creating the DTO

The service layer and Data Transfer Object (DTO) work together to streamline the communication between different layers in an application. The service layer encapsulates business logic and acts as an intermediary between the presentation and lower data access layers. It processes requests, applies business rules, and manages data flow. The DTO, on the other hand, is a lightweight object designed to transfer data between these layers. It helps decouple the internal domain model from external representations, allowing for more efficient data transfer and reducing unnecessary dependencies. By using DTOs, the service layer can return only the required data, optimizing performance and enhancing security by limiting exposure to sensitive internal structures.

```java
package com.rce.dto;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.rce.model.ArticleTypeEnum;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ArticleDTO extends BaseDTO { 

	private static final long serialVersionUID = 1L;

	private String title;	
	private String category;
	private String summary;
	private AuthorDTO author;
	private List<CitationDTO> citations;
	private List<ArticleCommentDTO> comments;
	private ArticleTypeEnum type;
	private List<ArticleTypeDTO> types;
	

	/***
	 *  Use [@JsonManagedReference] this annotation to 
	 *  break the infinite loop when deserializing to json
	 *  For bi-directional object relations
	 */
	@JsonManagedReference
	public List<ArticleCommentDTO> getComments() {
		return comments;
	}
	public void setComments(List<ArticleCommentDTO> comments) {
		this.comments = comments;
	}		
}  
```
