A simple and elegant pizzeria prototype built with React. Browse through a selection of delicious pizzas, filter by category, customize by size and type, and manage your cart with ease.
- Features
- Tech Stack
- Installation
- Running the Project
- Project Structure
- Code Explanations
- Available Scripts
- Contributing
- License
- π Browse a curated list of pizzas
- π·οΈ Filter pizzas by category
- π Choose pizza size and type
- π Add/remove items from your shopping cart
- πΎ Persistent cart using localStorage
- π¨ Clean and modern UI
- π± Responsive design (in progress)
- π Redux state management for cart operations
- React (v19.2.5) - UI library for building interactive components
- TypeScript (70.2%) - Type-safe JavaScript for better code reliability
- CSS (25%) - Custom styling with CSS modules
- Vite (v8.0.10) - Modern bundler for fast development
- Redux Toolkit (v2.11.2) - Simplified Redux state management
- React Redux (v9.2.0) - React bindings for Redux
- React Router (v6.30.3) - Client-side routing for navigation
- Axios (v1.16.0) - HTTP client for API requests
- Supabase (v2.106.1) - Backend-as-a-Service for database operations
- React Content Loader (v7.1.2) - Skeleton loading components
- Vercel Analytics (v2.0.1) - Analytics tracking
- Vite - Fast module bundler with HMR (Hot Module Replacement)
- ESLint (v10.2.1) - Code quality and linting
- React Router DOM (v6.30.3) - DOM-specific routing utilities
- Node.js (v16 or higher)
- npm or yarn package manager
- Clone the repository
git clone https://github.com/c1felode/react-pizza.git
cd react-pizza- Install dependencies
npm install
# or
yarn install- Environment Variables (if needed)
Create a
.envfile in the root directory for any API keys or configuration:
VITE_API_URL=your_api_url_here
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_KEY=your_supabase_keyStart the development server with hot module replacement:
npm run dev
# or
yarn devThe application will be available at http://localhost:5173
Create an optimized production build:
npm run build
# or
yarn buildPreview the production build locally:
npm run preview
# or
yarn previewCheck code quality with ESLint:
npm run lint
# or
yarn lintreact-pizza/
βββ src/
β βββ components/ # Reusable React components
β β βββ CartItem/ # Individual cart item component
β β βββ Header/ # Application header
β β βββ ...
β βββ pages/ # Page components
β β βββ Home.tsx # Main pizzeria page
β β βββ Cart.tsx # Shopping cart page
β β βββ EmptyCart.tsx # Empty cart message
β βββ redux/ # Redux store and slices
β β βββ slices/ # Redux action creators
β β β βββ cartSlice.ts # Cart state management
β β βββ store.ts # Redux store configuration
β βββ types/ # TypeScript type definitions
β β βββ types.ts # General types
β β βββ redux.ts # Redux state types
β βββ App.tsx # Root application component
β βββ App.css # Global styles
β βββ index.css # Root styles
β βββ main.tsx # React DOM render entry point
βββ index.html # HTML template
βββ package.json # Project dependencies
βββ vite.config.ts # Vite configuration
βββ eslint.config.js # ESLint configuration
βββ tsconfig.json # TypeScript configuration
The main component sets up routing and conditional rendering for the cart:
// Routes between Home and Cart pages
// Shows EmptyCart component when cart has no items
// Shows Cart component when items are in cart
<Routes>
<Route path='/' element={<Home />} />
<Route path='/cart' element={items.length > 0 ? <Cart /> : <EmptyCart />} />
</Routes>Redux manages global state for:
- Pizza Items: List of available pizzas with loading states
- Filters: Category and sort preferences
- Cart: Items, total price, and item count
Benefits: Centralized state management, easy debugging, predictable state updates
Handles all cart operations:
- addItem: Adds pizza to cart or increments count if already present
- minusItem: Decreases pizza quantity (won't go below 1)
- removeItem: Removes pizza completely from cart
- clearCart: Empties entire cart
- localStorage Integration: Persists cart data across browser sessions
const updateCartStorage = (state: ICartState) => {
state.totalPrice = state.items.reduce((sum, obj) => (obj.price * obj.count) + sum, 0);
state.totalCount = state.items.reduce((sum, obj) => obj.count + sum, 0);
localStorage.setItem('cart', JSON.stringify(state.items));
};Individual item in cart with controls:
- Displays pizza image, title, size, and type
- Plus/minus buttons to adjust quantity
- Delete button to remove item
- Dispatches Redux actions for state updates
Uses React Router v6 for:
- Page navigation without page reloads
- URL-based state management
- Link components for navigation
Type safety throughout the app:
TCartItem: Defines pizza cart item structureIPizzaState: Redux pizza state interfaceICartState: Redux cart state interfaceIRootState: Complete Redux state shape
User Action (Click Add/Remove)
β
Component dispatches Redux Action
β
Reducer updates state
β
Component receives updated state via useSelector
β
Component re-renders with new data
β
localStorage is synced automatically
- Responsive mobile design
- Advanced styling and animations
- More features and enhancements
- Payment integration
- Order tracking
- User authentication
- Admin dashboard
ISC
Feel free to fork this project and submit pull requests for any improvements!
For issues and questions, please open an issue on GitHub Issues
Happy coding! π Enjoy building your pizzeria!