Skip to content

praytoo/Capstone3-YourFamilyGrocerApp

Repository files navigation

πŸ›’ Your Family Grocer App

A full‑stack e‑commerce grocery application built as a Spring Boot API capstone project. This project demonstrates backend API design, security with JWT authentication, MySQL persistence, and a dynamic client application that consumes the API.

πŸ“š Table of Contents


πŸ“Œ Project Overview

Your Family Grocer App is an online grocery store that allows users to:

  • Browse products by category
  • Filter products
  • Log in with JWT authentication
  • Add products to a shopping cart
  • View and manage their profile
  • Checkout and place orders

Administrators can additionally:

  • Manage product categories
  • Create, update, and delete products

This project was built as part of Capstone 3 – E‑Commerce API.


🧰 Tech Stack

Backend

  • Java 17
  • Spring Boot
  • Spring Security + JWT
  • Spring MVC (REST Controllers)
  • JDBC / DAO Pattern
  • MySQL
  • Maven
  • JUnit 5 & MockMvc (Testing)

πŸ—‚οΈ Project Structure

Capstone3-YourFamilyGrocerApp
β”‚
β”œβ”€β”€ capstone-api-starter        # Spring Boot REST API
β”‚   β”œβ”€β”€ src/main/java/org/yearup
β”‚   β”‚   β”œβ”€β”€ configurations      # App configuration
β”‚   β”‚   β”œβ”€β”€ controllers         # REST controllers
β”‚   β”‚   β”œβ”€β”€ data/mysql          # DAO implementations
β”‚   β”‚   β”œβ”€β”€ models              # Domain models
β”‚   β”‚   β”œβ”€β”€ security/jwt        # JWT auth + filters
β”‚   β”‚   └── service             # Business logic
β”‚   └── src/test/java/org/yearup
β”‚       β”œβ”€β”€ controllers         # Controller tests
β”‚       └── data/mysql          # DAO tests
β”‚
└── capstone-web-applications   # Frontend client
   └── capstone-client-groceryapp
        β”œβ”€β”€ css
        β”œβ”€β”€ images
        β”œβ”€β”€ js
        β”‚   └── services        # Client-side services
        └── templates           # Html templates

✨ Features

User Features

  • User registration & login
  • JWT-based authentication
  • Profile management
  • Product browsing & filtering
  • Shopping cart management
  • Checkout flow

Admin / System Features

  • Secure REST API
  • Stateless authentication
  • Role-based access control
  • DAO-driven persistence layer
  • Clean separation of concerns

πŸ—„οΈ Database Schema

Key tables include:

  • users
  • orders
  • products
  • profiles
  • categories
  • shopping_cart
  • order_line_items

🌐 REST Endpoints

Authentication

  • POST http://localhost:8080/auth/register
  • POST http://localhost:8080/auth/login

Products

  • GET http://localhost:8080/products
  • GET http://localhost:8080/products/{id}

Categories

  • GET http://localhost:8080/categories

Shopping Cart

  • GET http://localhost:8080/cart
  • POST http://localhost:8080/cart/products/{productId}
  • PUT http://localhost:8080/cart/products/{productId}
  • DELETE http://localhost:8080/cart

πŸ“¦ Example JSON Requests

Login

  • POST http://localhost:8080/login
{
  "username": "Prince87",
  "password": "password123"
}

Add Product to Database

  • POST http://localhost:8080/products
{
  "productId": 63,
  "name": "Teriyaki Chicken",
  "price": 6.99,
  "categoryId": 1,
  "description": "Delicious chicken marinated in teriyaki sauce",
  "subCategory": "Fresh",
  "stock": 50,
  "imageUrl": "teriyaki-chicken.jpg",
  "featured": true
}

▢️ Installation Run Instructions

Installation

Clone the repository from GitHub:

git clone https://github.com/praytoo/Capstone3-YourFamilyGrocerApp.git
cd Capstone3-YourFamilyGrocer

Build the project using Maven:

mvn clean install

Run

mvn spring-boot:run

API runs at http://localhost:8080


🧠 Interesting Code Snippet

Products Controller Add A Product

//add product
//only admin can use this function
@PostMapping()
@PreAuthorize("hasRole('ROLE_ADMIN')")
public Product addProduct(@RequestBody Product product)
{
    try
    {
        return productService.create(product);
    }
    catch(Exception ex)
    {
        throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops... our bad.");
    }
}

Why it is interesting: this piece of code is interesting because it alone allows you to add a new product to the database if you have admin authorization. This line is what makes it admin restrictive:

@PreAuthorize("hasRole('ROLE_ADMIN')")

While these lines produce the ability to add a new product:

@PostMapping()
public Product addProduct(@RequestBody Product product)
{
    try
    {
        return productService.create(product);
    }
    catch(Exception ex)
    {
        throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Oops... our bad.");
    }
}

πŸ–ΌοΈ Landing Pages API Testing and UML Diagram

  • Website Walk Through: Landing Page
  • API Testing: API Testing
  • Login Page: Login
  • Product Catalog: Product Catalog
  • Shopping Cart: Cart
  • Checkout Page: Checkout
  • UML Diagram: UML Diagram

πŸ‘€ Author

Prince Haywood Playa Vista, CA


βœ… License

This project is for educational purposes as part of Year Up United: Learning to Code Academy capstone 3.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors