Skip to content

jakegithub24/Brew-Cafe-SpringBoot

Repository files navigation

Brew Cafe - Java Version

A complete coffee shop management system built with Spring Boot backend, MySQL database, and modern HTML/CSS/JavaScript frontend. This is a Java conversion of the original Node.js Brew Cafe project.

Project Structure

brew-cafe/
├── src/
│   ├── main/
│   │   ├── java/com/brewcafe/
│   │   │   ├── BrewCafeApplication.java       # Main application entry point
│   │   │   ├── config/                        # Spring configuration
│   │   │   ├── controller/                    # REST API controllers
│   │   │   │   ├── PageController.java        # Page routing
│   │   │   │   ├── CustomerController.java    # Customer endpoints
│   │   │   │   ├── AdminController.java       # Admin endpoints
│   │   │   │   ├── MenuController.java        # Menu item endpoints
│   │   │   │   ├── OrderController.java       # Order endpoints
│   │   │   │   ├── ReviewController.java      # Review endpoints
│   │   │   │   └── OfferController.java       # Offer endpoints
│   │   │   ├── model/                         # Entity classes
│   │   │   │   ├── Customer.java
│   │   │   │   ├── Admin.java
│   │   │   │   ├── MenuItem.java
│   │   │   │   ├── Order.java
│   │   │   │   ├── Review.java
│   │   │   │   └── Offer.java
│   │   │   ├── repository/                    # Data access layer (JPA)
│   │   │   ├── service/                       # Business logic layer
│   │   ├── resources/
│   │   │   ├── templates/                     # HTML templates
│   │   │   ├── static/
│   │   │   │   ├── css/style.css              # Styling
│   │   │   │   ├── js/                        # JavaScript files
│   │   │   │   └── images/                    # Images
│   │   │   └── application.properties         # Spring Boot config
│   └── test/                                  # Unit tests
├── pom.xml                                   # Maven dependencies
└── database.sql                              # MySQL schema

Features

Frontend

  • Modern UI/UX: Clean, responsive design with smooth animations

  • Pages:

    • Home page with featured offers and café info
    • Menu page with category filters and shopping cart
    • Customer login/registration
    • My Orders dashboard for customers
    • Admin login
  • Technologies: HTML5, CSS3, Vanilla JavaScript

Backend

  • REST API with Spring Boot
  • Database: MySQL
  • ORM: Spring Data JPA + Hibernate
  • Architecture: MVC pattern with layered architecture

API Endpoints

Customers

  • POST /api/customers/register - Register new customer
  • POST /api/customers/login - Customer login
  • GET /api/customers/{id} - Get customer by ID
  • GET /api/customers/phone/{phone} - Get customer by phone

Admins

  • POST /api/admins/login - Admin login
  • POST /api/admins - Create admin account
  • GET /api/admins/{id} - Get admin by ID

Menu Items

  • GET /api/menu - Get all menu items
  • GET /api/menu/categories - Get all categories
  • GET /api/menu/category/{category} - Get items by category
  • GET /api/menu/{id} - Get menu item by ID
  • POST /api/menu - Create menu item
  • PUT /api/menu/{id} - Update menu item
  • DELETE /api/menu/{id} - Delete menu item

Orders

  • GET /api/orders - Get all orders
  • GET /api/orders/customer/{customerId} - Get customer orders
  • GET /api/orders/status/{status} - Get orders by status
  • GET /api/orders/{id} - Get order by ID
  • POST /api/orders - Create new order
  • PUT /api/orders/{id}/status - Update order status
  • DELETE /api/orders/{id} - Delete order

Reviews

  • GET /api/reviews - Get all reviews
  • GET /api/reviews/{id} - Get review by ID
  • GET /api/reviews/customer/{phone} - Get reviews by customer
  • POST /api/reviews - Create review
  • DELETE /api/reviews/{id} - Delete review

Offers

  • GET /api/offers - Get all offers
  • GET /api/offers/active - Get active offers
  • GET /api/offers/{id} - Get offer by ID
  • POST /api/offers - Create offer
  • PUT /api/offers/{id} - Update offer
  • DELETE /api/offers/{id} - Delete offer

Prerequisites

  • Java 17 or higher
  • MySQL 8.0 or higher
  • Maven 3.6+

Setup Instructions

1. Database Setup

-- Connect to MySQL and run the database.sql file
mysql -u root -p < database.sql

-- Or manually in MySQL:
CREATE DATABASE IF NOT EXISTS brew_cafe;
USE brew_cafe;
-- Then paste the contents of database.sql

2. Configure Database Connection

Edit src/main/resources/application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/brew_cafe
spring.datasource.username=your_mysql_user
spring.datasource.password=your_mysql_password

3. Build the Project

mvn clean install

4. Run the Application

mvn spring-boot:run

Or run the main class:

java -cp target/brew-cafe-1.0.0.jar com.brewcafe.BrewCafeApplication

The application will start on http://localhost:8080

Usage

Customer Flow

  1. Visit the home page - browse offers and menu overview
  2. Click "Explore Menu" or go to /menu
  3. Register or login to place orders
  4. Select items and add to cart
  5. Place order - order appears in "My Orders"

Admin Flow

  1. Visit /admin-login
  2. Login with credentials (default: admin/password)
  3. Access admin dashboard to manage orders and menu

Sample Credentials

Admin Login:

  • Username: admin
  • Password: password

Alternative Staff Log in:

  • Username: staff
  • Password: 12345678

Technology Stack

Backend

  • Framework: Spring Boot 3.1.5
  • ORM: Spring Data JPA + Hibernate
  • Database: MySQL
  • Build Tool: Maven
  • IDE Compatible: IntelliJ IDEA, VS Code, Eclipse

Frontend

  • HTML5 - Structure
  • CSS3 - Styling (custom design system)
  • JavaScript (Vanilla) - Interactivity
  • Fetch API - AJAX calls

Configuration

Application Properties

# Server
server.port=8080
server.servlet.context-path=/

# Database
spring.datasource.url=jdbc:mysql://localhost:3306/brew_cafe
spring.datasource.username=root
spring.datasource.password=root

# JPA/Hibernate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

Project Features

✅ Customer registration and authentication ✅ Menu management with categories ✅ Shopping cart and order placement ✅ Order tracking and history ✅ Admin dashboard for order management ✅ Offers and promotions management ✅ Customer reviews system ✅ Responsive design ✅ RESTful API architecture ✅ Database schema with proper relationships

Future Enhancements

  • Payment gateway integration (Stripe/PayPal)
  • Email notifications for orders
  • SMS alerts for delivery
  • Admin analytics and reports
  • Rating and review system
  • Wishlist functionality
  • User profile management
  • Order cancellation feature
  • Delivery partner tracking
  • Admin dashboard UI

Dependencies

Direct Dependencies (Maven)

  • spring-boot-starter-web
  • spring-boot-starter-data-jpa
  • mysql-connector-java (8.0.33)
  • lombok (productivity tool)
  • spring-boot-devtools (development)
  • jackson-databind (JSON processing)

Build Plugins

  • spring-boot-maven-plugin

API Testing

Using cURL

# Get all menu items
curl http://localhost:8080/api/menu

# Create an order
curl -X POST http://localhost:8080/api/orders \
  -H "Content-Type: application/json" \
  -d '{"customerId":1,"customerName":"John","items":"Coffee x2","total":50}'

# Get customer orders
curl http://localhost:8080/api/orders/customer/1

Using Postman

  1. Create a new Collection
  2. Import the API endpoints
  3. Set request type (GET, POST, PUT, DELETE)
  4. Add JSON body for POST/PUT requests
  5. Send and verify responses

Troubleshooting

Database Connection Issues

  • Verify MySQL is running
  • Check credentials in application.properties
  • Ensure database exists: CREATE DATABASE brew_cafe;

Build Errors

  • Clear Maven cache: mvn clean
  • Update Maven: mvn -v
  • Check Java version: java -version (need 17+)

Port Already in Use

  • Change in application.properties: server.port=8081
  • Or kill the process using port 8080

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is open source and available under the GPL v3.0 License.

Support

For issues and questions:

  • Check the documentation
  • Review the code comments
  • Create an issue in the repository

Authors

About

A 'BrewCafe' website developed using SpringBoot.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors