Welcome to the e-commerce platform project! This project is designed to provide a comprehensive online shopping experience, featuring a client-side application built with React and a server-side application powered by Node.js and Express.
The project is organized into two main directories: client and server.
The client directory contains the front-end application built with React. It includes:
- Public Assets: Static files such as
favicon.icoandindex.html. - Components: Reusable UI components organized into common, layout, and product categories.
- Contexts: Context providers for managing authentication and cart state.
- Hooks: Custom hooks for handling authentication and cart logic.
- Pages: Different pages of the application, including Home, Product, Cart, Checkout, and Auth.
- Services: API and authentication service functions.
- Utils: Utility functions for various purposes.
- Storybook: A tool for developing and testing UI components in isolation.
The server directory contains the back-end application built with Node.js and Express. It includes:
- Configuration: Database and authentication configuration files.
- Controllers: Logic for handling requests related to authentication, orders, and products.
- Middlewares: Middleware functions for authentication and error handling.
- Models: Database models for Orders, Products, and Users.
- Routes: API endpoints for authentication, orders, products, and users.
- Services: Functions for handling OAuth providers.
- User Authentication: Implemented using OAuth for secure user management.
- Product Listings: Users can view and interact with a list of products.
- Shopping Cart: Users can add products to their cart and proceed to checkout.
- Responsive Design: The application is designed to work on various devices.
To get started with the project, follow these steps:
-
Clone the repository:
git clone <repository-url> -
Navigate to the project directory:
cd e-commerce-platform -
Install dependencies for the client:
cd client npm install -
Install dependencies for the server:
cd ../server npm install -
Set up environment variables:
- Copy
.env.exampleto.envand fill in the required values. - Create a new JWT secret
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"- or
openssl rand -hex 64- put the result in place of
your_jwt_secret
- Copy
-
Start the server:
cd server npm start -
Start the client:
cd ../client npm start -
Access the application in your browser at
http://localhost:3000.
To develop and test components in isolation, you can run Storybook:
-
Navigate to the client directory:
cd client -
Start Storybook:
npm run storybook -
Access Storybook in your browser at
http://localhost:6006.
This project maintains high test coverage standards to ensure code quality and reliability.
- Global Minimum: 0% statements, functions, lines; 70% branches
- Components: 0% statements, functions, lines; 80% branches
- Critical Areas: 0%+ coverage for business logic and data handling
To be improved while we add more tests.
# Run all tests
npm test
# Run tests with coverage report
npm run test:coverage
# Run client tests only
npm run client:test
# Run client tests with coverage
npm run client:test -- --coverage
# Run tests in watch mode
npm run test:watchCoverage reports are automatically generated and can be found in:
client/coverage/- Client-side coverage reportscoverage/- Server-side coverage reports (when available)
Open client/coverage/lcov-report/index.html in your browser to view detailed coverage reports.
GitHub Actions automatically:
- Runs all tests on every push and pull request
- Checks coverage thresholds
- Generates coverage reports
- Posts coverage summaries on pull requests
- Uploads coverage data to Codecov
Contributions are welcome! Please open an issue or submit a pull request for any improvements or features you'd like to add.
This project is licensed under the MIT License. See the LICENSE file for more details.