Updated for Fall 2026
This page describes the current backend design of CoffeeMaker — the static structure, the flow of control, and the REST API. It is reference material you will come back to in Milestones 2 through 6.
A copy of this page lives in your repository at technical-documents/backend-design.md. See Milestone 2 for how to put it there. When your design changes, update the copy in your repository. This page describes the starting point before Milestone 2 and will not change.
Static Design - Current Class Diagram
The class diagram below describes the static structure of the CoffeeMaker system:

There are nine total packages in the project; six of which are shown in the class diagram:
edu.ncsu.csc326.coffee_maker.entity: contains the Entity classes that correspond to major objects in the system and are connected to the database. These are Data Access Objects (DAOs).edu.ncsu.csc326.coffee_maker.repositories: contains Repository interfaces that handle database CRUD operations. These interfaces extendJpaRepository.edu.ncsu.csc326.coffee_maker.services: contains the Service interfaces and define key business logic of the system.edu.ncsu.csc326.coffee_maker.services.impl: contains implementations of the Service interfaces.edu.ncsu.csc326.coffee_maker.controllers: contains API endpoints.edu.ncsu.csc326.coffee_maker.dto: contains Data Transfer Objects (DTOs) for use by the Services and Controllers.
The packages not included in the diagram are:
edu.ncsu.csc326.coffee_maker: contains theCoffeeMakerApplicationclass that gets the application started.edu.ncsu.csc326.coffee_maker.exception: contains custom exceptions for the project.edu.ncsu.csc326.coffee_maker.mapper: contains classes that map between Entities and DTOs.
Entity
Inside the entity package, we have all persistent entities. These classes exist just to store data, and all functionality is located in other classes.
Both the Recipe and Inventory classes are annotated with @Entity, which tells Spring that these should be persisted to the database. Consequently, each will have a corresponding database table (or tables when considering composition relationships) for storing data.
Repositories
Inside the repositories package, we have two different interfaces: InventoryRepository and RecipeRepository. Since these interfaces extend the JpaRepository, they provide all the functionality that we need for how to persist the entities. The generic parameters on JpaRepository tell us that the repository works with an entity and that the primary key is identified by a Long. We can add additional behaviors by defining methods like the one in RecipeRepository. Methods that follow specific naming conventions (described in the documentation) are automatically implemented through the Spring libraries.
Services
The services package holds the business logic of the system. The interfaces define the key behaviors and they are implemented in the corresponding *Impl class in the services.impl package. Each service class has (an) instance(s) of the appropriate Repository(s) that provides support for interacting with the database.
Controller
An API (or Application Programming Interface) defines a specification for how to communicate with a computer program or subset thereof and a REST API is a subtype of API that is geared towards Internet-facing systems. REST APIs typically allow (often with some sort of authentication) manipulation of the various types of entities (recipes, inventory, etc) that a web application revolves around.
In CoffeeMaker, we are also using REST APIs to form a connection between the client (frontend) and server (backend). The APIs are all located inside the controller classes in the controllers package. Every action in the frontend that needs to work with the backend should have an API endpoint inside these controllers. Please refer to the classes’ JavaDoc to know more about the behavior of each class.
Adding New Persistence Classes
To add a new persistence class to CoffeeMaker, you’ll need to add the following:
- Entity version of the persistence class.
*RepositoryInterface*ServiceInterface*ServiceImplClass that implements*ServiceInterface*ControllerClass with appropriate end points*DtoClass that provides Data Transfer Object version of the Entity.
Adding Behaviors
You can also add behaviors that aren’t directly tied to an entity. An example of this is the Make Recipe functionality. You would add the following:
*ServiceInterface*ServiceImplClass that implements*ServiceInterface*ControllerClass with appropriate end points
Dynamic Design - Sequence Diagram
Sequence diagrams help us understand the flow of control in a complex system around a specific scenario. We can also use them to better understand the flow of control when dependency injection is used; we can model what methods will end up calling other methods through dependency injection. By modeling the flow of control, we can understand what portions of the backend will be used by REST API calls.
For sequence diagrams modeling the backend of a web system, the starting point is the call to a specific REST API endpoint. For example, if the REST API call is POST /makerecipe/coffee, the flow of control would transfer to the MakeRecipeController.makeRecipe() method and the attached JSON would be the amount paid for the recipe in the API call. From there, the flow of control for successfully making a recipe would be:
- Get the recipe by name
- Get the inventory (if the inventory hasn’t been initialized yet, initialize it)
- Make the recipe if there’s enough inventory and return the change.

End Point Design - REST API
Developers need to document the application’s API endpoints because the API documents are the primary resources that explain what operations are possible in your system. It also serves as a reference for developers to return to with questions about syntax or functionality of each endpoint.
GET Routes
GET routes are used to fetch data from the API, and as such, we care about seeing a description of the API endpoint and the data that is returned from the API.
GET Example
Request: GET /recipes/{name}
Name of function: RecipeController.getRecipe(String name)
Brief Description: This API endpoint will return a recipe with the name provided, or an error (404/Not Found) if a recipe with the provided name cannot be found.
Path Parameters
name: recipe’s name (required)
HTTP Response Status Codes
| Status Code | Description |
|---|---|
200 |
OK |
404 |
Resource not found |
Response
Status: 200
{ // start of Recipe object
'name': 'Mocha',
'price': 10,
'sugar': 2,
'milk': 3,
'coffee': 5,
'chocolate': 3
}
Status: 404
PUT/POST Routes
PUT and POST routes are used to send data to the API, and as such we particularly care about a description of the API endpoint and the data that is sent to the API. These routes should also show the data that is returned from the API, particularly if it’s different than what was provided as part of the request.
PUT Example
Request: PUT /inventory/
Note that since the Inventory is managed as a Singleton (there’s only one copy of it) we don’t need to specify a name or ID of the inventory as part of the URL. This is somewhat unusual — usually PUT routes take an ID as part of the URL.
Name of function: InventoryController.updateInventory(InventoryDto inventoryDto)
Brief Description: This API endpoint provides access to the CoffeeMaker’s Inventory, updating it with the new values provided. Rather than overwriting the Inventory with the values that are provided, instead all new values are added to the ones already stored.
Body Parameters
inventoryDto: Inventory object
{ // start of Inventory object
// note that there's no ID here. For this purpose,
// it doesn't matter either way since it is the _quantity_
// provided that is added to the existing values. To
// update objects that are not managed as a Singleton,
// the `id` would be here too.
'sugar': 2,
'milk': 2,
'coffee': 3,
'chocolate': 4
}
HTTP Response Status Codes
| Status Code | Description |
|---|---|
200 |
OK |
Response
Status: 200
{
'id': 1,
'sugar': 2,
'milk': 2,
'coffee': 3,
'chocolate': 4
}
Documenting Your Own Design
When you extend this backend design in Milestone 2, document it in your repository using the same three views:
- Static design — a class diagram plus a text description of what you changed and why.
- Dynamic design — a sequence diagram for one scenario, the scenario description, and why the design supports it.
- End point design — for each new or changed endpoint: the name of the function, the relative URL, the HTTP verb, a brief description, the input and output data, and the response status codes.
Diagrams may be drawn in UMLetino and exported as images and structured text, or written directly in Mermaid, which GitHub renders inside a markdown file.
