This project is an e-commerce site that includes authentication and various features such as categories, products, cart management, orders, and payments. It provides a robust API for interacting with these functionalities, with JWT-based authentication and role-based access control.
- Authentication: Secure login and registration with JWT and OAuth (Google, GitHub)
- Categories: Manage product categories
- Products: CRUD operations for products
- Cart: Add, remove, and view items in the cart
- Cart Items: Manage items within the cart
- Order: Place and manage orders
- Order Items: Manage items within orders
- Payment: Process payments
- Java 17 or higher
- Maven
- Docker (optional, for running services in containers)
- Clone the repository:
git clone https://github.com/yourusername/ecommerce-site.git cd ecommerce-site
Install dependencies:
bash Copy code mvn install Set up environment variables in .env or application.properties as required by your application.
bash Copy code mvn spring-boot:run (Optional) If using Docker, build and run the containers:
bash Copy code docker-compose up --build API Documentation The API is documented using Swagger. You can access the Swagger UI at: Swagger API Documentation
src/main/java/com/example/ecommerce/:
controllers: REST controllers for handling HTTP requests services: Business logic and service layer dtos: Data Transfer Objects for API requests and responses repos: Repository interfaces for data access authUtils: Utility classes for authentication and authorization
To authenticate, use the /auth/login endpoint to receive a JWT token. Include this token in the Authorization header of your requests as Bearer {token}.
For complete API documentation, including detailed descriptions of all endpoints, parameters, and responses, please refer to the Swagger UI:
After running the app go to http://localhost:8080/swagger-ui/index.html
GET /categories - List all categories with pagination Query Parameters: page, size, sort POST /categories - Create a new category PUT /categories/{id} - Update a category DELETE /categories/{id} - Delete a category
GET /products - List all products with pagination Query Parameters: page, size, sort POST /products - Create a new product PUT /products/{id} - Update a product DELETE /products/{id} - Delete a product
GET /cart - View the cart POST /cart/items - Add an item to the cart DELETE /cart/items/{id} - Remove an item from the cart
GET /orders - List all orders with pagination Query Parameters: page, size, sort POST /orders - Create a new order GET /orders/{id} - View a specific order
POST /payment - Process a payment
Feel free to contribute by opening issues, submitting pull requests, or suggesting features.
Create a new branch (git checkout -b feature-branch) Make your changes Commit your changes (git commit -am 'Add new feature') Push to the branch (git push origin feature-branch) Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For any inquiries, please contact om35453@gmail.com.
You can adjust the parameters and endpoints as needed.