This project is a robust e-commerce website built using Spring Boot. It follows the MVC architecture and incorporates various Spring-related technologies and third-party integrations to manage users, products, orders, and more. It leverages MongoDB for storage, JWT for authentication, and Cloudinary for image management.
- Spring Boot Starters: Web, Data REST, Mongo, Security, and Session.
- Third-party Integrations: Cloudinary, JWT, and Jakarta.
- Additional Tools: Lombok, Logging (Logback), CORS configuration, and AOP for modular design.
- Install Java JDK 17+ and an IDE like IntelliJ IDEA or Eclipse.
- MongoDB Setup:
- Create a MongoDB database.
- Replace the
spring.data.mongodb.uriinapplication.ymlwith your database's connection string. - Collections and schemas will be auto-generated at runtime.
- Cloudinary Account:
- Create an account on Cloudinary.
- Replace the values of
cloud-name,api-key, andapi-secretinapplication.ymlwith your Cloudinary credentials.
- Mail Configuration:
- Use your email and app password for the SMTP configuration in
spring.mail.
- Use your email and app password for the SMTP configuration in
- Clone the repository:
git clone <repository-url> cd ecommerce
- Build the project:
mvn clean install
- Run the application:
mvn spring-boot:run
- CORS Configuration:
- Update the frontend URL in the CORS settings within SecurityConfig to allow cross-origin requests.
- Logging:
- Change the logback.xml file path (Add your Folder Path) to your desired logging directory.
- Update the EcommerceApplication main file to reflect the updated path.
File logsDir = new File("<your-custom-log-directory>");
- Enable the Logback annotation for efficient logging.
- Update the @EnableMongoRepositories base package if you restructure the project.
@EnableMongoRepositories(basePackages = "<your.package.name>")
- Execute the provided unit and integration tests using Maven:
mvn test
- Role-based Authentication and Authorization:
- Admin with roles:
SUPER_ADMIN,USER_ADMIN, andPRODUCT_ADMIN. - Buyers and sellers with distinct functionalities.
- Admin with roles:
- JWT-Based Authentication:
- Secure user session management using JSON Web Tokens (JWT).
- Login and Registration:
- Separate flows for buyers, sellers, and admins.
- Input validation and custom exception handling for security.
- CRUD Operations:
- Create, read, update, and delete products with constraints (e.g., Seller ID).
- Image Upload & Deletion:
- Upload multiple product images to Cloudinary.
- Dynamically delete images from Cloudinary when removed from the database.
- Search Functionality:
- Fetch products by name, category, or seller ID.
- Category Management:
- Categorization for product organization and filtering.
- Placing and Tracking Orders:
- Buyers can place orders and track their statuses.
- Order history retrieval for users.
- Centralized Exception Management:
- Handled using
@ControllerAdvice.
- Handled using
- Custom Exceptions:
- Specific exceptions for scenarios like:
- User not found.
- Invalid credentials or roles.
- Product conflicts (e.g., duplicate names, invalid updates).
- Database access errors.
- Specific exceptions for scenarios like:
- MongoDB Integration:
- Document storage and retrieval.
- Query optimization with indexed fields like
sellerIdandproductName.
- API Endpoints:
- Designed to seamlessly integrate with a frontend application.
- MongoDB Connection Errors:
- Verify the URI and credentials in
application.yml. - Ensure MongoDB is running and accessible.
- Verify the URI and credentials in
- Cloudinary Misconfiguration:
- Ensure accurate account details in the
cloudinarysection ofapplication.yml. - Check for sufficient storage in your Cloudinary account.
- Ensure accurate account details in the
- SMTP Failures:
- Use valid email credentials in
spring.mail. - Enable app access in your email settings if required.
- Use valid email credentials in
- CORS Errors:
- Ensure the frontend URL is properly configured in the CORS settings.
- Payment Integration:
- Currently lacks a payment gateway for secure checkout functionality.
- Analytics and Reporting:
- Missing tracking for user behavior, popular products, or sales trends.
- Multithreading:
- For parallelized image uploads and deletions via Cloudinary.
- Soft Delete Enhancements:
- Ensure deleted items are invisible while maintaining a history.
- Live Tracking:
- Currently missing delivery and order tracking functionality.
- Authorization List for Admin:
- Replace hardcoded roles with a dynamic role-based structure.
- Improved Database Structure:
- Lookup queries can reduce redundancy and optimize database design.
-
The frontend for this project is available on GitHub. Api Lists are available in Readme.md of frontend. It provides a user-friendly interface for buyers, sellers, and admins.
This README serves as a guide for understanding, setting up, and contributing to this project. For additional queries or issues, please contact the project maintainer.
