A mini e-commerce application with a Node.js backend (using Express.js and MongoDB) and a React frontend.
Build a mini e-commerce application that has both a backend (Node.js) and frontend (React). The application should have the following functionalities:
- User Authentication: Register, Login, and Logout.
- Product Management: CRUD operations on products.
- Shopping Cart: Users should be able to add products to their cart, view their cart, and checkout.
- Use Express.js.
- Set up a database (e.g., MongoDB).
- Implement JWT or another form of token-based authentication.
- User APIs: Registration, Login, Logout.
- Product APIs: Add, Update, Delete, and List products.
- Cart APIs: Add to cart, Remove from cart, List items in the cart, Checkout.
- Implement unit and integration tests using tools like Jest.
- Mock database interactions for unit tests.
- Ensure passwords are hashed before saving.
- Secure sensitive routes (like product management) to be accessible only by admin users.
- Responsive design.
- Product listing page with a search functionality.
- User profile and order history page.
- Basic Admin interface for product management.
- Shopping cart page.
- Use React Router to manage navigation.
- Implement unit and integration tests using tools like Jest.
- Optional: End-to-end tests using tools like Cypress.
- Ensure components are modular and reusable.
- Proper error handling, showing appropriate messages to users.
- Use of hooks, functional components, and other modern React best practices.
- Functionality: Does the application work without errors?
- Code Quality: Is the code clean, modular, and maintainable?
- Scalability: Is the solution designed to scale?
- Security: Are there any security vulnerabilities?
- Testing: Are the tests meaningful and covering important aspects?
- Documentation: Is the code well-commented? Is there a README detailing setup instructions and architecture decisions?
mini-ecommerce/
├── backend/ - Node.js backend code
│ ├── config/ - Configuration files (e.g., database setup)
│ ├── models/ - Mongoose data models
│ ├── routes/ - API route definitions
│ ├── middleware/ - Middleware (e.g., authentication)
│ ├── tests/ - Backend tests
│ └── index.js - Entry point
├── frontend/ - React frontend code
│ ├── src/
│ │ ├── components/ - React components
│ │ ├── pages/ - Pages or views
│ │ ├── tests/ - Frontend tests
│ │ ├── App.js - Main App component
│ │ └── index.js - Entry point
│ └── package.json - Frontend dependencies
└── README.md
- Node.js and npm
- MongoDB
- Clone the Repository:
git clone https://github.com/hcevikGA/ecommerce-test-ga
cd ecommerce-test-ga
- Install dependencies:
cd ecommerce-backend/
npm install
cd ../ecommerce-frontend/
npm install
- Run Backend:
cd ecommerce-backend/
npm run dev
- Run Frontend:
cd ecommerce-frontend/
npm start
The React app should open automatically in your browser, typically at http://localhost:3000.
- Backend Tests:
cd ecommerce-backend/
npm test
- Frontend Tests:
cd ecommerce-frontend/
npm test
For end-to-end tests using Cypress:
npm run cypress:open