Laptop Shop is a comprehensive e-commerce web application built using Spring MVC and Spring Boot. This application provides a platform for selling laptops online with features for both customers and administrators. The system includes product management, user authentication, shopping cart functionality, and order processing.
- Domain-driven design
- Repository pattern
- Java 17
- Spring Boot 3.2.2
- Spring MVC - Web framework
- Spring Security - Authentication and authorization
- Spring Data JPA - Database interaction
- Hibernate - ORM tool
- MySQL - Database
- JSP (Jakarta Server Pages) - Server-side templating
- JSTL - JSP Standard Tag Library
- Bootstrap - Responsive design
- CSS/JavaScript - Frontend styling and interactivity
- Maven - Dependency management and build automation
- Docker - Containerization
- Docker Compose - Multi-container application orchestration
- Product Browsing - Browse through available laptop products
- Product Search - Search for products by various criteria
- User Registration/Login - Create accounts and log in
- Shopping Cart - Add/remove products to/from shopping cart
- Order Management - Place and track orders
- Responsive Design - Optimized for different device sizes
- Dashboard - Overview of sales and system statistics
- Product Management - Add, edit, delete products
- User Management - Manage user accounts
- Order Processing - View and manage customer orders
laptopshop/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── vn/nvminh162/laptopshop/
│ │ │ ├── config/ # Application configuration
│ │ │ ├── controller/ # MVC controllers
│ │ │ │ ├── admin/ # Admin controllers
│ │ │ │ └── client/ # Client controllers
│ │ │ ├── domain/ # Entity classes
│ │ │ ├── repository/ # Data access layer
│ │ │ └── service/ # Business logic layer
│ │ ├── resources/
│ │ │ └── application.properties # Application settings
│ │ └── webapp/
│ │ ├── resources/ # Static resources
│ │ │ ├── client/ # Client-side resources
│ │ │ └── admin/ # Admin-side resources
│ │ └── WEB-INF/
│ │ └── view/ # JSP templates
│ └── test/ # Test classes
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker build configuration
└── pom.xml # Maven project configuration
The application uses MySQL with the following key entities:
- User - Stores user account information and credentials
- Product - Contains product details including price, description, and inventory
- Cart - Represents user shopping carts
- CartDetail - Contains details of items in a cart
- Order - Represents customer orders
- OrderDetail - Contains details of items in an order
- Role - Defines user roles for authorization
- Java 17 or higher
- Maven
- MySQL Server
- Docker (optional, for containerized deployment)
-
Clone the repository
git clone [repository-url] cd laptopshop -
Configure MySQL database
- Create a MySQL database named
laptopshop - Update database credentials in
src/main/resources/application.propertiesif needed:spring.datasource.url=jdbc:mysql://localhost:3306/laptopshop spring.datasource.username=root spring.datasource.password=root (your setting >,<>)
- Create a MySQL database named
-
Build the application
./mvnw clean package
-
Run the application
./mvnw spring-boot:run
-
Access the application
- Open a web browser and navigate to
http://localhost:8080
- Open a web browser and navigate to
-
Build and run with Docker Compose
docker compose -p nvminh162-spring-mvc up -d
-
Access the application
- Open a web browser and navigate to
http://localhost:8080
- Open a web browser and navigate to
The application supports file uploads with the following configuration:
spring.servlet.multipart.max-file-size=50MB
spring.servlet.multipart.max-request-size=50MBSpring Security is configured for both authentication and authorization, with separate roles for customers and administrators.
-
Database Connection Issues
- Ensure MySQL is running and accessible
- Verify database credentials in application.properties
-
Build Failures
- Make sure Java 17 is installed and configured correctly
- Ensure Maven is installed and added to PATH
-
Docker Issues
- Verify Docker and Docker Compose are installed
- Check if ports 8080 and 3306/3307 are available
- Create appropriate domain/entity classes
- Create repository interfaces extending JpaRepository
- Implement service classes with business logic
- Create controller endpoints
- Create JSP views
- Follow standard Java coding conventions
- Use proper JavaDoc comments for methods and classes
- Organize imports alphabetically