Dining Review Java Spring API

Overview

The Dining Review API allows users to submit and view dining reviews for restaurants. Users can create accounts, submit reviews for restaurants, and view pending reviews. Admins have the ability to approve or reject pending reviews. It was build using Java and the Spring framework.
Here's the code on GitHub.

Features

  • User registration and profile management
  • Submitting dining reviews with allergy scores
  • Admin approval workflow for reviews
  • Viewing pending reviews for admin
  • Restaurant submission
  • Retrieving restaurants by allergy scores and location

  • Technologies Used

    • Spring Boot: Used Spring Boot framework to develop the backend of the DiningReview app, handling API requests, data processing, and database interactions.
    • Spring Data JPA: Utilized Spring Data JPA for seamless integration with the database, simplifying data access and persistence operations.
    • Hibernate: Integrated Hibernate as the Object-Relational Mapping (ORM) tool, facilitating the mapping of Java objects to database tables. This enabled efficient database operations, automatic schema generation, and enhanced data management.
    • Java: Developed the backend logic and business logic of the application using the Java programming language.
    • RESTful API: Designed and implemented a RESTful API for communication between the frontend and backend components of the app.
    • Spring Web: Utilized Spring Web module to create and manage RESTful endpoints for user registration, review submission, and admin actions.
    • Curl: Utilized Curl, a command-line tool, to test and interact with the API endpoints during development.
    • Git: Managed version control using Git to track changes and collaborate on the codebase.
    • GitHub: Hosted the project on GitHub to facilitate code sharing, collaboration, and version history tracking.
    • JSON: Utilized JSON (JavaScript Object Notation) as the data interchange format for API requests and responses.

    Some of the functionality

    The controller class called DiningReviewController implements several methods that handle requests made to the API. The images below showcase how some of the routes are used:

    Adding a User

    To add a new user to the system, the /users endpoint is used with a POST request. This route receives user details, such as username, city, state, and allergies, and ensures that the username is unique before saving the user profile.

    Adding a Restaurant

    Adding a restaurant is achieved through the /restaurants endpoint with a POST request. The route validates whether a restaurant with the same name and zip code already exists before saving the new restaurant entry.

    Getting User Information

    To retrieve user information based on a specific username, the /users/by-username/{username} endpoint is used. This route returns user details, such as city and state, associated with the provided username.

    Posting a Review

    Posting a dining review involves sending a POST request to the /dining-reviews endpoint. The route verifies the existence of the user based on the username, then saves the review details to the repository.

    Getting Pending Reviews

    To retrieve a list of pending reviews, the /admin/pending-reviews endpoint is used. This route fetches reviews with an "PENDING" approval status and returns them for administrative purposes.

    Admin - Getting Users

    Administrators can access user information using the /admin/users endpoint. This route returns a list of all registered users, allowing administrators to manage user profiles and information.

    Getting All Reviews

    The /admin/reviews endpoint is used to retrieve all dining reviews in the system. This route provides administrators with an overview of all reviews, including their details and approval status.

    Accepting a Review

    Review approval or rejection is facilitated through the /admin/reviews/{id} endpoint with a PUT request. Administrators can specify the approval status ("ACCEPTED" or "REJECTED") to update the review accordingly.