Sweet Shop Management System is a full-stack web application for managing sweets inventory, sales, and administration. It supports secure user authentication, role-based access, real-time stock updates, sweet search and purchase features, and admin controls, built using REST APIs, a modern frontend, TDD, and AI-assisted development practices.
A full-stack web application for managing a sweet shop inventory with user authentication, role-based access control, and real-time inventory management.
- Project Overview
- Features
- Technology Stack
- Project Structure
- Prerequisites
- Installation & Setup
- Running the Application
- API Documentation
- Screenshots
- My AI Usage
- Testing
The Sweet Shop Management System is a modern web application designed to streamline the management of a sweet shop's inventory. It provides a user-friendly interface for customers to browse and purchase sweets, while offering administrators powerful tools to manage inventory, add new products, and track stock levels.
- Secure Authentication: JWT-based authentication with role-based access control
- Real-time Updates: Instant inventory updates when purchases are made
- Responsive Design: Beautiful, mobile-friendly interface built with Tailwind CSS
- Admin Dashboard: Comprehensive inventory management tools for administrators
- Search & Filter: Advanced search functionality to find sweets by name, category, or price
- Automatic Token Refresh: Seamless user experience with automatic session management
- 🔐 User registration and login
- 🍭 Browse all available sweets
- 🔍 Search and filter sweets by name, category, and price range
- 🛒 Purchase sweets with real-time inventory updates
- 📊 View current stock levels
- 🔄 Automatic session management
- 👥 All customer features
- ➕ Add new sweets to inventory
- ✏️ Edit existing sweet details
- 🗑️ Delete sweets from inventory
- 📦 Restock inventory with custom quantities
- 🎛️ Dedicated admin panel for management
- Java 21 - Programming language
- Spring Boot 3.5.7 - Application framework
- Spring Security - Authentication and authorization
- Spring Data JPA - Database operations
- MySQL 8.0 - Relational database
- JWT (JSON Web Tokens) - Token-based authentication
- Lombok - Reduce boilerplate code
- Maven - Build and dependency management
- React 18 - UI library
- JavaScript (ES6+) - Programming language
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- Axios - HTTP client for API calls
- Context API - State management
sweet-shop-management-system/
├── sweet-shop-server/ # Spring Boot Backend
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/sweet_shop_server/
│ │ │ │ ├── controller/ # REST controllers
│ │ │ │ ├── service/ # Business logic
│ │ │ │ ├── repository/ # Data access
│ │ │ │ ├── entity/ # JPA entities
│ │ │ │ ├── dto/ # Data transfer objects
│ │ │ │ ├── security/ # JWT & security config
│ │ │ │ └── configuration/ # App configuration
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/ # Unit tests
│ └── pom.xml
│
├── sweet-shop-client/ # React Frontend
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── hooks/ # Custom React hooks
│ │ ├── context/ # React context
│ │ ├── App.jsx # Main app component
│ │ └── main.jsx # Entry point
│ ├── public/ # Static assets
│ └── package.json
├── BACKEND_SETUP.md # Backend setup guide
├── FRONTEND_SETUP.md # Frontend setup guide
└── README.md # This file
Before you begin, ensure you have the following installed:
- Java Development Kit (JDK) 21 or higher
- Maven 3.6+ for building the project
- MySQL 8.0+ for the database
- IDE (IntelliJ IDEA, Eclipse, or VS Code recommended)
- Node.js 18+ and npm
- Modern web browser (Chrome, Firefox, Safari, or Edge)
git clone https://github.com/vikash-collab/Sweet_Shop_Management_System.git
cd sweet-shop-management-system-- Connect to MySQL
mysql -u root -p
-- Create database
CREATE DATABASE sweetshop;
-- Exit MySQL
EXIT;Edit sweet-shop-server/src/main/resources/application.properties:
# Server Configuration
server.port=8050
# JWT Secret Key (Change this in production!)
jwt.secretKey=your-super-secure-secret-key-here
# MySQL Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/sweetshop?useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=your_mysql_passwordA full-stack web application for managing a sweet shop inventory with user authentication, role-based access control, and real-time inventory management.
- Project Overview
- Features
- Technology Stack
- Project Structure
- Prerequisites
- Installation & Setup
- Running the Application
- API Documentation
- Screenshots
- My AI Usage
- Testing
The Sweet Shop Management System is a modern web application designed to streamline the management of a sweet shop's inventory. It provides a user-friendly interface for customers to browse and purchase sweets, while offering administrators powerful tools to manage inventory, add new products, and track stock levels.
- Secure Authentication: JWT-based authentication with role-based access control
- Real-time Updates: Instant inventory updates when purchases are made
- Responsive Design: Beautiful, mobile-friendly interface built with Tailwind CSS
- Admin Dashboard: Comprehensive inventory management tools for administrators
- Search & Filter: Advanced search functionality to find sweets by name, category, or price
- Automatic Token Refresh: Seamless user experience with automatic session management
- 🔐 User registration and login
- 🍭 Browse all available sweets
- 🔍 Search and filter sweets by name, category, and price range
- 🛒 Purchase sweets with real-time inventory updates
- 📊 View current stock levels
- 🔄 Automatic session management
- 👥 All customer features
- ➕ Add new sweets to inventory
- ✏️ Edit existing sweet details
- 🗑️ Delete sweets from inventory
- 📦 Restock inventory with custom quantities
- 🎛️ Dedicated admin panel for management
- Java 21 - Programming language
- Spring Boot 3.5.7 - Application framework
- Spring Security - Authentication and authorization
- Spring Data JPA - Database operations
- MySQL 8.0 - Relational database
- JWT (JSON Web Tokens) - Token-based authentication
- Lombok - Reduce boilerplate code
- Maven - Build and dependency management
<<<<<<< HEAD
- React 18 - UI library
- JavaScript (ES6+) - Programming language
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- Axios - HTTP client for API calls
- Context API - State management
sweet-shop-management-system/
├── sweet-shop-server/ # Spring Boot Backend
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/sweet_shop_server/
│ │ │ │ ├── controller/ # REST controllers
│ │ │ │ ├── service/ # Business logic
│ │ │ │ ├── repository/ # Data access
│ │ │ │ ├── entity/ # JPA entities
│ │ │ │ ├── dto/ # Data transfer objects
│ │ │ │ ├── security/ # JWT & security config
│ │ │ │ └── configuration/ # App configuration
│ │ │ └── resources/
│ │ │ └── application.properties
│ │ └── test/ # Unit tests
│ └── pom.xml
│
├── sweet-shop-client/ # React Frontend
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── hooks/ # Custom React hooks
│ │ ├── context/ # React context
│ │ ├── App.jsx # Main app component
│ │ └── main.jsx # Entry point
│ ├── public/ # Static assets
| └── package.json
│ └── package.json
│
|
├── BACKEND_SETUP.md # Backend setup guide
├── FRONTEND_SETUP.md # Frontend setup guide
└── README.md # This file
Before you begin, ensure you have the following installed:
=======
5a3a115 (Update README.md)
- Java Development Kit (JDK) 21 or higher
- Maven 3.6+ for building the project
- MySQL 8.0+ for the database
- IDE (IntelliJ IDEA, Eclipse, or VS Code recommended)
- Node.js 18+ and npm
- Modern web browser (Chrome, Firefox, Safari, or Edge)
<<<<<<< HEAD
git clone https://github.com/vikash-collab/Sweet_Shop_Management_System.git
=======
git clonehttps://github.com/Shailendrarai855/Sweet-Shop-Management-System.git
cd sweet-shop-management-system-- Connect to MySQL
mysql -u root -p
-- Create database
CREATE DATABASE sweetshop;
-- Exit MySQL
EXIT;Edit sweet-shop-server/src/main/resources/application.properties:
# Server Configuration
server.port=8050
# JWT Secret Key (Change this in production!)
jwt.secretKey=your-super-secure-secret-key-here
# MySQL Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/sweetshop?useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=your_mysql_password
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialectcd sweet-shop-server
mvn clean install
mvn spring-boot:runThe backend will start on http://localhost:8050
cd sweet-shop-client
npm installnpm run devThe frontend will start on http://localhost:3000
-
# On Linux/Mac sudo systemctl start mysql <<<<<<< HEAD ======= # On Windows net start MySQL80
=======
# On Linux/Mac
sudo systemctl start mysql
# On Windows
net start MySQL80- Start Backend <<<<<<< HEAD <<<<<<< HEAD
=======
cd sweet-shop-server
mvn spring-boot:run- Start Frontend (in a new terminal) <<<<<<< HEAD
=======
cd sweet-shop-client
npm run dev=======
cd sweet-shop-server
mvn spring-boot:run-
Start Frontend (in a new terminal)
cd sweet-shop-client npm run dev -
Access the Application
- Open your browser and navigate to
http://localhost:3000 - Register a new account
- Start browsing sweets!
- Open your browser and navigate to
By default, all users register as customers. To create an admin account:
- Register a user through the application
- Update the user's role in the database:
USE sweetshop; UPDATE users SET role = 'ADMIN' WHERE email = 'admin@example.com';
- Logout and login again
- You'll now see the "Admin Panel" link in the navbar
5a161e4 (Initial commit: Add Sweet Shop Management System)
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
Login user | No |
| Method | Endpoint | Description | Auth Required | Admin Only |
|---|---|---|---|---|
| GET | /api/sweets |
Get all sweets | Yes | No |
| GET | /api/sweets/search |
Search sweets | Yes | No |
| POST | /api/sweets |
Add new sweet | Yes | No |
| PUT | /api/sweets/{id} |
Update sweet | Yes | No |
| DELETE | /api/{id} |
Delete sweet | Yes | Yes |
| Method | Endpoint | Description | Auth Required | Admin Only |
|---|---|---|---|---|
| POST | /sweets/{id}/purchase |
Purchase sweet | Yes | No |
| POST | /sweets/{id}/restock |
Restock sweet | Yes | Yes |
=======
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
Login user | No |
| ======= | |||
| Method | Endpoint | Description | Auth Required |
| ------ | -------------------- | ----------------- | ------------- |
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
Login user | No |
5a161e4 (Initial commit: Add Sweet Shop Management System)
| Method | Endpoint | Description | Auth Required | Admin Only |
|---|---|---|---|---|
| GET | /api/sweets |
Get all sweets | Yes | No |
| GET | /api/sweets/search |
Search sweets | Yes | No |
| POST | /api/sweets |
Add new sweet | Yes | No |
| PUT | /api/sweets/{id} |
Update sweet | Yes | No |
| DELETE | /api/{id} |
Delete sweet | Yes | Yes |
| Method | Endpoint | Description | Auth Required | Admin Only |
|---|---|---|---|---|
| POST | /sweets/{id}/purchase |
Purchase sweet | Yes | No |
| POST | /sweets/{id}/restock |
Restock sweet | Yes | Yes |
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
curl -X POST http://localhost:8050/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:8050/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "password123"
}'curl -X GET http://localhost:8050/api/sweets \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```bash
curl -X POST http://localhost:8050/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:8050/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "password123"
}'curl -X GET http://localhost:8050/api/sweets \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Secure login with JWT authentication
User-friendly registration form
=======
Advanced search functionality to find sweets by name, category, or price range
Simple and intuitive purchase process with quantity selection
Comprehensive admin dashboard for inventory management
Easy-to-use form for adding new sweets to inventory
Update sweet details including name, category, price, and quantity
Quick restock functionality with custom quantity input
Secure login with JWT authentication
User-friendly registration form
=======
Advanced search functionality to find sweets by name, category, or price range
Simple and intuitive purchase process with quantity selection
Comprehensive admin dashboard for inventory management
Easy-to-use form for adding new sweets to inventory
Update sweet details including name, category, price, and quantity
Quick restock functionality with custom quantity input
I extensively used Kiro AI Assistant throughout the development of this project to accelerate development while maintaining code quality and best practices.
- Brainstorming: Used AI to discuss and refine the overall architecture of the application
- Technology Selection: Consulted AI on choosing the right tech stack (Spring Boot + React + MySQL)
- API Design: Collaborated with AI to design RESTful API endpoints following best practices
- Database Schema: Discussed and refined the database structure for users and sweets tables
- Boilerplate Generation: AI generated initial controller, service, and repository classes
- Security Configuration: AI helped implement JWT authentication and Spring Security configuration
- Exception Handling: Used AI to create global exception handlers and custom exceptions
- CORS Configuration: AI assisted in setting up proper CORS configuration for frontend integration
- Token Refresh Logic: Implemented cookie-based refresh token mechanism with AI guidance
Example: For the authentication system, I asked AI to generate the JWT service and security configuration, then manually customized the token expiry times and added refresh token functionality.
- Component Structure: AI generated the initial structure for all React components
- State Management: Used AI to implement Context API for authentication state
- API Integration: AI helped create axios interceptors for automatic token refresh
- Form Validation: Implemented client-side validation with AI assistance
- Responsive Design: AI provided Tailwind CSS classes for responsive layouts
- Custom Hooks: Created useSweets hook with AI guidance for state management
Example: The automatic token refresh logic in the API interceptor was initially generated by AI, then I refined it to work with our cookie-based backend implementation.
- Component Design: AI suggested component layouts and Tailwind CSS styling
- Color Scheme: Collaborated with AI to choose a pink/red gradient theme suitable for a sweet shop
- User Flow: Discussed and optimized user experience flows with AI
- Accessibility: AI helped ensure proper ARIA labels and keyboard navigation
-
Bug Identification: Used AI to help identify and fix issues like:
- JWT token decoding problems
- Role-based access control bugs
- API endpoint mismatches
- Input field UX issues
-
Error Handling: AI suggested comprehensive error handling strategies
-
Edge Cases: Discussed potential edge cases and how to handle them
- README Creation: AI helped structure and write comprehensive documentation
- Setup Guides: Generated detailed setup instructions for both backend and frontend
- API Documentation: Created API endpoint documentation with AI assistance
- Code Comments: AI suggested meaningful comments for complex logic
// Initial AI-generated structure
const AuthContext = createContext(undefined);
export const AuthProvider = ({ children }) => {
const [user, setUser] = useState(null);
// ... AI generated boilerplate
};I then manually added:
- JWT token decoding logic
- Role extraction from token payload
- Persistent authentication state
AI generated the basic structure with CRUD operations, and I customized:
- Error handling and user notifications
- Modal dialogs for add/edit operations
- Restock functionality with auto-focus input
- Responsive grid layout
AI helped identify a security vulnerability where users could self-register as admins. Together we:
- Removed the role selection from registration
- Implemented database-only admin creation
- Updated documentation with secure setup instructions
-
Accelerated Development: AI significantly reduced development time by generating boilerplate code and initial implementations. What might have taken days was accomplished in hours.
-
Best Practices: AI consistently suggested industry best practices for:
- RESTful API design
- Security implementations
- Code organization and structure
- Error handling patterns
-
Learning Opportunity: Working with AI helped me understand:
- JWT authentication flows
- React Context API patterns
- Spring Security configuration
- Modern frontend architecture
-
Problem Solving: When stuck on issues, AI provided multiple solution approaches, helping me choose the best one for my specific use case.
-
Documentation: AI made it easy to create comprehensive documentation, ensuring the project is well-documented and maintainable.
-
Context Understanding: Sometimes AI generated code that didn't perfectly match the backend implementation (e.g., refresh token endpoint structure), requiring manual adjustments.
-
Over-Engineering: Occasionally, AI suggested overly complex solutions when simpler ones would suffice. I had to evaluate and simplify.
-
Testing: While AI could generate test structures, I still needed to manually verify functionality and edge cases.
-
Business Logic: AI provided technical implementation, but I had to define the specific business requirements and user flows.
- Planning Phase: Discussed requirements and architecture with AI
- Implementation: AI generated initial code, I reviewed and customized
- Testing: Unit tested functionality, used AI to debug issues
- Refinement: Iteratively improved code with AI suggestions
- Documentation: AI helped create comprehensive docs
AI was an invaluable co-pilot throughout this project, but it was most effective when combined with:
- Critical thinking to evaluate AI suggestions
- Domain knowledge to guide AI in the right direction
- Unit testing to ensure everything works correctly
- Code review to maintain quality and consistency
- User registration works
- User login works
- JWT token is stored correctly
- Protected routes require authentication
- Admin routes require admin role
- Browse sweets displays all items
- Search functionality works
- Purchase decreases inventory
- Admin can add sweets
- Admin can edit sweets
- Admin can delete sweets
- Admin can restock inventory
- Token refresh works automatically
- Logout clears session
Contributions are welcome! Please follow these steps:
-
Fork the repository
-
Create a feature branch (
git checkout -b feature/AmazingFeature) -
Commit your changes with AI co-authorship:
git commit -m "feat: Add amazing feature Co-authored-by: Kiro AI Assistant <AI@users.noreply.github.com>"
-
Push to the branch (
git push origin feature/AmazingFeature) -
Open a Pull Request
- Kiro AI Assistant - AI Co-development
- Chatgpt AI Assistant - AI Co-development
- Spring Boot team for the excellent framework
- React team for the powerful UI library
- Tailwind CSS for the utility-first CSS framework
- Kiro AI for development assistance and guidance
- All open-source contributors whose libraries made this project possible
Note: This project was developed as part of a TDD Kata exercise to demonstrate full-stack development skills with modern technologies and AI-assisted development practices.
5a3a115 (Update README.md)