The Recipe Management System API with AWS is a Spring Boot-based system that empowers users to efficiently manage recipes. It provides a set of RESTful API endpoints for creating, updating, and categorizing recipes, and allows users to leave comments on their favorite recipes. This README provides an overview of the system, the technologies used, and details on the User and Comment functionalities.
- Framework: Spring Boot
- Language: Java
- Database: MySQL
- Build Tool: Maven
- Database: MySQL (Hosted on AWS EC2)
- Continuous Integration: GitHub Actions
- API Documentation: SpringDoc OpenAPI (Swagger UI)
Our application utilizes an AWS EC2 instance to host the MySQL database. This instance is responsible for securely storing and managing recipe data, user information, comments, and other related data. It allows for scalable and reliable database access while ensuring data security and performance.
We have implemented a robust continuous integration (CI) workflow using GitHub Actions. With every code push to our repository, GitHub Actions automatically builds and tests our application to ensure code quality and reliability. This helps us maintain a stable and error-free application.
The project leverages various dependencies to achieve its functionality:
-
Spring Boot Starter Data JPA: Simplifies database access using Spring Data repositories.
-
Spring Boot Starter Web: Provides support for building web applications, including RESTful APIs.
-
MySQL Connector/J (Runtime Dependency): The MySQL JDBC driver for connecting to MySQL databases.
-
Project Lombok (Optional): A library for reducing boilerplate code, such as getters and setters.
-
Spring Boot Starter Test (For Testing): Provides support for testing Spring Boot applications.
-
Springdoc OpenAPI (Swagger UI): Adds Swagger UI for documenting and testing API endpoints.
-
Thymeleaf (Optional): A templating engine used for generating dynamic HTML reports.
-
Other Dependencies: Various other dependencies are included in the
pom.xml
file for specific functionalities, such as Jackson for JSON serialization, Spring Web for web-related features, and more.
For a comprehensive list of all dependencies and their versions, please refer to the project's pom.xml
file.
Certainly, here's an overview of the data flow in the Recipe Management System API with AWS:
The Recipe Management System API follows a structured data flow for creating, updating, and categorizing recipes, as well as allowing users to add comments. This data flow illustrates how users can interact with the application and manage data effectively:
-
Recipe Management:
-
A user creates a new recipe by sending a
POST
request to the/api/recipes
endpoint, providing details such as the recipe's title, description, and category. -
The system validates the request, creates the recipe entity, and associates it with the user who created it and the selected category.
-
The new recipe is saved in the database.
-
The system responds with a confirmation message, indicating the successful creation of the recipe.
-
Users can also update or delete their recipes by sending
PUT
orDELETE
requests to the/api/recipes/{recipeId}
endpoint. -
The system checks if the provided recipe exists and is associated with the user.
-
If the recipe is valid, it is updated or deleted from the database, and the system sends a response confirming the update or deletion.
-
-
Category Management:
-
Users can create and manage recipe categories through API endpoints, such as creating a new category with a
POST
request to/api/categories
. -
The system manages recipe categories and their associations with recipes.
-
-
Comment Management:
-
Users can leave comments on their favorite recipes by sending a
POST
request to the/api/comments
endpoint, specifying the comment text and the recipe to which it belongs. -
The system validates the request, creates the comment entity, and associates it with the user who made the comment and the selected recipe.
-
The new comment is saved in the database, and the system responds with a confirmation message.
-
Users can also update or delete their comments by sending
PUT
orDELETE
requests to the/api/comments/{commentId}
endpoint. -
The system checks if the provided comment exists and is associated with the user.
-
If the comment is valid, it is updated or deleted from the database, and the system sends a response confirming the update or deletion.
-
-
User Authentication and Authorization:
-
User authentication and authorization are handled securely to ensure that only authorized users can create, update, delete, and comment on recipes.
-
The system manages user accounts and ensures that user data is protected.
-
-
Data Persistence:
- The application relies on a MySQL database for data storage. Entities such as recipes, users, comments, categories, and others are mapped to their corresponding database tables.
-
RESTful API Endpoints:
- RESTful API endpoints provide a clear interface for users to interact with the application. These endpoints are documented using Swagger UI, providing a user-friendly way to explore and use the API.
-
Database Design:
- The database design includes tables for recipes, users, comments, categories, and other entities, ensuring a structured and efficient data storage approach.
This data flow illustrates how users can interact with the Recipe Management System API to manage recipes, categories, and comments effectively. It ensures a seamless experience for users and maintains data integrity and security throughout the process.
In addition to recipe management, this system allows users to interact with recipes by adding comments and provides user management functionality. Here are the details of User and Comment functionalities:
The User table stores information about users of the Recipe Management System.
User Table Fields:
Column Name | Data Type | Description |
---|---|---|
userId | INT | Unique identifier for users |
username | VARCHAR(255) | User's username |
password | VARCHAR(255) | Encrypted user password |
User Data Structures:
The User entity represents a user in the system.
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userId;
@Column(unique = true)
private String username;
private String password;
// Constructors, getters, setters, and other methods
}
The UserRepository is a repository interface for managing User entities.
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByUsername(String username);
}
The Comment table stores comments associated with recipes in the Recipe Management System.
Comment Table Fields:
Column Name | Data Type | Description |
---|---|---|
commentId | INT | Unique identifier for comments |
text | TEXT | The text of the comment |
user_userId | INT | Foreign key referencing the user who made the comment |
recipe_recipeId | INT | Foreign key referencing the recipe to which the comment is related |
Comment Data Structures:
The Comment entity represents a comment in the system.
@Entity
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long commentId;
@Lob
private String text;
@ManyToOne
@JoinColumn(name = "user_userId")
private User user;
@ManyToOne
@JoinColumn(name = "recipe_recipeId")
private Recipe recipe;
// Constructors, getters, setters, and other methods
}
The CommentRepository is a repository interface for managing Comment entities.
@Repository
public interface CommentRepository extends JpaRepository<Comment, Long> {
List<Comment> findByRecipe(Recipe recipe);
}
With these additions, you can now manage users and comments in your Recipe Management System. The User entity represents users, and the Comment entity represents comments, and you can use the UserRepository and CommentRepository to perform database operations on these entities.
The project follows a structured and organized architecture:
-
Main Application Class: The entry point for the application is defined in the main class.
-
Entities: The application includes entities such as
Recipe
,User
,Comment
, and
others to model the data.
-
Repository Interfaces: Spring Data JPA repository interfaces manage data access for recipes, users, and comments.
-
Service Classes: Business logic is implemented in service classes for managing recipes, users, and comments.
-
Controller Classes: These classes define and document RESTful API endpoints for creating, updating, categorizing, and commenting on recipes.
-
Data Flow: The Recipe Management System follows a structured data flow for managing recipes and allowing user interactions, including adding comments and user management.
This data flow illustrates how users can interact with the application, manage recipes, add comments, and manage user accounts.
The application provides RESTful API endpoints for various functionalities:
- Create Recipe:
POST /api/recipes
- Update Recipe:
PUT /api/recipes/{recipeId}
- Delete Recipe:
DELETE /api/recipes/{recipeId}
- Create Category:
POST /api/categories
- Update Category:
PUT /api/categories/{categoryId}
- Delete Category:
DELETE /api/categories/{categoryId}
- Create Comment:
POST /api/comments
- Update Comment:
PUT /api/comments/{commentId}
- Delete Comment:
DELETE /api/comments/{commentId}
- Get Comments for Recipe:
GET /api/comments/recipe/{recipeId}
The API endpoints are documented, adhering to REST principles, and provide the core features of the Recipe Management System.
The application uses a relational database to store data, including recipes, user information, comments, categories, and more. Key attributes and tables include:
Column Name | Data Type | Description |
---|---|---|
recipeId | INT | Unique identifier for recipes |
title | VARCHAR(255) | Title of the recipe |
description | TEXT | Description of the recipe |
user_userId | INT | Foreign key referencing the user who created the recipe |
category_categoryId | INT | Foreign key referencing the category of the recipe |
Column Name | Data Type | Description |
---|---|---|
categoryId | INT | Unique identifier for categories |
name | VARCHAR(255) | Category name |
recipes | One-to-Many | Recipes associated with the category |
The Recipe and Category tables are part of the core functionality for recipe management and categorization.
For detailed information on the User and Comment tables, please refer to the "User Table" and "Comment Table" sections in the README.
-
Entities:
-
Recipe: Represents a recipe with attributes like
recipeId
,title
,description
, a reference to the associateduser
, and a reference to thecategory
. -
User: Represents a user with attributes like
userId
,username
,password
, and a collection ofrecipes
. -
Comment: Represents a comment with attributes like
commentId
,text
, a reference to theuser
who made the comment, and a reference to therecipe
to which the comment is related. -
Category: Represents a category with attributes like
categoryId
,name
, and a collection ofrecipes
.
-
-
Repositories:
- JPA repositories for data access, including repositories for recipes, users, comments, categories, and other related entities.
-
ArrayLists:
- ArrayLists are used for efficiently managing lists of entities. For example, a user's recipes are managed using a collection of
Recipe
entities within theUser
entity.
- ArrayLists are used for efficiently managing lists of entities. For example, a user's recipes are managed using a collection of
ArrayLists provide flexibility for storing and managing multiple entities efficiently within the application. The actual storage and retrieval of data are typically handled by the JPA repositories and the underlying database systems.
The database connection properties, including the URL, username, and password, are specified in the application.properties
file. Ensure that these properties are correctly configured to connect to your MySQL database.
Example configuration for MySQL:
spring.datasource.url=jdbc:mysql://<Public IP>:3306/RecipeManager
spring.datasource.username=root
spring.datasource.password=yourPassword
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
Please replace spring.datasource.url
, spring.datasource.username
, and spring.datasource.password
with your database connection details.
The Recipe Management System API with AWS is a comprehensive system for managing recipes, comments, user accounts, and categories. Users can create, update, categorize, and comment on recipes with ease. This system also allows for user registration and management, ensuring a personalized experience for every user.
The application follows best practices for clean code, separation of concerns, secure user data handling, and RESTful API design. Additionally, it leverages AWS services for robust and scalable data storage.
This project is licensed under the BSD 3-Clause License.
We would like to thank the Spring Boot and Java communities for providing excellent tools, frameworks, and resources that have contributed to the development of this project.
For questions or feedback, please contact Amit Ashok Swain.