Git Product home page Git Product logo

atillatahak / ecommerce-react Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 443 KB

This repository contains an e-commerce application developed using Redux and Redux-Saga. Built with React and TypeScript, this application features product listing and detail views. It also provides basic e-commerce functionality such as adding products to a shopping cart.

JavaScript 1.10% HTML 0.87% TypeScript 72.46% CSS 25.56%

ecommerce-react's Introduction

E-Commerce Frontend Case Study

Table of Contents

Overview

screenshot

This repository contains an e-commerce application developed using Redux and Redux-Saga. Built with React and TypeScript, this application features product listing and detail views. It also provides basic e-commerce functionality such as adding products to a shopping cart.

Features

Product Listing Page: Allows users to view various products and access their details. Product Detail Page: Displays detailed information about each product. Add to Cart and Cart Summary: Enables users to add products to their cart and lists the added items. Redux and Redux-Saga: Used for state management and controlling side effects. Unit Tests: Ensures robustness and fault tolerance of the application. Technologies Used

  • React
  • TypeScript
  • Redux
  • Redux-Saga
  • Axios
  • React Router DOM
  • Vitest
  • Testing Library

Project Structure

src/
├── app/
│   ├── store.ts
│   └── rootSaga.ts
├── components/
│   ├── CartItem.tsx
│   ├── CartItemBasket.tsx
│   ├── CartItemsList.tsx
│   ├── CartSummary.tsx
│   ├── Checkout.tsx
│   ├── Filter.tsx
│   ├── NavBar.tsx
│   ├── Pagination.tsx
│   ├── ProductCard.tsx
│   ├── SearchBar.tsx
│   ├── SortProduct.tsx
│   └── UserProfile.tsx
├── features/
│   ├── cart/
│   │   ├── cartSlice.ts
│   │   └── cartSaga.ts
│   └── products/
│       ├── productsSlice.ts
│       └── productsSaga.ts
├── hooks/
│   └── useFetch.ts
├── pages/
│   ├── ProductDetail.tsx
│   └── ProductList.tsx
├── services/
│   └── api.ts
├── styles/
│   └── global.css
│   ├── cart-item-basket.module.css
│   ├── cart-item.module.css
│   ├── cart-item-list.module.css
│   ├── check-out.module.css
│   ├── filter.module.css
│   ├── navbar.module.css
│   ├── product-card.module.css
│   ├── product-detail.module.css
│   ├── product-list.module.css
│   ├── profile.module.css
│   ├── search-bar.module.css
│   └── sort.module.css
├── tests/
│   └── components/
│       ├── CartSummary.test.tsx
│       └── ProductCard.test.tsx
└── App.tsx

Setup and Running

Follow these steps to get the project up and running on your local machine.

Clone the Project and Install Dependencies Start the Development Server

$  git clone github.com/AtillaTahak/Ecommerce-React
$  cd ecommerce-react
$  npm install
$  npm run dev

Run Tests

$  npm run test

Redux and Redux-Saga Workflow

What is Redux-Saga?
Redux-Saga is a library used to manage side effects in Redux-based applications. It is especially preferred for asynchronous operations (API calls, localStorage operations, etc.).

Workflow in This Project

Store Structure:

store.ts creates the Redux store and adds saga middleware. rootSaga.ts combines all sagas. Managing Products with Redux-Saga: Slice: productsSlice.ts uses Redux slice logic to define a reducer and actions for products. Saga: productsSaga.ts defines a saga function to fetch products from the API. Saga Flow

graph TD
A[Store] --> B[Product Slice]
B --> C[Redux Action: fetchProductsStart]
C --> D[Product Saga]
D -->|API Call| E[fetchProductsSuccess / fetchProductsFailure]
E --> B

Example Usage

In ProductList.tsx, the fetchProductsStart action is triggered when the product listing page is loaded. This action activates the fetchProductsSaga function in productsSaga.ts. fetchProductsSaga fetches the products from the API and passes the result to Redux state via the fetchProductsSuccess or fetchProductsFailure actions.

Contact

ecommerce-react's People

Contributors

atillatahak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.