This project is a Fast Food Restaurant Management System built using Spring Boot for the backend and HTML/CSS/JavaScript for the frontend. It provides a platform for managing food categories, menu items, user roles, and shopping baskets. The system supports two types of users: Admin and Regular Users. Admins can manage categories, foods, and user roles, while regular users can browse the menu, add items to their basket, and place orders.
- Category Management:
- Create, update, and delete food categories.
- View all categories and their associated foods.
- Food Management:
- Add, update, and delete food items.
- Upload food images.
- User Management:
- View all users.
- Assign or remove roles (e.g., ADMIN, USER) for users.
- Dashboard:
- Access a centralized dashboard for managing the restaurant.
- Browse Menu:
- View food items by category.
- See food details (name, price, description, and image).
- Shopping Basket:
- Add or remove food items from the basket.
- Adjust quantities of items in the basket.
- Checkout and clear the basket.
- User Profile:
- View user details (email, roles).
- User Registration:
- Register with email, password, and full name.
- Email verification with a 4-digit code.
- User Login:
- Login with email and password.
- JWT-based authentication for secure access.
- Role-Based Access Control:
- Admins have access to all features.
- Regular users can only browse the menu and manage their basket.
- Spring Boot: Core framework for building the REST API.
- Spring Security: For authentication and authorization.
- Spring Data JPA: For database interactions.
- PostgreSQL: Relational database for storing data.
- JWT (JSON Web Tokens): For secure user authentication.
- JavaMailSender: For sending email verification codes.
- Lombok: For reducing boilerplate code.
- Multipart File Upload: For handling food image uploads.
- HTML/CSS: For structuring and styling the web pages.
- JavaScript: For dynamic interactions and API calls.
- Bootstrap: For responsive and modern UI components.
- Fetch API: For making HTTP requests to the backend.
- PostgreSQL: Database management.
- Postman: For testing API endpoints.
- Maven: For dependency management.
- Git: For version control.
- Controllers: Handle HTTP requests and responses.
- Services: Contain business logic.
- Repositories: Interact with the database.
- Entities: Represent database tables (e.g., User, Food, Category, Basket).
- Security: Configuration for JWT authentication and role-based access.
- Payloads: Data transfer objects (DTOs) for API requests and responses.
- HTML Pages:
index.html
: Main landing page.login.html
: User login page.register.html
: User registration page.adminMenuPage.html
: Admin dashboard.userMenuPage.html
: User menu page.categoryFoods.html
: Page to view foods in a category.verify-email.html
: Email verification page.
- JavaScript Files:
adminLoginData.js
: Handles admin login and role checks.userLoginData.js
: Handles user login and role checks.logout.js
: Handles user logout.
- Java Development Kit (JDK): Version 17 or higher.
- PostgreSQL: Installed and running.
- Maven: For building the project.
- Node.js: Optional, for running a local server for the frontend.
- Clone the Repository:
git clone https://github.com/JohnUfo/fast-food-rest.git cd fast-food-restaurant-management
- Configure Database:
- Update the
application.properties
file with your PostgreSQL credentials:spring.datasource.url=jdbc:postgresql://localhost:5432/fast_food spring.datasource.username=your-username spring.datasource.password=your-password
- Update the
- Run the Application:
The backend will start at
mvn spring-boot:run
http://localhost:8080
.
-
Serve the Frontend:
- Use a local server (e.g., Live Server in VS Code) to serve the HTML files.
- Open
index.html
to access the application.
-
Configure API Endpoint:
- Ensure the frontend JavaScript files point to the correct backend URL (e.g.,
http://localhost:8080
).
- Ensure the frontend JavaScript files point to the correct backend URL (e.g.,
- POST
/register
: Register a new user. - POST
/login
: Authenticate a user and return a JWT token. - POST
/verify-email
: Verify user email with a code.
- GET
/categories
: Get all categories. - POST
/categories
: Create a new category (Admin only). - PUT
/categories/{id}
: Update a category (Admin only). - DELETE
/categories/{id}
: Delete a category (Admin only).
- GET
/categories/{categoryId}/foods
: Get all foods in a category. - POST
/categories/{categoryId}/foods
: Add a new food (Admin only). - PUT
/categories/foods/{foodId}
: Update a food (Admin only). - DELETE
/categories/foods/{foodId}
: Delete a food (Admin only).
- GET
/basket
: Get the user's basket. - POST
/basket/add
: Add a food item to the basket. - DELETE
/basket/{foodId}
: Remove a food item from the basket. - DELETE
/basket/checkout
: Clear the basket (checkout).
- GET
/api/users
: Get all users (Admin only). - PUT
/api/users/{userId}/roles
: Update user roles (Admin only). - DELETE
/api/users/{userId}/roles
: Remove roles from a user (Admin only).